Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2095178pxb; Mon, 12 Apr 2021 14:20:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygwYdLCFYdn60GfMEYfLmWpDp7JHI322jGmj8QXsf6l2BuqRop99j03ceYvUpoxJoHCB/3 X-Received: by 2002:a17:907:c08:: with SMTP id ga8mr28673559ejc.376.1618262441505; Mon, 12 Apr 2021 14:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618262441; cv=none; d=google.com; s=arc-20160816; b=jhxB0zClP7zTiTb6zJa64TcEcVfdHSJBlK7kaXc2y90TPB8qTjp4MwBXxaI9/s2nUU qXRWhN/qClIog5x5AsW8/V27J0Hmd2gffAqa67aAo5VJ4SrlOnzIsTrYtc5JIBLOD2xw HJ7UkKZQ55x5srIZ3mcdfvtg20x6fWS/7HUSROouAOE7Tu16M94m8NtgkBT80M/KEOxj rMAeML4EVuFtJXyhUNh+z01DIkiIEi+j7Fz45KIsH9lQqHuYPh4K65jXJEHe2JUd3u/R Rq3pi2Rv0OqJMuFBX055HxT5iNdcCyVY8qHwPSAPiUarV+4DySRMzWBXEpMJJYCmn3Pd y0fw== 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=PIqUBy1ZKfN71OvknOD61HmmTwxUWHxfPi4f3Ly4cuoG/cxQviE3lxz3/oSUk30GHj FKxlNz9q5SZHiSXsLJik12V7Xb1kbuo9vyyM2kwF/1lTZsKtpLQEX2IIETyMdHf3mADG dWSkBCcPmvfdrg5QEMkl6bRphDJxIif1sQoWz8h3lzc52R4SEaM8AIvHNkdLI9ozmGV6 Oy0bMlbaFfmgSBn2pP4AY63txp7987anlAVF1ebWpvYZssz8WJzbiSKYxwjjkIGkULdt tDUwUHEqz7dJxZKrc9lnS1yPLLn4j6i1h1b/vA1NwJYPN4hT1G9iegW0wwrubNeDNxKo XI2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bTmfxq7g; 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 s7si7996082edd.589.2021.04.12.14.20.18; Mon, 12 Apr 2021 14:20: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=bTmfxq7g; 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 S237777AbhDLJIm (ORCPT + 99 others); Mon, 12 Apr 2021 05:08:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:47052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238987AbhDLIzR (ORCPT ); Mon, 12 Apr 2021 04:55:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8804761263; Mon, 12 Apr 2021 08:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217660; bh=4wbeKZkoyAOU2fztr/DIcBWidLILZA3OAF2I2RO21SY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bTmfxq7gifUutQUa+jY1MoVgwlPKbYhY82mtNBesVTTRl05g5OaNlTTltlnKXEnUy DLJB1t0I+JsHjI0linET62xx1gKQ84KReEOD5yppMAeQOJLlVagjNZSgS8EtjC/Ouu R9sO+MD3TvMrynhijYyFDBdR18k6NZZN3K5pRb4g= 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.10 063/188] nl80211: fix beacon head validation Date: Mon, 12 Apr 2021 10:39:37 +0200 Message-Id: <20210412084015.753371404@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084013.643370347@linuxfoundation.org> References: <20210412084013.643370347@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);