From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB1BBECAAA1 for ; Tue, 30 Aug 2022 12:16:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230074AbiH3MQp (ORCPT ); Tue, 30 Aug 2022 08:16:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229781AbiH3MQo (ORCPT ); Tue, 30 Aug 2022 08:16:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E297CAB1B5 for ; Tue, 30 Aug 2022 05:16:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4A7ED6160B for ; Tue, 30 Aug 2022 12:16:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEB68C433D6; Tue, 30 Aug 2022 12:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661861802; bh=/N05Ut6pL6u3K483klYAOd9CgyYiliwvzUbSC8NeEmM=; h=Subject:From:In-Reply-To:References:To:Cc:Date:From; b=O6Ew6NjK1no1vTWscccFnSwjPNKTbwStX00x0Y0WxFjd26Aztpu4SH4ZnBPXltihG elNm4pIMjXPcOm0FuG3SC4FZjEln3cPn+bCN2vEcKw/Xn08pw5CUULoIXTrDx3TfQ4 bGM3nDpd0BLMI9+niMpKD/zkDSZhW/cg2BBVEtSGuJZPqrGiRJT5lokmeRoHyR+2+d o9EH9NvmGJc4oyuqC9Xs1Qv5HgCieoL4DJkx7mFZEWOivHZ8q17qEGVWICVFAj9I/m bFdc47Vy/DEFYwfkBCRPVXCq7yjl3X90U/t4sKk3KVyrQfEmByW+OAIBoY/yE85CUV rTfakDqXFIzkA== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: Re: [PATCH v2] ath9k: avoid uninit memory read in ath9k_htc_rx_msg() From: Kalle Valo In-Reply-To: <7acfa1be-4b5c-b2ce-de43-95b0593fb3e5@I-love.SAKURA.ne.jp> References: <7acfa1be-4b5c-b2ce-de43-95b0593fb3e5@I-love.SAKURA.ne.jp> To: Tetsuo Handa Cc: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , linux-wireless User-Agent: pwcli/0.1.1-git (https://github.com/kvalo/pwcli/) Python/3.7.3 Message-ID: <166186178944.2851.7181874556097643606.kvalo@kernel.org> Date: Tue, 30 Aug 2022 12:16:41 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Tetsuo Handa wrote: > syzbot is reporting uninit value at ath9k_htc_rx_msg() [1], for > ioctl(USB_RAW_IOCTL_EP_WRITE) can call ath9k_hif_usb_rx_stream() with > pkt_len = 0 but ath9k_hif_usb_rx_stream() uses > __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC) based on an assumption that > pkt_len is valid. As a result, ath9k_hif_usb_rx_stream() allocates skb > with uninitialized memory and ath9k_htc_rx_msg() is reading from > uninitialized memory. > > Since bytes accessed by ath9k_htc_rx_msg() is not known until > ath9k_htc_rx_msg() is called, it would be difficult to check minimal valid > pkt_len at "if (pkt_len > 2 * MAX_RX_BUF_SIZE) {" line in > ath9k_hif_usb_rx_stream(). > > We have two choices. One is to workaround by adding __GFP_ZERO so that > ath9k_htc_rx_msg() sees 0 if pkt_len is invalid. The other is to let > ath9k_htc_rx_msg() validate pkt_len before accessing. This patch chose > the latter. > > Note that I'm not sure threshold condition is correct, for I can't find > details on possible packet length used by this protocol. > > Link: https://syzkaller.appspot.com/bug?extid=2ca247c2d60c7023de7f [1] > Reported-by: syzbot > Signed-off-by: Tetsuo Handa > Acked-by: Toke Høiland-Jørgensen > Signed-off-by: Kalle Valo Patch applied to ath-next branch of ath.git, thanks. b383e8abed41 wifi: ath9k: avoid uninit memory read in ath9k_htc_rx_msg() -- https://patchwork.kernel.org/project/linux-wireless/patch/7acfa1be-4b5c-b2ce-de43-95b0593fb3e5@I-love.SAKURA.ne.jp/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches