Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5240496rwe; Tue, 18 Apr 2023 04:16:59 -0700 (PDT) X-Google-Smtp-Source: AKy350bRpjlJ+6AA14LecjNGBWqSCm+OGebaxMhsqBFCxmJ5AjpTP1ddHR8uzmGZnzob+VZ8VsVJ X-Received: by 2002:a17:903:1c5:b0:1a6:83fa:b370 with SMTP id e5-20020a17090301c500b001a683fab370mr2401662plh.2.1681816619608; Tue, 18 Apr 2023 04:16:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1681816619; cv=pass; d=google.com; s=arc-20160816; b=tIziD2YfH3zsGb63FC1bZrBnh5jelrftAD8Y0ef8xHMTCkB2MFl3OsOux5pHxa78b9 zYZeMcRPsPJn9K0dSni5JC3zAnsqFDfcViyU7N3PmTzkk6qYpHtkxyKxURecQeZkkOaL TTuEKd9V+glAL3KDGXtjLK2Kr3xvGSERBf8I78VTquXD/Pd5YOkv2nfp+pJDFyZNK7aV deROBxIHwG03mdSXxzZGDgLKHSgxXgvdvcXwypM+ugZCmkjR/Iciw1DrBhty6OwESj2i 0DjCVyUngtEKomyxM0p0ASZR4wYoRBT9JBebWToiI1v61LEIZ1Ba5rZbe/8YtzHYzFFf 0LXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZUBfqL8ZER71p4PwFMmPWN6oiSM69vL5qZGaDNdIfiQ=; b=kXTlNTgGvtn11+z6NEQESOOeNgaR9o9BPFc6g+lKJFgCqm6nMTjPTK+r3E3lL1CZMS Vdvpt0GZpPNRSmjniy4P+eRd6AWFT7roJ+D+VuMwk7ZJx++R7UbJrFQdXX4sWhZRzw/Z NeBxas5q6PFcXH5oIIaG8MvAjY8tondwHmac9gdAirliTwjvN5SzsWfkFRp5aYDu7a4A annjA/yZ4WVMP5WYapENV7R5qI462jsx5UJd+ntGWU4/vfAkb87aCPOnr9iSEGA6zoJ5 G+pfWbvYOGl5J3B1KrS3LKmE9ON3m+O3kNIugUIIyWeSAjy1iWsmJ2pop+VWsI31/aNV LsOA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=pUmfJpVr; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m17-20020a170902db1100b001a6494cf707si14500784plx.268.2023.04.18.04.16.33; Tue, 18 Apr 2023 04:16:59 -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=@nxp.com header.s=selector2 header.b=pUmfJpVr; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231488AbjDRLP7 (ORCPT + 99 others); Tue, 18 Apr 2023 07:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231390AbjDRLP1 (ORCPT ); Tue, 18 Apr 2023 07:15:27 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2045.outbound.protection.outlook.com [40.107.104.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDBB146BA; Tue, 18 Apr 2023 04:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OQlpzmFq2EEpQ1MUs+lSNws3mZOx01PfQIfRTbTEfv8Lugfd/CiSo9Tc71609tPE2JGHaikDvkRLSsx0fKaDxtTT9X8VQzXOFMrvHZtLjeISLIA4320Z8jWjxOwWx6mmGtR56sszko1mLjeKBXYE7LldSD2cEa+Cg27qwaFBDrw0ARdDQ9/n5l78nd4zUdS4sosjK+wTIdS8r0lgHjVDsXM124nzTd/FLICZlHU0F5XMiZ13ylVvzSzK+SlF+L9YesAH9LZ1iLVof/DZV1mHIRAieabY9e/jJgDlhai+08W9g8tIU7BohXbInh807Hy+fIh4gaXFJAZh+QjD89BsxQ== 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=ZUBfqL8ZER71p4PwFMmPWN6oiSM69vL5qZGaDNdIfiQ=; b=StwkvzV6MmwnxIp0wgwgktt3lrFRfkBsT4LobM/eqpMJ5stBfRkE6Hk5J8U6wPkckeBCaXw2HYLePMYmGn949RVA8TuW1dnz+zFJ1Zu1pYi8xylTaBnNkmYRMSSsmskESIXjgpFJUjFHs+WkPo96BzPuQYI941z7M4USFgZXfqJTIq6gB9NOiqqpT8srLB84Z77yizK7QSR3UJmjvYnblIYB+ZFvcvAhAKd35SuA5NaEuO5mrBvJuQedHcB7v7DBXo45+dIRfZlxnnEZdPig0ZWAqK8G1YHmgT+UFUGy0AweXIzTbqqc7EkF79M+5Zie13L8cFRbO6gp81Un7giY3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZUBfqL8ZER71p4PwFMmPWN6oiSM69vL5qZGaDNdIfiQ=; b=pUmfJpVryqR7A7P05ePoJeM057H5bzRPrZTVIeahYHGRkqTLKnlKdu3rDltB63R0tvrwbtlkAPLDYazCCL1orT6n/kpq4xTcnI2texH2UmIPUEyEn5VCnjQWJCj6BJa0yJkYFRWoD9WcAp9JCBl2LlGzEfxJbjKgCpKOx0BWNJE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS8PR04MB8659.eurprd04.prod.outlook.com (2603:10a6:20b:42a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Tue, 18 Apr 2023 11:15:22 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6298.028; Tue, 18 Apr 2023 11:15:22 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Michal Kubecek , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Xiaoliang Yang , Petr Machata , Danielle Ratson , Pranavi Somisetty , Harini Katakam , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Ferenc Fejes , Aaron Conole , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 5/9] net: ethtool: mm: sanitize some UAPI configurations Date: Tue, 18 Apr 2023 14:14:55 +0300 Message-Id: <20230418111459.811553-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418111459.811553-1-vladimir.oltean@nxp.com> References: <20230418111459.811553-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: FR2P281CA0152.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:98::19) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS8PR04MB8659:EE_ X-MS-Office365-Filtering-Correlation-Id: 8fec4046-b3ee-46e1-f7c4-08db3ffe3392 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MWvPWjyF9r57ZJ455F7nsF7X4+v++Qo12iA1/2fR4moH+QgYROGZ0Sn0yfd2AgiKI/cXRnvLcFdgaklbjuMyzTbJpB56xnRCvFTHbAp2a4xAPPCLr4/6nnzZih+zm4kzNqw4gvQwy6ZUEj03gViaBph6SqWilKWvyId5r20HY/CDmX5uiOg+VU+spUCl7+V7g9tuNHXaDJnhXJcTzzFej9szESlocZ87G+QqHqxXOju+F4j3pqMeT8FEdkMLtLQRyZui4eML3ILa09/ujAXAwTdhCDhC0AVSEaMj6pm8818ZMJ/E5OKIi92d/gr2Bxq9qRVyNAt6T8rXAQ6V1uXt51cTBGGpy235nNXWfJMwf1vO7UnRZjJLjQUAKzMEjKxAGT5EbTfNKeFOuH4kFNVEqAoPy8EubQfpakrSEGQCZUuc/WJM7IZFJNqcKxJS4sa1IGJeIWShbBMigzjuCsaHhmw30/3sNM7XXFgkpLQdccOSDRrsibyIo/1aY3JnkqidyJ898HWzBFcCvJUFQVJo2JE2z9k+/4HkL89mZhtBbHCNGLRvF01OP4Ff2hovvXmHo/KoB/CR913ey6R2EK23jHefmYHGlGzf6GKDjzvVMYLvKVXMloBBIqYpMTqHC931 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(346002)(396003)(39860400002)(366004)(451199021)(6666004)(6486002)(478600001)(86362001)(2616005)(36756003)(26005)(83380400001)(6512007)(1076003)(6506007)(186003)(38100700002)(38350700002)(52116002)(66556008)(66946007)(66476007)(316002)(2906002)(4326008)(6916009)(8936002)(5660300002)(8676002)(7416002)(44832011)(41300700001)(54906003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Ha525zYnbg+7ay56hOfH82Djy0iEdEW8kunTxmas0L/+qw9iksyXU6vWT6N+?= =?us-ascii?Q?WiBRXewxI/W759FrVIQ+VlTJUrx7++nop0qT3ZBQ7q0qi/itZb4PKwKUtPB9?= =?us-ascii?Q?VMJPNP28VX2/Ww2vMBCrqbQBZQ7kPHT6LkC2IEJ9MSbxvNMvTUggkflUk41j?= =?us-ascii?Q?hSYKWBLlY/X6BI07779gKBrBqmNpxsiZbMaMLqHY0vhhfVUUVCa9edEhZ6jL?= =?us-ascii?Q?iBm6A0zMxdaIjcUzHDrn0dm3uDBF7Wv5L237GPuOgX5FMNJJYpH6miJiqQnP?= =?us-ascii?Q?mlP1C15Tlse1aTQ+ZSM6TM+2eVmrfNNoyds/r6nvuToCrEWpDyG4TX3oJv/g?= =?us-ascii?Q?09YoB5K8H4UrziRiwOKRPjSo2IdBfHONj7jcZZqwfvpHniklEFqfFfwDOzJ5?= =?us-ascii?Q?Hmeu3NJl3+Qqhtw+tswqnqlDyHg5ahE+BJRjktTOBObIOaQ0ZwiXw03LF01y?= =?us-ascii?Q?0kkANiQmKXoY7SBA9qLCZRCLSwlCO/BMnyQBdI4uYnIzANR9ze+VOyNXn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IcvwohaKsOwgNoN3PSag?= =?us-ascii?Q?HcknFVxDzw92PYuja1g/qR5v3UwPt4tk+/c0hfhBdOp/A2OBSt9t7CKkSXVv?= =?us-ascii?Q?jp3/UKah4aBFIxzHDj/jvrFlGZgZBY/Vw4/b6DENsw98dtYuPIQ8+OY8QWdR?= =?us-ascii?Q?0MLdNP0LlCHj5t6agDstn7tJgfTBG05He0Yw4cJUnJiF/l+R909l0Edjyb+D?= =?us-ascii?Q?pA=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8fec4046-b3ee-46e1-f7c4-08db3ffe3392 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2023 11:15:22.4304 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mvz9d6+mNxjGJbyYvi2ONn0kvTIMC4hRCz8DQDM3jcNZ2J+YLaqhFBlshkJ0Jxgr23mEm+VEecNgDCDu4iD+Bw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8659 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 The verify-enabled boolean (ETHTOOL_A_MM_VERIFY_ENABLED) was intended to be a sub-setting of tx-enabled (ETHTOOL_A_MM_TX_ENABLED). IOW, MAC Merge TX can be enabled with or without verification, but verification with TX disabled makes no sense. The pmac-enabled boolean (ETHTOOL_A_MM_PMAC_ENABLED) was intended to be a global toggle from an API perspective, whereas tx-enabled just handles the TX direction. IOW, the pMAC can be enabled with or without TX, but it doesn't make sense to enable TX if the pMAC is not enabled. Add two checks which sanitize and reject these invalid cases. Signed-off-by: Vladimir Oltean --- v1->v2: add missing "Verification requires TX enabled" check which was only mentioned in the commit message net/ethtool/mm.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/ethtool/mm.c b/net/ethtool/mm.c index e00d7d5cea7e..4058a557b5a4 100644 --- a/net/ethtool/mm.c +++ b/net/ethtool/mm.c @@ -214,6 +214,16 @@ static int ethnl_set_mm(struct ethnl_req_info *req_info, struct genl_info *info) return -ERANGE; } + if (cfg.verify_enabled && !cfg.tx_enabled) { + NL_SET_ERR_MSG(extack, "Verification requires TX enabled"); + return -EINVAL; + } + + if (cfg.tx_enabled && !cfg.pmac_enabled) { + NL_SET_ERR_MSG(extack, "TX enabled requires pMAC enabled"); + return -EINVAL; + } + ret = dev->ethtool_ops->set_mm(dev, &cfg, extack); return ret < 0 ? ret : 1; } -- 2.34.1