From patchwork Thu Jun 24 09:38:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Tenart X-Patchwork-Id: 12341671 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 149C5C48BDF for ; Thu, 24 Jun 2021 09:38:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7CD7613F6 for ; Thu, 24 Jun 2021 09:38:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231985AbhFXJlA (ORCPT ); Thu, 24 Jun 2021 05:41:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:54700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbhFXJk5 (ORCPT ); Thu, 24 Jun 2021 05:40:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5EC58613F6; Thu, 24 Jun 2021 09:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624527519; bh=nroBsKWJJxUHBe+pmBgTlAGQCdIlIewQPm2Pf4A08kM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P0IvcPRrCKY1ctUT8YQxQA9LjVshQoXoFCmz5E080rRilk3yrDEVGKVeluUoY5wep lmeF3sUw9ib+ON8XDvd0GdSUzQvVNzWrJuzB9igGqMHfnZEke9iA/SzkTO5STiDk8y CXeNFzNptuC5DT9kv0a2avKd7vhpNmZ4axVhhjlFEhNlv58oUa97ou4piW1y1JIvSi HtnkYVhxK6AlVZgIgEvvyK3UeSc3x3ZGVr8HXMgbiw0czrhN6fwbjhEJn4ihVqB7Lz nALBSyN4Aung8t+6Hx+3eZec2UPsaEvqOZw/aJplib6CulCrsmCk+2CvFmoHvylcdC wpIFBQSaDPlUw== From: Antoine Tenart To: davem@davemloft.net, kuba@kernel.org, sd@queasysnail.net, andrew@lunn.ch, hkallweit1@gmail.com, irusskikh@marvell.com Cc: Antoine Tenart , netdev@vger.kernel.org, Lior Nahmanson Subject: [PATCH net 2/3] net: phy: mscc: fix macsec key length Date: Thu, 24 Jun 2021 11:38:29 +0200 Message-Id: <20210624093830.943139-3-atenart@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210624093830.943139-1-atenart@kernel.org> References: <20210624093830.943139-1-atenart@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The key length used to store the macsec key was set to MACSEC_KEYID_LEN (16), which is an issue as: - This was never meant to be the key length. - The key length can be > 16. Fix this by using MACSEC_MAX_KEY_LEN instead (the max length accepted in uAPI). Fixes: 28c5107aa904 ("net: phy: mscc: macsec support") Reported-by: Lior Nahmanson Signed-off-by: Antoine Tenart --- drivers/net/phy/mscc/mscc_macsec.c | 2 +- drivers/net/phy/mscc/mscc_macsec.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/mscc/mscc_macsec.c b/drivers/net/phy/mscc/mscc_macsec.c index 10be266e48e8..b7b2521c73fb 100644 --- a/drivers/net/phy/mscc/mscc_macsec.c +++ b/drivers/net/phy/mscc/mscc_macsec.c @@ -501,7 +501,7 @@ static u32 vsc8584_macsec_flow_context_id(struct macsec_flow *flow) } /* Derive the AES key to get a key for the hash autentication */ -static int vsc8584_macsec_derive_key(const u8 key[MACSEC_KEYID_LEN], +static int vsc8584_macsec_derive_key(const u8 key[MACSEC_MAX_KEY_LEN], u16 key_len, u8 hkey[16]) { const u8 input[AES_BLOCK_SIZE] = {0}; diff --git a/drivers/net/phy/mscc/mscc_macsec.h b/drivers/net/phy/mscc/mscc_macsec.h index 9c6d25e36de2..453304bae778 100644 --- a/drivers/net/phy/mscc/mscc_macsec.h +++ b/drivers/net/phy/mscc/mscc_macsec.h @@ -81,7 +81,7 @@ struct macsec_flow { /* Highest takes precedence [0..15] */ u8 priority; - u8 key[MACSEC_KEYID_LEN]; + u8 key[MACSEC_MAX_KEY_LEN]; union { struct macsec_rx_sa *rx_sa;