From patchwork Tue Aug 15 16:16:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 714017 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 F23E8C0015E for ; Tue, 15 Aug 2023 16:17:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238491AbjHOQQj (ORCPT ); Tue, 15 Aug 2023 12:16:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238496AbjHOQQN (ORCPT ); Tue, 15 Aug 2023 12:16:13 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:242:246e::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6E4C110 for ; Tue, 15 Aug 2023 09:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-To:Resent-Cc: Resent-Message-ID:In-Reply-To:References; bh=MawKX8R/FbJdHQC1xDrhBMUkYV/2zIZgjTXKTJvufVg=; t=1692116168; x=1693325768; b=RdVR8yd7wzCQFRAApV2OFNS25EuF6AlU0CL5nmz+qUXHWeDcJ4hGX0vnwegh2a83XjXfaTkTT8t ONQsLrdP6HSM5mi8hVS6JNx+epz/86CKGv8vC+Dq0jR7TlOv9rWTDtqwuKtQrlXQRBtk0C/7+I4Si 6R8BlNAfMH077aNwCf9ariYeRO3V0eQKk5d3a26zvxcYc5u1DmrszO2JTH0g1oPXWlTFyfQ4FRuAm JfLwfK2UjrQbgQtYsohgkGusJ1Yb1Zj9TV67d1Xsm8XUvUVTXOTPNLNOfVwSvbWsfWdL0pufiH23/ MCveCT1T1Iir8iuFLt6Sk/pufOdlfbZ9fJpg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1qVwiE-0091r0-0Z; Tue, 15 Aug 2023 18:16:06 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , syzbot+b2645b5bf1512b81fa22@syzkaller.appspotmail.com Subject: [PATCH] wifi: mac80211_hwsim: drop short frames Date: Tue, 15 Aug 2023 18:16:04 +0200 Message-ID: <20230815181603.f576bd983875.I1efbeef082c3f7094037882f213202d760848eb7@changeid> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg Frames that don't even have addr1 are clearly not valid, drop those early in the netlink/wmediumd path here. Reported-by: syzbot+b2645b5bf1512b81fa22@syzkaller.appspotmail.com Signed-off-by: Johannes Berg --- drivers/net/wireless/virtual/mac80211_hwsim.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c index f446fd0e8cd0..8f1e4420ed1e 100644 --- a/drivers/net/wireless/virtual/mac80211_hwsim.c +++ b/drivers/net/wireless/virtual/mac80211_hwsim.c @@ -5626,14 +5626,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 < offsetofend(typeof(*hdr), addr1) || + 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);