Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2969267pxb; Mon, 18 Apr 2022 12:14:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw53Fk+J/XWRMFR9scUlZVJ+KUx16kDT+IYVYlQYDcdCzi40l8AgrQXM3zsXX7H6i3zcGmv X-Received: by 2002:a17:902:e1c5:b0:158:e060:4f6c with SMTP id t5-20020a170902e1c500b00158e0604f6cmr12164387pla.163.1650309293822; Mon, 18 Apr 2022 12:14:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650309293; cv=none; d=google.com; s=arc-20160816; b=g/ILOqi/iGquymOgv070nl0FKEfYU2ubc8xDPb2tf9psG4TtFrQAOSaCeC0FQb0ydy o2hiCJsT3cqDCCyw5oLo/mEG7JNnDHsQMuenM3M1JiZ7hHZBNmA/AftaU2Af01sSsd7W CsYwhxmgggymYqlDZIyKHbdzUEokLJGBQLrHdelrH5b0KFHRDLTGdBrgSrvrz/XnKHdO g7G10sP2c+Dq+ScsZ/Bze6CqNvD2URI0u36R9Oaoth+xPNTdAaL4ggZ5zGN314ct3NWR I3WNdY8zGI2kqL87mwdQrpCvWriCUhLfmLfnTeq2dg4sv0gQr4nYCjC65jgabPTawLaz Exwg== 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=LM+cnp9Vb3c0vfWhlvwqRGWpNwtPzEQL11zi8Sbnr18=; b=vtrGFX1s+EY/LVY7UWkqREmZlY0Rs7Y1xYjQClmA2s0Ido9Lc/lDGA83DhWzV9uhK7 nDo0z4eFDdPUL6at2TDWxeiDUQD4DLKCykHWuou0LR+450EQoY/esS1mvh5YwOH/QXeL dm4fi9fbyL2PtEzi5HPv0Xww+eYA1ucv/o6v1hO04FDxbcb1Fyeiiv29XtcUjfjKRIx/ V0OjtxooAUmedSi2NNiLV/ZrAFbalhwi5Sf3wEOjYxVxtvDZdUYJIF9UeUcG98Un9EtF q9IsZMXYEqL0kQZ0hU5s+SxsprYRHtuAEpWV6M4Cv9EOiyHrRjGbaijjhrnldGPDIGkP 1fsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VQ0mDwiw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v19-20020a17090a521300b001ca64c6f839si136497pjh.15.2022.04.18.12.14.37; Mon, 18 Apr 2022 12:14:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VQ0mDwiw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S239963AbiDRMi2 (ORCPT + 99 others); Mon, 18 Apr 2022 08:38:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239576AbiDRMdP (ORCPT ); Mon, 18 Apr 2022 08:33:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10755CC1; Mon, 18 Apr 2022 05:24:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7BA9C60B40; Mon, 18 Apr 2022 12:24:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DDEAC385A7; Mon, 18 Apr 2022 12:24:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284691; bh=uaW8DEnT4sb0/ybCYpcyrSkLQYz8E36Brq7Wd8H8Qlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VQ0mDwiwFejfZ1H25RIcnW6U47aei4FzWq/lX7ml8N6EMrWD0nYDsyRVaGFUai/ms +LILsdku7m7JizyxGt/jD9IbWERcvovup3BJYJgCCBwXVYsDyfm/g5Jup0qm/kR+ul h6QFsXjAkTp8J1QrS2gUC+pyzbZkGY9dvz054Kjw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lee Jones , Johannes Berg Subject: [PATCH 5.17 197/219] nl80211: correctly check NL80211_ATTR_REG_ALPHA2 size Date: Mon, 18 Apr 2022 14:12:46 +0200 Message-Id: <20220418121212.387687704@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg commit 6624bb34b4eb19f715db9908cca00122748765d7 upstream. We need this to be at least two bytes, so we can access alpha2[0] and alpha2[1]. It may be three in case some userspace used NUL-termination since it was NLA_STRING (and we also push it out with NUL-termination). Cc: stable@vger.kernel.org Reported-by: Lee Jones Link: https://lore.kernel.org/r/20220411114201.fd4a31f06541.Ie7ff4be2cf348d8cc28ed0d626fc54becf7ea799@changeid Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/nl80211.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -519,7 +519,8 @@ static const struct nla_policy nl80211_p .len = IEEE80211_MAX_MESH_ID_LEN }, [NL80211_ATTR_MPATH_NEXT_HOP] = NLA_POLICY_ETH_ADDR_COMPAT, - [NL80211_ATTR_REG_ALPHA2] = { .type = NLA_STRING, .len = 2 }, + /* allow 3 for NUL-termination, we used to declare this NLA_STRING */ + [NL80211_ATTR_REG_ALPHA2] = NLA_POLICY_RANGE(NLA_BINARY, 2, 3), [NL80211_ATTR_REG_RULES] = { .type = NLA_NESTED }, [NL80211_ATTR_BSS_CTS_PROT] = { .type = NLA_U8 },