Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1746334pxj; Sun, 30 May 2021 02:02:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTgb0IR1Xw3eAhmubC4e4s39F7ajuGXkyQPQcmCp14yXRbBp+YN3XmcRM5yrBM+nYpuUOb X-Received: by 2002:a05:6602:14d3:: with SMTP id b19mr13224506iow.154.1622365372954; Sun, 30 May 2021 02:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622365372; cv=none; d=google.com; s=arc-20160816; b=HgByRBNQjObVRVlxm4x9bKU/PygmcFrMYAx14Z3BsHPvhWP9WSMXPOTDb39s7vDEpk 4sMqR15StrAXlmR1Aevu7UoY5+WO3N5I+cFtf/ENsWaXdbtPLoOe349XuDWWrg7P9iUj bfsGAUN3RxGWWf83KVOdoCrsTMpHEOU2eJVYQIB04Ptbd+GR2oElHMoxj63JUyNnQt3G ti/lvXOPiJFRbJcy/DlfMe8KxtgPC+1GibmPvWiLAWFGGy+ippcVX7dBBtKaU8YAtAJ8 uGqEiogxyHpz8PNUHQQkABeIL7b35gJCFLML4OXZK92Xz0ze93pIK6coY3VZJTqubDtP qNrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dmarc-filter:sender :dkim-signature; bh=m6gbfF2M8WEGMtZm9Ch5HQfluH/QE2I8j/C41+TlWbM=; b=QHMyDbw/b1j2RIbUCZh6Bd3JTF4VYsmeOXOib02NIqHoVP0+4BkpWPpi3SH17ILMW0 TyIo9/UDvqKd/3mD3miWygBzCiWAp2EF18Ym1g7+sF8strYi+yyvQBWPdRwTyOnThL8t mtnwumiMur9k6ua4C5FvnW9ggffKDD2XhRkbdo4X6MWt07w4aWbB88ioKDL0P9/6FjRX 8h9a6kefPfSVeuE9iWFQtB5CXAV6ocK/QJ+HtjAfyRHeN+LIMIg//X+IZmP4xq4pbGcf LYa0GtjnTDACUae6juhQL7HKwlLy5sNioFaOXtT3y8YgQ6GDjSAYdmg2K7r1FeGUyR/v Px8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=ZIythUaw; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y15si11683107jat.39.2021.05.30.02.02.26; Sun, 30 May 2021 02:02:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=ZIythUaw; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229765AbhE3JCp (ORCPT + 99 others); Sun, 30 May 2021 05:02:45 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:24990 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbhE3JCo (ORCPT ); Sun, 30 May 2021 05:02:44 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1622365266; h=Content-Type: MIME-Version: Message-ID: In-Reply-To: Date: References: Subject: Cc: To: From: Sender; bh=m6gbfF2M8WEGMtZm9Ch5HQfluH/QE2I8j/C41+TlWbM=; b=ZIythUawtpBDSbsYQx+SIFGdGymdXK+1WI6b9N/o4N4h/LSIhfamIYulW/t/eUQf1H94lt6w OmWo8G9oxIpc8j0C8uD6c5a2GEYTPg4l5D0o85r6j5BaznQn96xolaOqqMAfcTcuuH3ZU5Vv MSDEIAQQ/Z8dTVTvV5m5bMw+pGs= X-Mailgun-Sending-Ip: 198.61.254.9 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-east-1.postgun.com with SMTP id 60b3544b51f29e6bae4b4ea3 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sun, 30 May 2021 09:00:59 GMT Sender: kvalo=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 600C2C433F1; Sun, 30 May 2021 09:00:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from tykki (88-114-240-156.elisa-laajakaista.fi [88.114.240.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: kvalo) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7DB0FC433D3; Sun, 30 May 2021 09:00:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7DB0FC433D3 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: Phillip Potter Cc: 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, fw@strlen.de Subject: Re: [PATCH v2] ath9k: ath9k_htc_rx_msg: return when sk_buff is too small References: <20210502212611.1818-1-phil@philpotter.co.uk> Date: Sun, 30 May 2021 12:00:53 +0300 In-Reply-To: <20210502212611.1818-1-phil@philpotter.co.uk> (Phillip Potter's message of "Sun, 2 May 2021 22:26:11 +0100") Message-ID: <87fsy4ppdm.fsf@codeaurora.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Phillip Potter writes: > 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 if not, > 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 > --- > > V2: > * Free skb properly when this problem is detected, as pointed out by > Florian Westphal. > > --- > drivers/net/wireless/ath/ath9k/htc_hst.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c > index 510e61e97dbc..1fe89b068ac4 100644 > --- a/drivers/net/wireless/ath/ath9k/htc_hst.c > +++ b/drivers/net/wireless/ath/ath9k/htc_hst.c > @@ -406,6 +406,11 @@ void ath9k_htc_rx_msg(struct htc_target *htc_handle, > if (!htc_handle || !skb) > return; > > + if (!pskb_may_pull(skb, sizeof(struct htc_frame_hdr))) { > + kfree_skb(skb); > + return; > + } This does not look complete to me, I think the function is missing proper length checks. For example, with ENDPOINT0 it reads two byte msg_id after the htc header and it's not verified that skb really has that. I did not check if ep_callbacks.rx handlers have proper length handling, I recommend verifying that also while fixing this. Also I want to point out that the skb is freed differently based on endpoint, I did not check why and don't know if it causes: if (epid < 0 || epid >= ENDPOINT_MAX) { if (pipe_id != USB_REG_IN_PIPE) dev_kfree_skb_any(skb); else kfree_skb(skb); return; } -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches