From patchwork Tue Jul 27 13:44:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 486704 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp231957jas; Tue, 27 Jul 2021 06:46:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw37X7Y2FhHQ/wQuVxizV/q4FRC/ukYHmfSAyRhGQucdEcIVY6dvUFeDQHRUSZqKpu/OJln X-Received: by 2002:a17:907:987c:: with SMTP id ko28mr4516443ejc.200.1627393597273; Tue, 27 Jul 2021 06:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627393597; cv=none; d=google.com; s=arc-20160816; b=gNsvo/OyEBQalV35fnR6zJLSwUv8lAfTH++ZTcspYBztByATW7j0sMrb28LWCoVDvQ 79gJgRnA4mPKR9LoGHYp//1MwRBx7WRkzwjY0LpKCogAZISAy+xvE4v5QgVBA241nfrm Tn+K+F/ivQDE49gypQYOH5tQ0ROR4PqYp5AFTixQKpR+WRIwVyXbBls+B0WNi7y7wqK8 wZyFIGgMJoLnKEiLopUtJSZLWOH2cF4+eU0hc5iHzMt8VCv2yXNqQl7r7/MBSxlCN3Ok KfZC0oh3jLqT6ZnMjppLn9THVn7+MIGkaqXAnLlt/XvrhAKFUEWrwwCTh0lgahz8JhnG MCgA== 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=Vyc7IPkC3M8rSfuFkHPVQQS1FN7sDvdt2CYmoRAIA9U=; b=gTMNVqPXrjrka3TIxU1H168eoPMLok84mmhuieR/7rQ3Y6Dy0/yadY9gZZYgh5TNa+ i+eSf9EfBjl5zMJ9kSdFgN/RO/HSfa9P64EVHQFBnHb3TBrfuPDyICuwxG1d0YghLieb 181s8QeS0wOaCCmFlVaHZjwhL9oEwnd+Jn4nLESfnhJYz22o0LOPWCeLzEW7OSwz4pBE CIVe3cQCd7CYYRYr91IY1Pp/dWfAf1Kvso+SB3Rz7oJNx9Uu+IajS+u8k0yxcE9i/zkB rsbjEIa2LsqHtnLPE0pwH1bluj578ZRfY+ziYS05efvFn/iU3m34J7HgJkyuv7DLthp8 7kcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s5hvaYII; 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 u22si3078914ejj.279.2021.07.27.06.46.37; Tue, 27 Jul 2021 06:46:37 -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=s5hvaYII; 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 S237008AbhG0Nqd (ORCPT + 8 others); Tue, 27 Jul 2021 09:46:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:46306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236721AbhG0NqL (ORCPT ); Tue, 27 Jul 2021 09:46:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7A9D1619F5; Tue, 27 Jul 2021 13:46:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627393571; bh=+t9fgxzXlhR6aMB1NCCu4ndbySWH7P+Oqdf5Vmqkihs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s5hvaYII0JI/yTMojcAbHnRFPE3DsxQrcdUu6WAdNMCZ0AhHv08oHIVYp2knEXQZ8 0KpnHD1dKUc0T88Eeb2IE5yQe2Met5WI4kuSnsArK6T0o1IgKjETUaa9TTzun9jQQ2 dBZAhdfTwHko51YlM5kOH24yfRcpwa2/3FgEH36amqzfVmrhWgx2rJbbAtR1AKyNyn 4oFb00PJwN3m0fL0klGd00jFyab5kvRU8cmUawzIqlGG4yzu3rPa3eiKTSv9YKoRDl fEKsSfWsXaBbnLJiF3MLNDR7m+P/vyC5ql5TAM3hxP9uUdTTx6K99PT/p5CQRMxK1L 1dHI/7+jH9fdA== From: Arnd Bergmann To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Arnd Bergmann , linux-parisc@vger.kernel.org Subject: [PATCH net-next v3 07/31] tulip: use ndo_siocdevprivate Date: Tue, 27 Jul 2021 15:44:53 +0200 Message-Id: <20210727134517.1384504-8-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210727134517.1384504-1-arnd@kernel.org> References: <20210727134517.1384504-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann The tulip driver has a debugging method over ioctl built-in, but it does not actually check the command type, which may end up leading to random behavior when trying to run other ioctls on it. Change the driver to use ndo_siocdevprivate and limit the execution further to the first private command code. If anyone still has tools to run these debugging commands, they might have to be patched for it if they pass different ioctl command. The function has existed in this form since the driver was merged in Linux-1.1.86. Cc: linux-parisc@vger.kernel.org Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/dec/tulip/de4x5.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.29.2 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c index b125d7faefdf..36ab4cbf2ad0 100644 --- a/drivers/net/ethernet/dec/tulip/de4x5.c +++ b/drivers/net/ethernet/dec/tulip/de4x5.c @@ -443,6 +443,7 @@ ========================================================================= */ +#include #include #include #include @@ -902,7 +903,8 @@ static int de4x5_close(struct net_device *dev); static struct net_device_stats *de4x5_get_stats(struct net_device *dev); static void de4x5_local_stats(struct net_device *dev, char *buf, int pkt_len); static void set_multicast_list(struct net_device *dev); -static int de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); +static int de4x5_siocdevprivate(struct net_device *dev, struct ifreq *rq, + void __user *data, int cmd); /* ** Private functions @@ -1084,7 +1086,7 @@ static const struct net_device_ops de4x5_netdev_ops = { .ndo_start_xmit = de4x5_queue_pkt, .ndo_get_stats = de4x5_get_stats, .ndo_set_rx_mode = set_multicast_list, - .ndo_do_ioctl = de4x5_ioctl, + .ndo_siocdevprivate = de4x5_siocdevprivate, .ndo_set_mac_address= eth_mac_addr, .ndo_validate_addr = eth_validate_addr, }; @@ -5357,7 +5359,7 @@ de4x5_dbg_rx(struct sk_buff *skb, int len) ** this function is only used for my testing. */ static int -de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +de4x5_siocdevprivate(struct net_device *dev, struct ifreq *rq, void __user *data, int cmd) { struct de4x5_private *lp = netdev_priv(dev); struct de4x5_ioctl *ioc = (struct de4x5_ioctl *) &rq->ifr_ifru; @@ -5371,6 +5373,9 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } tmp; u_long flags = 0; + if (cmd != SIOCDEVPRIVATE || in_compat_syscall()) + return -EOPNOTSUPP; + switch(ioc->cmd) { case DE4X5_GET_HWADDR: /* Get the hardware address */ ioc->len = ETH_ALEN;