Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4131188rwe; Tue, 30 Aug 2022 05:17:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR4gwxYxJn1l6VU+JMAm8HXxPSMicGE+iKqFSaZ5mLjmpZlykZffFcLK/vVBSRFVY06mbFSI X-Received: by 2002:a17:906:fe0b:b0:730:3646:d177 with SMTP id wy11-20020a170906fe0b00b007303646d177mr16109043ejb.688.1661861856659; Tue, 30 Aug 2022 05:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661861856; cv=none; d=google.com; s=arc-20160816; b=ySuWeqsfq/sqnUY453K8XPXZ9IU2OZWYaPtt1MYQYPBe8wHytbNqDDET07ecpN017u 7Zh6bkW5vWrN9eK+yckXUeDtG4XplOBsxC89UUZsMPez3m2iaRTNyZq2aALDtcIJO8ye jpgHVOqgUj47n7xPmlx/YJQ838/e/vp8CfQHJpicS5+t3ymqowJX1/BZAX8lBspQTwXt S4Gqqy6EemfG++OPeewBvHmBl7ERE02zjXY2kJaHhSYNozZcbwu4m/F74wq+oSlhuSKo cFNhtmjA5+TrAP5HL+m+TQge1Ij+oNNcKuUh+HV3z4snPFpTqtKDg/6DxLmn+aBoG105 rQRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:message-id:user-agent:cc:to:references :in-reply-to:from:subject:content-transfer-encoding:mime-version :dkim-signature; bh=XHqbVrYanivcL3BmIokRIPor0WRlm33mN3RUhY9uzV8=; b=H/jaccVcItGmgRynB0rGiWEe0H5IMAhk5Wo6pi5fN1OxYeb2EJh0EKLSAdLIshDdvf 76DsL6b7Tf9WalVvSc2rHnxYCrVQ9gQ5/XaF0i+QckPq4q6VnQ81nE+98KY4xilodgpo Z4rTvZRtCCyqF6PCkUXlsMK70UBEl5FfUh+xUne3Ca1TXjWlmtQeYWHwPecJdgjM2iSm 0BUFsRR5L1Z7hKQ9+Qu9nOkZ33w/XL5brZlWHsKOqeQ9Qub5SA1rr5kDwjM8Ysr3AEn3 XbPZa1zYrI1GxFXV7iGPnhPOorxFHymT0bKkW1q27RdmGccx7XFCZpLhypK2P0o0/mc+ ORMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O6Ew6NjK; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c10-20020a50d64a000000b00446d2362b7esi8612125edj.539.2022.08.30.05.17.18; Tue, 30 Aug 2022 05:17:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O6Ew6NjK; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230074AbiH3MQp (ORCPT + 64 others); 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) X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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