Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp649013pxj; Thu, 10 Jun 2021 09:21:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGh5HQ8JJqDqF5ZqYzoc3IfVk2bm9lMzkD79BfXyFV5F/t3LYo3RgWMb6SHa1P6Hb8z7gw X-Received: by 2002:a17:906:cc14:: with SMTP id ml20mr366819ejb.515.1623342093761; Thu, 10 Jun 2021 09:21:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1623342093; cv=pass; d=google.com; s=arc-20160816; b=h5Ki5vN3dYf5CAJG8ak70GnvBLH3hrpRIDxTkF676jsgPPxWwSD2uhHS8dJzF5llcQ E7liHtaTS+kuBDDYr4gQsgzxXqeUROKvj8j3X5XWn8/nIqIxdA3+7zFkcPEZOIiPRyyr mA53zWKL1SiuvkbFVJLCB+3DycYNfYnjKXIeSCxMFKZI4USUjnoApEOMTHXE1qdaintR rHxx95AfXtKM7jeGVPhSNhRvTCpnHY9KLV04Nvc09BXGSssNnCH/fYXRei3JeA2mbMgX fQ+uDEqozdvKLwwttagHjYSjJ+ULX0B1GkuI/6clVnbl2OVOj9oyEZArJ1rOGQgF6uQ5 XHmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=HAKm0vB87VfcW2UTN+pnBdBfKxvZ/KF9QbxznGuDeHk=; b=jBitm6ldPrykSoJlPW9GpWF1iHk8UHcoybL+LmwmSIW29i+VhsgRwM1GYUnlAS3IYT PAht7UXD1jzASD5qv1bdtEoZDAYhYWGqPAXTOKL8EJlG4se9lwKYJrM5h+5JOp49YDy4 Ap+85dW7gRUv1CI8IXds5whs4plGa5YYeFDOU+dm1SdDnwpkPWTAec17ZfmfiH1tpLXl NAyqUzzlSyg15r7PdZLppXqpbt55N+nD0EuXEmRfk14J3qTVK+B/Gi+5DIh25xjA3MeF 5wdmplJHjYcQmS47Jeb6mH9KJNLyCU1k/GAosAxOWLbhhuAkzEeJgZ5OQOCY9urx+P7/ 22qQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@anirudhrb.com header.s=zoho header.b=BA8qi6XY; arc=pass (i=1 spf=pass spfdomain=anirudhrb.com dkim=pass dkdomain=anirudhrb.com dmarc=pass fromdomain=anirudhrb.com>); 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 ce2si2769467ejc.316.2021.06.10.09.21.02; Thu, 10 Jun 2021 09:21:33 -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=@anirudhrb.com header.s=zoho header.b=BA8qi6XY; arc=pass (i=1 spf=pass spfdomain=anirudhrb.com dkim=pass dkdomain=anirudhrb.com dmarc=pass fromdomain=anirudhrb.com>); 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 S230289AbhFJQVl (ORCPT + 99 others); Thu, 10 Jun 2021 12:21:41 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21380 "EHLO sender4-of-o53.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbhFJQVl (ORCPT ); Thu, 10 Jun 2021 12:21:41 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1623341975; cv=none; d=zohomail.com; s=zohoarc; b=coZG9heMNMaVtmLhvzg39WQj9ttAHjAVR4Xin5Tl++EWjGNVjHgc6AeSB+Vk1smMrxq5KpkFXzOKp/Em7YDDMc7mglty70BFURFtxlQWlsY76wyMP4j8MIrciVkVy1rLqIKLkYN6XoE+Uy4x149sALB9uRbG6WeWyKlkGoX7PGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623341975; h=Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=HAKm0vB87VfcW2UTN+pnBdBfKxvZ/KF9QbxznGuDeHk=; b=YJNMlInwHU9N8ys4lH9xuXLkGPlV7lqA1FhRB9HDJBeHmR0q5UAa3qNV2UFdpX6iRTxkIjBK8L03kVnbvAVWFmSpUATF6aBnkmZRnzAXkpYa8rHD97MT6ukk/A2cwsdA1R7LV1xqatg+e3xEju/BvEnGC3EfsreBzO20gs5PC5k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=anirudhrb.com; spf=pass smtp.mailfrom=mail@anirudhrb.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1623341975; s=zoho; d=anirudhrb.com; i=mail@anirudhrb.com; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Transfer-Encoding; bh=HAKm0vB87VfcW2UTN+pnBdBfKxvZ/KF9QbxznGuDeHk=; b=BA8qi6XYZGlPo9t9larjyIpSYdNf/1i1q1n064Y/76Q8WS1IPvtnMV7JBTz+EN4v REcxm2tTb2BXvkiP5tjgYm7OLxbD25WFMjFMhXjhdPzAkmaUJDiVVT7zJM9vrB9LeP6 Da7A1TLPNKuLHyOjwsiIHR1WweIArmmdFx8Eys3k= Received: from localhost.localdomain (106.51.105.43 [106.51.105.43]) by mx.zohomail.com with SMTPS id 1623341973610765.8442819280449; Thu, 10 Jun 2021 09:19:33 -0700 (PDT) From: Anirudh Rayabharam To: Johannes Berg , Kalle Valo , "David S. Miller" , Jakub Kicinski Cc: gregkh@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, Anirudh Rayabharam , syzbot+b2645b5bf1512b81fa22@syzkaller.appspotmail.com, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mac80211_hwsim: correctly handle zero length frames Date: Thu, 10 Jun 2021 21:49:16 +0530 Message-Id: <20210610161916.9307-1-mail@anirudhrb.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-ZohoMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org syzbot, using KMSAN, has reported an uninit-value access in hwsim_cloned_frame_received_nl(). This is happening because frame_data_len is 0. The code doesn't detect this case and blindly tries to read the frame's header. Fix this by bailing out in case frame_data_len is 0. Reported-by: syzbot+b2645b5bf1512b81fa22@syzkaller.appspotmail.com Tested-by: syzbot+b2645b5bf1512b81fa22@syzkaller.appspotmail.com Signed-off-by: Anirudh Rayabharam --- drivers/net/wireless/mac80211_hwsim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 51ce767eaf88..ccfe40313109 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -3649,7 +3649,7 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2, if (skb == NULL) goto err; - if (frame_data_len > IEEE80211_MAX_DATA_LEN) + if (frame_data_len == 0 || frame_data_len > IEEE80211_MAX_DATA_LEN) goto err; /* Copy the data */ -- 2.26.2