Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6420563rwd; Mon, 19 Jun 2023 07:06:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5U4RqAFox6qU4lnRjAxb1UzNaLvfLW7sbp6DtfkA46Iak7atIyjvbfuAOxgT3tqh6jaKhI X-Received: by 2002:a05:6e02:102:b0:340:8cb1:aaa8 with SMTP id t2-20020a056e02010200b003408cb1aaa8mr8771525ilm.21.1687183607706; Mon, 19 Jun 2023 07:06:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687183607; cv=pass; d=google.com; s=arc-20160816; b=S3T+Dr2MiM66xWqmcA5Ng5pXYS53Ad8kVTlY7Hfsy2SblhxHZxA5aoNMMqdGWpbLuS ZOSqpXCRO0hOKfs+dVxXJ39Jok3ZmAtNRHg4K5hsf2jKJaV8c5MuNzRDnChCBPh8/lLA M37QM9aB0Rf7/AdJWLZMfo4hZ2A4GJJSr9ByjnnVhrz/Q4bENWgby4W/YqT94QmMxORl G4udnDG6idW93lFbtOLx47Tk05+AKf3Shj4yP2L3wgRUK3EuKDYbaxYb2y8QxsHEr6Zl 2R38mzBIqKAVEH31pw+BfAW2tVV7tVxslbKNo5v+ttEs8hgPu8SP1/8b+aPjflcbcepn b2Yw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6XbEPFKGfWrarrs9tUnQw/EEtvwGjUmAlv+f3Fu2R8w=; b=uK1WkbT6HFTI06G8Esom68g3XudKG0yn+0X3A8UVM2y5K10T7YYN5w8yKAiiK/LHb0 SrDxdPEQ7qnkOysKFsTrc2upr10+bYCA/uIoIrWD/2xDIfGlMMUGyfPu8Hq7EYxj6+pM CENw1qhCixcUqiCkqUc6p/zrjeWpk76Arkb+cvyY+wT/woY/S50mMzyvVIO51gOiuLcY 18M52pFZzRgepypPYncbAb4FNQLah/2HYjdqfOBDP4oGbD0UYPTec1p2AlWF9x1P6QLv X4dunagGQD0iomUrvrEDuVDpGnW1gyo66SZ6cU8sqZXREcj4rzMqmjZ/VMSHGg0Ej68M N5mg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@corigine.onmicrosoft.com header.s=selector2-corigine-onmicrosoft-com header.b=SMJPKQae; arc=pass (i=1 spf=pass spfdomain=corigine.com dkim=pass dkdomain=corigine.com dmarc=pass fromdomain=corigine.com); 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=fail (p=NONE sp=NONE dis=NONE) header.from=corigine.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v16-20020a63d550000000b00543a6cf2b5csi20144645pgi.662.2023.06.19.07.06.24; Mon, 19 Jun 2023 07:06:47 -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=@corigine.onmicrosoft.com header.s=selector2-corigine-onmicrosoft-com header.b=SMJPKQae; arc=pass (i=1 spf=pass spfdomain=corigine.com dkim=pass dkdomain=corigine.com dmarc=pass fromdomain=corigine.com); 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=fail (p=NONE sp=NONE dis=NONE) header.from=corigine.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232059AbjFSNrv (ORCPT + 99 others); Mon, 19 Jun 2023 09:47:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbjFSNrt (ORCPT ); Mon, 19 Jun 2023 09:47:49 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2107.outbound.protection.outlook.com [40.107.93.107]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFE5DE54; Mon, 19 Jun 2023 06:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g9cUGixCB1C9sbp2mLL6fylgc4Mhpag9XG+Q8BYy+QqZI03MbsJCE4PXC6teGGgmKB+1srdPn7qeKy0ZJ4lamIx1NnOcl+v/6alRdyQcebVr2bMoLe68xrX3Gp+SXZiCNrlz0kppxAhdVGLqQ2aA/7K55kifpzRnEFf2J7VKgGS12eMRBVv9o39Olqnk6yrSVnzzSVYF0KA6EHVgo3EwegsZIpSvJChhwadkT6o00jLWtKtIYebHck8iz+lGR4oCyOPQSQwcldqmsDFVkmx0hpryI2broGdINs4T218WfTzPPQK8al1lnYaF+ril8kUIwi1hvJHvkkiwBX0Dl3r+Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6XbEPFKGfWrarrs9tUnQw/EEtvwGjUmAlv+f3Fu2R8w=; b=J3Dj/Gwt8PrF962BsbtEysvmMDJx+Ae4GyCoiDbV+hsmOKhyQ1qlKF65tazfZFjLg4+rZ2sVqCrYgjHO0ACy1vvzkbEEZMxtt5ohs/4HYCAMcod6fgysCNI466sKCEYwoSw1azwk486+txMfpMSSPcFewigQDhVaQjXIzFXfyUx7dY1/jILAU1mLHLcN0Ca9/tibFaMYxbZaqRn+gqm7aAIPURsD1PxO/IQ3eutQSx6izceabWJveALZiSwfmBFgRakHc67tB7rFc3xfm7lScWSbzxhTstS2mc7cE2HnhL1N2G40O6L6H9OEqUfPEffLedC4Cc+GBb9GsZEczXGOoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6XbEPFKGfWrarrs9tUnQw/EEtvwGjUmAlv+f3Fu2R8w=; b=SMJPKQaeFICEbR0oAjyffYKU9ZW9TxMZQ2SfJiio7N/8LaNcKcK0Y24nmIgxTWFTUKp4N3rWmGBPzLYb5gr+COwv4Rbdc5HuV2yq0AZm/F3tujCFcHfXJ1WZqmGJ5hUiCTa05xgWgGvRhWSgziReAnEpysRS8hzWycRTr7yYENc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by PH7PR13MB6059.namprd13.prod.outlook.com (2603:10b6:510:2b4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Mon, 19 Jun 2023 13:47:44 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::eb8f:e482:76e0:fe6e]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::eb8f:e482:76e0:fe6e%5]) with mapi id 15.20.6500.036; Mon, 19 Jun 2023 13:47:44 +0000 Date: Mon, 19 Jun 2023 15:47:37 +0200 From: Simon Horman To: carlos.fernandez@technica-engineering.de Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] net: macsec SCI assignment for ES = 0 Message-ID: References: <20230616092404.12644-1-carlos.fernandez@technica-engineering.de> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230616092404.12644-1-carlos.fernandez@technica-engineering.de> X-ClientProxiedBy: AS4P189CA0006.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5d7::10) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB4842:EE_|PH7PR13MB6059:EE_ X-MS-Office365-Filtering-Correlation-Id: 580fc22e-b830-4733-4cf9-08db70cbc25f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cOTZBmF8jC/tncnSBisRdrEYJMFvF3ii3tzIUIxThYWw8eG29vBSqS0osT3XTKad3+9PdWa8Zps0jIKF5pKdxFnwwQ24WfPrFKxxyDUbHuQhH1iXIZ+pHHiZV3KmPf2mav4IdldSbtb046oPDPFOeohXkSM3d6xXTn2nRVVl+/QiFfYPTgLUhYRXwGt4yXR5xwZ2d2t/mobbWTUJQxv8mi2/o+NiFBVhsgr0UOBsk0jQH+tG1FhOzgH+IsR7EvwmSHwqTq960lSQTOlOlW97cqWj0hX0O9O8PT8i8JDpp+CaGoiOqm4Qj+C7T89gtIdEi2OdFdNjMmBkFmKDk39uk4rghcDI2iyZzLooUIBVFK+dJeSkOqX+xRs11GMxsrTK/MJJuKh293iroquf4S4elFI7guSvWujQyHgGVthSjG15DlvL+04j+cZSLNkKdciir547zsXxl+8TYHtoX+0cJsUunGMJosxKpI3h/X1iJ5MtWiYF80smL218H4e/MTF4DynEAARHG75BPhLOyrtnJ9aeIl7yhevg4xvgc7KW3z/I1rj5MZtXDIy5Tnf5rpmjItwiJAQ83KSwu/+Rx2pJ5q/sLGmzrDc65A0AhsHA+oU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(346002)(39830400003)(136003)(366004)(396003)(451199021)(478600001)(2906002)(6666004)(6486002)(38100700002)(316002)(83380400001)(5660300002)(41300700001)(66946007)(44832011)(66556008)(66476007)(6916009)(6506007)(36756003)(86362001)(2616005)(8676002)(8936002)(186003)(6512007)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?jL+xH9bM8YM9mooHK002uNTqEqzZBpD2MySB5W7N4wUWlnrybiUv7HJWkJhs?= =?us-ascii?Q?dQrQED8jhW1g5Rt4TEjOlyjmM6RVJtioj/b8ITljD3kHi4KGqqYao1Mk1XSV?= =?us-ascii?Q?LSbsKEtiGly1UvTwmbi7vV7n2mqcmll27rECtwbPqXC0FEa8BvPEJPM7PAdW?= =?us-ascii?Q?aZrYoeaJiHr35jm55zsOLZIXReClrtI4TdV1Rkc68wKQ+BZMUOW+8GmyKmqM?= =?us-ascii?Q?1VTYoKT2TC0QJTzVenjrtH6oZ5dh/YQ7RDHKgCMFucsvjOn3lhIkZ64XvG6e?= =?us-ascii?Q?LCQ9AcsaKSRjHiWUxQGjMKT0mMbUHzx7gmktH60hLBlsHQarC6QCI8bTPGd3?= =?us-ascii?Q?XKl//Y+fEVUehlfg2CQwfZmQLO2nnJfY9UFn3WBu/aFCi8Q41sh+gB76nRpe?= =?us-ascii?Q?aB9GM9ge38anXQq15LeSrtcR/fydu9FiRvEwul4PKiXW3JRN9piGaYqmdrN0?= =?us-ascii?Q?4Uijs0k22WYkxARBu0lw6uf4LbhTwIuu+88a5rNPeOCvQXWqhGBRWhxQBXEV?= =?us-ascii?Q?KfXiFyrmQD9j3oVJToLDjTCwnWnXr9xCI3/emugZjAGp5IXPO/+RpZzbOC8v?= =?us-ascii?Q?N/G0iGchB2x8y0qrtU1MuVaIP4s8E4Pvo+UOwgZisk/XxezcD6GzHqh7GtRJ?= =?us-asc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5FiZzgo6jr7W9AUuJmU?= =?us-ascii?Q?+NHytCPjj+UZQnDRGKYxPzNyquN8SjHQwjmelk16Ha3JVvO90Sr7XTZWUhGh?= =?us-ascii?Q?TF4o5PgseKAp+hsyPjiOkz3JREWC64xPh9M5jK3KRfuRdE1fgA7XsntrL2B/?= =?us-ascii?Q?/LMjKQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 580fc22e-b830-4733-4cf9-08db70cbc25f X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 13:47:44.8448 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AVwPH1S2sRie9N/UeJYfpvnfS3tg7eNmIDOFoXWRdmQFcYhCtN8Co6Oh4XAOQZASte1Mcw+/JFeswejOXVmDS+PFWJa3hmsV2KUUwrNYL/Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB6059 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 On Fri, Jun 16, 2023 at 11:24:04AM +0200, carlos.fernandez@technica-engineering.de wrote: > From: Carlos Fernandez > > According to 802.1AE standard, when ES and SC flags in TCI are zero, used > SCI should be the current active SC_RX. Current kernel does not implement > it and uses the header MAC address. > > Without this patch, when ES = 0 (using a bridge or switch), header MAC > will not fit the SCI and MACSec frames will be discarted. > > Signed-off-by: Carlos Fernandez > --- > drivers/net/macsec.c | 28 ++++++++++++++++++++++------ > 1 file changed, 22 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c > index 3427993f94f7..ccecb7eb385c 100644 > --- a/drivers/net/macsec.c > +++ b/drivers/net/macsec.c > @@ -256,16 +256,31 @@ static sci_t make_sci(const u8 *addr, __be16 port) > return sci; > } > > -static sci_t macsec_frame_sci(struct macsec_eth_header *hdr, bool sci_present) > +static sci_t macsec_frame_sci(struct macsec_eth_header *hdr, bool sci_present, > + struct macsec_rxh_data *rxd) > { > + struct macsec_dev *macsec_device; > sci_t sci; > > - if (sci_present) > + if (sci_present) { > memcpy(&sci, hdr->secure_channel_id, > - sizeof(hdr->secure_channel_id)); > - else > + sizeof(hdr->secure_channel_id)); > + } else if (0 == (hdr->tci_an & (MACSEC_TCI_ES | MACSEC_TCI_SC))) { > + list_for_each_entry_rcu(macsec_device, &rxd->secys, secys) { > + struct macsec_rx_sc *rx_sc; > + struct macsec_secy *secy = &macsec_device->secy; > + > + for_each_rxsc(secy, rx_sc) { > + rx_sc = rx_sc ? macsec_rxsc_get(rx_sc) : NULL; > + if (rx_sc && rx_sc->active) > + return rx_sc->sci; > + } > + /* If not found, use MAC in hdr as default*/ > + sci = make_sci(hdr->eth.h_source, MACSEC_PORT_ES); Hi Carlos, sorry for the slow response. And also for asking about this same topic a second time. Does the list_for_each_entry_rcu() loop always iterate at least once, if the else if condition is met? If not, sci may be uninitialised when returned at the end of this function. As reported by Smatch: .../macsec.c:284 macsec_frame_sci() error: uninitialized symbol 'sci'. > + } > + } else { > sci = make_sci(hdr->eth.h_source, MACSEC_PORT_ES); > - > + } > return sci; > } > > @@ -1150,11 +1165,12 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb) > > macsec_skb_cb(skb)->has_sci = !!(hdr->tci_an & MACSEC_TCI_SC); > macsec_skb_cb(skb)->assoc_num = hdr->tci_an & MACSEC_AN_MASK; > - sci = macsec_frame_sci(hdr, macsec_skb_cb(skb)->has_sci); > > rcu_read_lock(); > rxd = macsec_data_rcu(skb->dev); > > + sci = macsec_frame_sci(hdr, macsec_skb_cb(skb)->has_sci, rxd); > + > list_for_each_entry_rcu(macsec, &rxd->secys, secys) { > struct macsec_rx_sc *sc = find_rx_sc(&macsec->secy, sci); > > -- > 2.34.1 > >