Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2120892pxb; Mon, 12 Apr 2021 15:10:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWIDoOqHRtP5+vYOEtnOtXQk4ZyhOKCFrpAllyazO+43fOQvIjxAJccOS21HT8Xwm3hDYA X-Received: by 2002:a05:6402:510f:: with SMTP id m15mr31806214edd.328.1618265441775; Mon, 12 Apr 2021 15:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618265441; cv=none; d=google.com; s=arc-20160816; b=KhWHj1clC2Dcdk7daQXBpRZyPXdiYH/0gdh4zfXgILzOCgU7JpOazOYnjcd209JzUN OnUJTkCBqfwtFBhcVip+uGFlLpRZbFXToxseGio8B1Onn1gFfnxQgGmdYYeF4/8SjpRa zQg1BQDxUxC7xCfwskIATAV0LOfG/O1zOGFHNHMsBB7OLfOXJGVfZ5XJ8inbX6EJAMd/ +UoePzQSwo94Krisp/Po9rfvhX+1D0XJ79+cl9rReds5NkCXhZEn+Vph7ixnVzBDskuX M8dpwrNV48KOjoS1HxUl8C+Rw66Tx8mYstLszDSOjCfZdIcyRCrslGPCfsmruptEjonn fjFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NXT05vGqESrea6DLXHouIDRVcorO59/Sjk4E8wAJ+rQ=; b=fsA5LMyck3ZSWGVBdxs3X4Qh+EvQM+3t/uPMJb2eIfcP6zMfz2rJtVgnUwzNVURgO8 XpLfRPotimdHAXmiZ0JXVCdjBXtDqxM0hrivQ3F+xI0ZkfATlxY2lTarctoX7ohb6c4M 4R46jCG+76bnGgYOkPInkeQ6vfJo6R+DrU6DLOjmQMPIxl9hmHwMOTABcVNkuaZhX7aa w+ENnjCxCx9uOLbn8Mh7JVi9RQYDey4jxBryEP3954xRbwZe39+E+CjLzTP4LIcY4dTg HHqTKQnZEHQmyE/BnKg895/6xKifuZ+LMryBaArLXHQhGii56PvMc2g+PZmlmLX5Rhdj ByNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SpIkNOv+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k1si8338612ejc.515.2021.04.12.15.10.17; Mon, 12 Apr 2021 15:10:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=SpIkNOv+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242219AbhDLJ2D (ORCPT + 99 others); Mon, 12 Apr 2021 05:28:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:54616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239231AbhDLJEG (ORCPT ); Mon, 12 Apr 2021 05:04:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F11A161221; Mon, 12 Apr 2021 09:01:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618218098; bh=4wbeKZkoyAOU2fztr/DIcBWidLILZA3OAF2I2RO21SY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SpIkNOv+MujoVhm4HFFRSqfMZBu61bIt1qD8RHGfldKmFfLO21iq+BLbFD7O0n18X IHO7IKP2gKAnhxOkcw8Ko+eiTeTlaqpUZFkyYIXnS3BLH6jOAaPOG2mAlf3h+qovgK a0A1gE8a6Pn2f9Jvj3f/C620MEcm+mHwxjSSgNXs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Johannes Berg , syzbot+72b99dcf4607e8c770f3@syzkaller.appspotmail.com Subject: [PATCH 5.11 070/210] nl80211: fix beacon head validation Date: Mon, 12 Apr 2021 10:39:35 +0200 Message-Id: <20210412084018.341444114@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084016.009884719@linuxfoundation.org> References: <20210412084016.009884719@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg commit 9a6847ba1747858ccac53c5aba3e25c54fbdf846 upstream. If the beacon head attribute (NL80211_ATTR_BEACON_HEAD) is too short to even contain the frame control field, we access uninitialized data beyond the buffer. Fix this by checking the minimal required size first. We used to do this until S1G support was added, where the fixed data portion has a different size. Reported-and-tested-by: syzbot+72b99dcf4607e8c770f3@syzkaller.appspotmail.com Suggested-by: Eric Dumazet Fixes: 1d47f1198d58 ("nl80211: correctly validate S1G beacon head") Signed-off-by: Johannes Berg Link: https://lore.kernel.org/r/20210408154518.d9b06d39b4ee.Iff908997b2a4067e8d456b3cb96cab9771d252b8@changeid Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/nl80211.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -209,9 +209,13 @@ static int validate_beacon_head(const st unsigned int len = nla_len(attr); const struct element *elem; const struct ieee80211_mgmt *mgmt = (void *)data; - bool s1g_bcn = ieee80211_is_s1g_beacon(mgmt->frame_control); unsigned int fixedlen, hdrlen; + bool s1g_bcn; + if (len < offsetofend(typeof(*mgmt), frame_control)) + goto err; + + s1g_bcn = ieee80211_is_s1g_beacon(mgmt->frame_control); if (s1g_bcn) { fixedlen = offsetof(struct ieee80211_ext, u.s1g_beacon.variable);