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 X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B9CFC433ED for ; Sun, 2 May 2021 20:28:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1739361352 for ; Sun, 2 May 2021 20:28:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232526AbhEBU3a (ORCPT ); Sun, 2 May 2021 16:29:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232374AbhEBU3a (ORCPT ); Sun, 2 May 2021 16:29:30 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59627C06174A; Sun, 2 May 2021 13:28:38 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1ldIhX-000260-Ah; Sun, 02 May 2021 22:28:27 +0200 Date: Sun, 2 May 2021 22:28:27 +0200 From: Florian Westphal To: Phillip Potter Cc: kvalo@codeaurora.org, davem@davemloft.net, kuba@kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ath9k-devel@qca.qualcomm.com Subject: Re: [PATCH] ath9k: ath9k_htc_rx_msg: return when sk_buff is too small Message-ID: <20210502202827.GG975@breakpoint.cc> References: <20210502202545.1405-1-phil@philpotter.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210502202545.1405-1-phil@philpotter.co.uk> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Phillip Potter wrote: > At the start of ath9k_htc_rx_msg, we check to see if the skb pointer is > valid, but what we don't do is check if it is large enough to contain a > valid struct htc_frame_hdr. We should check for this and return, as the > buffer is invalid in this case. Fixes a KMSAN-found uninit-value bug > reported by syzbot at: > https://syzkaller.appspot.com/bug?id=7dccb7d9ad4251df1c49f370607a49e1f09644ee > > Reported-by: syzbot+e4534e8c1c382508312c@syzkaller.appspotmail.com > Signed-off-by: Phillip Potter > --- > drivers/net/wireless/ath/ath9k/htc_hst.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c > index 510e61e97dbc..9dbfff7a388e 100644 > --- a/drivers/net/wireless/ath/ath9k/htc_hst.c > +++ b/drivers/net/wireless/ath/ath9k/htc_hst.c > @@ -403,7 +403,7 @@ void ath9k_htc_rx_msg(struct htc_target *htc_handle, > struct htc_endpoint *endpoint; > __be16 *msg_id; > > - if (!htc_handle || !skb) > + if (!htc_handle || !skb || !pskb_may_pull(skb, sizeof(struct htc_frame_hdr))) > return; This leaks the skb.