From patchwork Sun Apr 2 12:37:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13197382 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46D8FC77B62 for ; Sun, 2 Apr 2023 12:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230332AbjDBMiZ (ORCPT ); Sun, 2 Apr 2023 08:38:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbjDBMiU (ORCPT ); Sun, 2 Apr 2023 08:38:20 -0400 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2071.outbound.protection.outlook.com [40.107.247.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C8889740 for ; Sun, 2 Apr 2023 05:38:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NiffzvOWmTy5DKF3ezNoFTuToIV3du2urA+fg2ZbNh9ytp/U/JThJr7nuaeDMDCNyO3vRutvq+Ta7SDg19vkcB0iO6yEyTXGD/tLTZKcYMHzag3XNIu3zhL8RacXDCE26Yu9MxSFQSXgNAW5tCjzpdr4rzG4cqWW3I5sKFTHkISYfi41D12o5yrimhOYGN5wAp+C4YJ4fFYWim5mFcyLpXQE9sJXb2F6iYsHSCtvjNlaHwsDPoKIhv6ojUN0oPlCAlFaLy1Vii6ieq1CTGrBui3p2ukEarU+APbdl7uaPg5guzx7QcDnQtqwpMp4aMthkgOGXFEHuQ+of3jf2j2dnQ== 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=yAtuOgQZ8gP2z4Snp06w4GyQSc6lSb0Hyo7pkzukcEc=; b=I/2VYBhbyiodnZ3GBAUm1Is5e6bAXuvU7T+VwJT+BiYNuZtETmAvc5YyCNkx/689T0qxnyvXOrr5ajW2GBHOjtKL8we1G5q7RIHWPHo2eorq6w+0MPKw/9wR5mRZa0vx0EOR+cS3lTw3qRh4rCK21STeOyEA2kJ2xA04jl79x/zJjMPzYWEr0lViWEdswRFYh+Jw36WATzYTNrLE6gaLTL59zbPh1Nd04wK20x93frESuP6c2JN1twAy8eB6Sf7JErZhMNZQf25mEPf7eeMEXK3CN9FQcL4LpdmosGHQl9StvO7z8OJOfCx7WXcBsAAiZx3sFuhk7MqrutMrXThBAQ== 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=yAtuOgQZ8gP2z4Snp06w4GyQSc6lSb0Hyo7pkzukcEc=; b=n0PQg6OdSe6wWzW6g/WBLgEqieh6tNwc88SE4KGBjFmT90zE0YFjc9r75VwXMrd08IvPOW0LNTkpSZZe3wPi5Sb47P9a+u7TUIXITiimgT/XBepagjKXLj8rjgFb7EpaCIlQ2aeYuMdRI0C5NfKKKY8UK0S017yRXpDYvjJbLR0= 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 VI1PR04MB10052.eurprd04.prod.outlook.com (2603:10a6:800:1db::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.28; Sun, 2 Apr 2023 12:38:13 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5%3]) with mapi id 15.20.6254.026; Sun, 2 Apr 2023 12:38:13 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Maxim Georgiev , Horatiu Vultur , =?utf-8?q?K=C3=B6ry_Maincent?= , Maxime Chevallier Subject: [PATCH net-next 4/7] net: move copy_from_user() out of net_hwtstamp_validate() Date: Sun, 2 Apr 2023 15:37:52 +0300 Message-Id: <20230402123755.2592507-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230402123755.2592507-1-vladimir.oltean@nxp.com> References: <20230402123755.2592507-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0018.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::28) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|VI1PR04MB10052:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d8f6762-e374-4162-cb1d-08db33771f6b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EhgejxNzoFA1Yb3cUzH2hWIZ5USznIsjwdKlsYznX3rNS4M2yEhZMA6R++8Ps47YFsgsTkb1J9U9R39ZPTL3hUMwwnSofc+VhdV2WOydbmi1VzcKkKXzs08QcMORDV/6SM9MTz6xgHpqafCqTJEu9zPhvF7RbVuMP1EnJ1mu9Fz4+leDGVIUprkkCG6+UBbaWwe2FVolrtntMy6yWsFzkLbEV4BIBa4TtpszdWQOzQNLmynNmTm25pH80FkHLgZwUbZDo+5YxOCPx4GGjjcijIdTT4wHpc6oI3SAjMhw4ilUK8AKc1/+/C9k6AmAxkZ14TMWWsczAoM+3EnRKrnwHQygRydvFVn1S/LPVVAmBtjPi0WhfRoRSHwMJHGPsbhcYxjq3H7GoLiwSmmq9y66+RLNjm/MF5CN9FMPmKPTVC7gCQXSh6t41FrvV44uG4vEQeBN5DzZqcZTZO/TNe+dFHlrAXuuoKEXel1tMA9b/KD4thlkFaciuuE+wCDcSCU2xv/s+Z4dnaYVbDetBDrIhr5hOgX9YF3rZqfZ1W02dOqX22dQFcD+VQRMvDrNeTjAjmOJuIFEJmnUSUpF8qjBkgncuqJP4sw+FkNmuZ5a/dURgK+o7/XXYyhPSi47iVEr 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)(39850400004)(396003)(136003)(376002)(366004)(346002)(451199021)(66476007)(86362001)(36756003)(83380400001)(52116002)(41300700001)(316002)(66946007)(54906003)(6486002)(4326008)(66556008)(6916009)(8676002)(478600001)(7416002)(5660300002)(44832011)(2906002)(38100700002)(38350700002)(186003)(6506007)(6666004)(1076003)(26005)(6512007)(2616005)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jTFk0so2920Af9cOx3rKwA/AFI+nkfv4jnv5kz29HG39S2Vl7lC8dUI9D3ErwpPJUH22D5n9v3YrRMxAHDnHSgNL17lDLlTxl4xO66iyYYY53SBmRnm+uwrgNhzm39wbvxEuKeQ2D7ufWBc5feZ7kpKxFvFSdxeWxzivn9NzI9hpC+yaKuH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zUeaJne6qbsqVW/kqp/MdMju/QuQC8h8kc20xJQI2fBkgOde1lnWyAOSHsBIjwE8pbloz7AT+JfyZ5Kn5HDJ1BvItWOUGOLD+bPyubpfw/sT+YzqPZsI6+leneQsWAw/+wqFUXnYWw8ljF09aBTCvKQ/eug5EMeWixPwhfCjc9eNtflRfuYBAmhHdypuyPlSSo8gaI67YZUCyG6U0QPYWqhcIruNTqClG4JscXQLw59Xtse9gNxe0H74CRaoKbI5TC1Ml0aKARysl90JMDKMM3rZqPcgvSmXrG3XYmfl3vhpHhGhKk1S3gYwY8J528Y0xt/Zgtaya2Ub4j+4WJPaQhohRNxZfDOX/nOeJF7A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d8f6762-e374-4162-cb1d-08db33771f6b X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2023 12:38:12.5978 (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: dF1zFcNgi3uHWNK05O0eBTeC5QQGvYpuABqHL47BAkmaYmV8pJtzRhAIVZ0C8+zNSX9mjGs/6UY/lw32slMh3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10052 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The kernel will want to start using the more meaningful struct hwtstamp_config pointer in more places, so move the copy_from_user() at the beginning of dev_set_hwtstamp() in order to get to that, and pass this argument to net_hwtstamp_validate(). Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- net/core/dev_ioctl.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c index 3b1402f6897c..34a0da5fbcfc 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -183,22 +183,18 @@ static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cm return err; } -static int net_hwtstamp_validate(struct ifreq *ifr) +static int net_hwtstamp_validate(const struct hwtstamp_config *cfg) { - struct hwtstamp_config cfg; enum hwtstamp_tx_types tx_type; enum hwtstamp_rx_filters rx_filter; int tx_type_valid = 0; int rx_filter_valid = 0; - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) - return -EFAULT; - - if (cfg.flags & ~HWTSTAMP_FLAG_MASK) + if (cfg->flags & ~HWTSTAMP_FLAG_MASK) return -EINVAL; - tx_type = cfg.tx_type; - rx_filter = cfg.rx_filter; + tx_type = cfg->tx_type; + rx_filter = cfg->rx_filter; switch (tx_type) { case HWTSTAMP_TX_OFF: @@ -263,9 +259,13 @@ static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr) static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr) { + struct hwtstamp_config cfg; int err; - err = net_hwtstamp_validate(ifr); + if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) + return -EFAULT; + + err = net_hwtstamp_validate(&cfg); if (err) return err;