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 5E523EEB562 for ; Fri, 8 Sep 2023 18:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231997AbjIHSbN (ORCPT ); Fri, 8 Sep 2023 14:31:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233933AbjIHSbG (ORCPT ); Fri, 8 Sep 2023 14:31:06 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E2A83C3D; Fri, 8 Sep 2023 11:21:30 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11008C116A6; Fri, 8 Sep 2023 18:21:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694197265; bh=k3moEPGR0BOFaRMofyY+Z9IPG8m7Wu+N491Qu/QXPIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VkBV9jwVr6WuQVQdZXsKAXBs8xPaVcdwgsNVtzncZJ7vxvGPXKjwmlPgCSNWix2DU wSqPMM9LhHTAdDofHxQWFzI3m0vcaj8OM8vxI+Aig7OeJD3Yz196Z4nelMwE88zd7T XElxp6+wDjhd8AloiUT80ePKxZr9w8+nUWnsGd6AJDSwH6FhoV4qQn0zhgT/UCpapm X9nrvwd1Nwz+nI3LBg4bBmg9XlpO5jfAjr+H3BhbmstsHx4oANbRIEVSCCfUxQU5+A j8DQV5Li4SThPSFGmu2u6qp0f3v2HmyyYswMSbGMDgsGXurwO34Wtcn9nYSsf0203L fONQ7Q3cr1paQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Johannes Berg , syzbot+b2645b5bf1512b81fa22@syzkaller.appspotmail.com, Jeff Johnson , Sasha Levin , kvalo@kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 08/10] wifi: mac80211_hwsim: drop short frames Date: Fri, 8 Sep 2023 14:20:42 -0400 Message-Id: <20230908182046.3460968-8-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230908182046.3460968-1-sashal@kernel.org> References: <20230908182046.3460968-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.4.256 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg [ Upstream commit fba360a047d5eeeb9d4b7c3a9b1c8308980ce9a6 ] While technically some control frames like ACK are shorter and end after Address 1, such frames shouldn't be forwarded through wmediumd or similar userspace, so require the full 3-address header to avoid accessing invalid memory if shorter frames are passed in. Reported-by: syzbot+b2645b5bf1512b81fa22@syzkaller.appspotmail.com Reviewed-by: Jeff Johnson Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- drivers/net/wireless/mac80211_hwsim.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index f80b1d57d6c38..a21739b2f44e6 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -3367,14 +3367,15 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2, frame_data_len = nla_len(info->attrs[HWSIM_ATTR_FRAME]); frame_data = (void *)nla_data(info->attrs[HWSIM_ATTR_FRAME]); + if (frame_data_len < sizeof(struct ieee80211_hdr_3addr) || + frame_data_len > IEEE80211_MAX_DATA_LEN) + goto err; + /* Allocate new skb here */ skb = alloc_skb(frame_data_len, GFP_KERNEL); if (skb == NULL) goto err; - if (frame_data_len > IEEE80211_MAX_DATA_LEN) - goto err; - /* Copy the data */ skb_put_data(skb, frame_data, frame_data_len); -- 2.40.1