Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1943009imn; Mon, 1 Aug 2022 05:54:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sF7k01JgTwV2j3xOzAWTRAPkxXHxhg9QFCayWqpWqnT01TSfEpn4Bl4d3nNxouNRuqxKpt X-Received: by 2002:a05:6402:4028:b0:43a:8d67:faeb with SMTP id d40-20020a056402402800b0043a8d67faebmr15715270eda.90.1659358448241; Mon, 01 Aug 2022 05:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659358448; cv=none; d=google.com; s=arc-20160816; b=PX8AQq5T1MJT403U6ptm8R3yHK0CtiHOasvbDOtI+4BDAhZid16tmbkdlLsKthtK8L 0igaRZS3sdiSR7CD6LWAvNf8jIX4q96iCSW/3ycz8DenM/oqCQtNU9SvOxlpBZ4n47Dh aeF4DpEcRMFLc8A4+15KywvFAXt0eC9oP/PbFBJowNuRajWu7yUOUzCX+GQPWCgNAyzF 7yV4bt+GUe3oeXEWLG0qi09DznVRBRphFV65nH0T56k8+xtgif2g5O+zffzRDQrRY6ay x6xRAAP9ItBKoy6n84Zk6BrCIc1ZJE/ZsWr1YBHLS8j+MQCNq12iwmxpVIzNHYlbh3QW I5Kg== 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=knWcYU5XGUmg2fzpG2P8xNDCgKzS7j2NF2dOmLIIBHA=; b=egOVVcYS/ky1zRtvWUB7sSzcsLZj90V+9yqzcaYZVy85OioazHZjWWRbB1QPO9ojDI OUd/T7jT0B+dqW4q6YaQh3D3z/PWV6AzMQvRNlnUMG1T3b4FpNAiHfvmUHLkwirOXG6W jkeXuUXKCNQ9TEun19wKHzI2iwmgqKn7VFWuh1449t8EoTtz9IJIAfgz4MbSv5pJ20QF 4WCQxLS6Se/X37DF8kS+Rtcjf6R7ZSfY5mNgbf2vXSwJ9C1FvS7v6ni9P7D3+L8u/ScI Bni+BEa+qec4RVp3E2cIwB8vCQwOsUSt6u/s6VrNHnPgLOuoN9APeYCg+6+CCDzH/9rc c70w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yecUOsqL; 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 hg5-20020a1709072cc500b0072af3bdf59esi11287864ejc.3.2022.08.01.05.53.43; Mon, 01 Aug 2022 05:54:08 -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=yecUOsqL; 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 S233251AbiHAMPU (ORCPT + 99 others); Mon, 1 Aug 2022 08:15:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234032AbiHAMOp (ORCPT ); Mon, 1 Aug 2022 08:14:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8529F78222; Mon, 1 Aug 2022 04:58:01 -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 127F6601CD; Mon, 1 Aug 2022 11:58:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21691C433C1; Mon, 1 Aug 2022 11:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1659355080; bh=CLVAxviFNkM+6MZHDWRFc5Wxzx2ONWeNJkWfDn1Ffvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yecUOsqLXBZxWWJOCfeGryzO5wTYA4e4llFvJTrtwOxtP+2ABkW9072YjdjSKjTBe hStt3dYXiG4dHBIJk+gqruiBqfqzFvcJAFCVQ3ZcnwFyqk99mMjXolMsrWlCIUWsPz chAXJGN/BfvppCY7fIN4vYEOisBuDSp6QRXw6gCY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sabrina Dubroca , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 55/88] macsec: always read MACSEC_SA_ATTR_PN as a u64 Date: Mon, 1 Aug 2022 13:47:09 +0200 Message-Id: <20220801114140.554941467@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220801114138.041018499@linuxfoundation.org> References: <20220801114138.041018499@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 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: Sabrina Dubroca [ Upstream commit c630d1fe6219769049c87d1a6a0e9a6de55328a1 ] Currently, MACSEC_SA_ATTR_PN is handled inconsistently, sometimes as a u32, sometimes forced into a u64 without checking the actual length of the attribute. Instead, we can use nla_get_u64 everywhere, which will read up to 64 bits into a u64, capped by the actual length of the attribute coming from userspace. This fixes several issues: - the check in validate_add_rxsa doesn't work with 32-bit attributes - the checks in validate_add_txsa and validate_upd_sa incorrectly reject X << 32 (with X != 0) Fixes: 48ef50fa866a ("macsec: Netlink support of XPN cipher suites (IEEE 802.1AEbw)") Signed-off-by: Sabrina Dubroca Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/macsec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index b3834e353c22..95578f04f212 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -1698,7 +1698,7 @@ static bool validate_add_rxsa(struct nlattr **attrs) return false; if (attrs[MACSEC_SA_ATTR_PN] && - *(u64 *)nla_data(attrs[MACSEC_SA_ATTR_PN]) == 0) + nla_get_u64(attrs[MACSEC_SA_ATTR_PN]) == 0) return false; if (attrs[MACSEC_SA_ATTR_ACTIVE]) { @@ -1941,7 +1941,7 @@ static bool validate_add_txsa(struct nlattr **attrs) if (nla_get_u8(attrs[MACSEC_SA_ATTR_AN]) >= MACSEC_NUM_AN) return false; - if (nla_get_u32(attrs[MACSEC_SA_ATTR_PN]) == 0) + if (nla_get_u64(attrs[MACSEC_SA_ATTR_PN]) == 0) return false; if (attrs[MACSEC_SA_ATTR_ACTIVE]) { @@ -2295,7 +2295,7 @@ static bool validate_upd_sa(struct nlattr **attrs) if (nla_get_u8(attrs[MACSEC_SA_ATTR_AN]) >= MACSEC_NUM_AN) return false; - if (attrs[MACSEC_SA_ATTR_PN] && nla_get_u32(attrs[MACSEC_SA_ATTR_PN]) == 0) + if (attrs[MACSEC_SA_ATTR_PN] && nla_get_u64(attrs[MACSEC_SA_ATTR_PN]) == 0) return false; if (attrs[MACSEC_SA_ATTR_ACTIVE]) { -- 2.35.1