From patchwork Tue Jul 20 14:46:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 481559 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp5248429jao; Tue, 20 Jul 2021 08:39:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2cH0lQ8OK6njxEkAWW5Si1/KqKoy/yLudvP5Yi9ahiMqxhNvGYEFaHyXW5gkIuoaYx/6r X-Received: by 2002:a17:906:b0d4:: with SMTP id bk20mr32539068ejb.535.1626795580476; Tue, 20 Jul 2021 08:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626795580; cv=none; d=google.com; s=arc-20160816; b=m0/h4yX7tHmqK8WSPzuYCvaDnpScA3J2GbXrRJ1bgyaDorAYxTXIE7PbHvW1Eq47OB JTNz1nHuz2LJL+GseRbDHbqFjzBFvewzMtr8+RCpD85ztPbOzX4TqbqXDeitDUwOF9eP fBisKHr7jSCbcxhgGYVRXuSugaeGEXDjSkHmcx46WSvyPswS3x3Q9wHFWvgWDDm4Oyrn op97fTvyqvl8lcM/Xp935CA+ViFfExUuIGN4h8qXHSyGjSSlfThD7v60rSK9/mIu73n5 wk4t/WbM7EsHsXVQ0P/+C3CxpiI3ANXjxdmju96imnc9dajhu2GdWDH5/Xd3c1J0RyxW CHgg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LnlltNFxjVlTq+WY6odiqywn9k+MEP2SHUwBMrYAWUs=; b=jMEpAvC012SS1C4QVJ8nWjBZgDJt4EmV52y5b86ibvFox3r8kfDwQCsP2cRx6yLhZk jk5BVfCQLjRcUw4uIXJcnVU2bd4lFlSXumm4P7NeNFfEFGk11tMC4yWTBDPLy7Qb0JeI zsl66dNAOvesTTlTiuhhzyghZY2mSCxmpGlgJmCAQ1lt7W7mKkZ1BwggE/7wiWoZTIuJ YHvQ4dzih6c0D6lXgIe2QhoIOvOhGHyR4g8qvtmnOkY389W38Gg974eAC8mB8zU1QRZJ JYV8uB+bFtcZTDX72QaPmig+CNl4vH0UJniDBuWQLpYAAMYGbvcWhqPDns+9iZHEb+R8 w8Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bn8h9GWf; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si160517edd.497.2021.07.20.08.39.40; Tue, 20 Jul 2021 08:39:40 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bn8h9GWf; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241822AbhGTOyW (ORCPT + 8 others); Tue, 20 Jul 2021 10:54:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:36050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240449AbhGTOaw (ORCPT ); Tue, 20 Jul 2021 10:30:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 958EB61246; Tue, 20 Jul 2021 14:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626792425; bh=sDCMtMP7Pgt+PxycUvIgb3ElpWRaEe2P7FlQyXYUjpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bn8h9GWf28Bv8rXYbWyKXBWBlUS4/sQjINhGrMiNhUGo6KMx2aZudqvXiGFb/DJCv S4m5gEyssanvyRRBQ2PPe8J4ACeNNsoeZ5M5iiKAu6tG+Tofd0eS61M6e/5yy8jw4p OafJQdDC+jGBS8isxHgRKD33KZzVMpEadfyJ5ekmstlqOOGbPp019TQt9rBOgAZAzI rpdqo/wxY6TmQzyXyGMkZqymJwY6kKiJMoIN6xhHI6Y7StS96mNP+LwxyyPJIakrcL 13ITvh75CSx1P/HYzzIq6MMIZCQiBOIw8q13lFECZFTHKlMz/j5nSy2VcuPfvLkX/n sSZopXdbSktNQ== From: Arnd Bergmann To: netdev@vger.kernel.org Cc: Christoph Hellwig , Arnd Bergmann Subject: [PATCH net-next v2 11/31] tehuti: use ndo_siocdevprivate Date: Tue, 20 Jul 2021 16:46:18 +0200 Message-Id: <20210720144638.2859828-12-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210720144638.2859828-1-arnd@kernel.org> References: <20210720144638.2859828-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann Tehuti only implements private ioctl commands, and implements them by overriding the ifreq layout, which is broken in compat mode. Move it to the ndo_siocdevprivate callback in order to fix this. Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/tehuti/tehuti.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) -- 2.29.2 diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c index d054c6e83b1c..8f6abaec41d1 100644 --- a/drivers/net/ethernet/tehuti/tehuti.c +++ b/drivers/net/ethernet/tehuti/tehuti.c @@ -637,7 +637,8 @@ static int bdx_range_check(struct bdx_priv *priv, u32 offset) -EINVAL : 0; } -static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) +static int bdx_siocdevprivate(struct net_device *ndev, struct ifreq *ifr, + void __user *udata, int cmd) { struct bdx_priv *priv = netdev_priv(ndev); u32 data[3]; @@ -647,7 +648,7 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) DBG("jiffies=%ld cmd=%d\n", jiffies, cmd); if (cmd != SIOCDEVPRIVATE) { - error = copy_from_user(data, ifr->ifr_data, sizeof(data)); + error = copy_from_user(data, udata, sizeof(data)); if (error) { pr_err("can't copy from user\n"); RET(-EFAULT); @@ -669,7 +670,7 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) data[2] = READ_REG(priv, data[1]); DBG("read_reg(0x%x)=0x%x (dec %d)\n", data[1], data[2], data[2]); - error = copy_to_user(ifr->ifr_data, data, sizeof(data)); + error = copy_to_user(udata, data, sizeof(data)); if (error) RET(-EFAULT); break; @@ -688,15 +689,6 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) return 0; } -static int bdx_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd) -{ - ENTER; - if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) - RET(bdx_ioctl_priv(ndev, ifr, cmd)); - else - RET(-EOPNOTSUPP); -} - /** * __bdx_vlan_rx_vid - private helper for adding/killing VLAN vid * @ndev: network device @@ -1860,7 +1852,7 @@ static const struct net_device_ops bdx_netdev_ops = { .ndo_stop = bdx_close, .ndo_start_xmit = bdx_tx_transmit, .ndo_validate_addr = eth_validate_addr, - .ndo_do_ioctl = bdx_ioctl, + .ndo_siocdevprivate = bdx_siocdevprivate, .ndo_set_rx_mode = bdx_setmulti, .ndo_change_mtu = bdx_change_mtu, .ndo_set_mac_address = bdx_set_mac,