From patchwork Tue Jul 20 14:46:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 481551 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp5243949jao; Tue, 20 Jul 2021 08:34:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrFXiAeX2BMSzSYEq3Pl2LVgA65BHeUWvUrmYR27v/cAAEL4tZUGJeH1+LvnKr/+7vVBoY X-Received: by 2002:a17:906:fb12:: with SMTP id lz18mr33889454ejb.324.1626795262239; Tue, 20 Jul 2021 08:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626795262; cv=none; d=google.com; s=arc-20160816; b=vdRKASfM+1RDlg1RWdwwt56vkyAtF7HQnuQW34hdCwaS8zlybNz5PpvgSdCEkhd/IZ yCYYHm4ICjwiTpHe1XEUW5mAd+O/VmJ0AEGWdKc38spF20w+2CknAAGw144lGzKJE4oH ZrNd4HkNtVAsa+A2D22NgcGAw2qgMQyuwOXsID9ot+txGK5/Z7BaHf1iV0pKXF/H6+8w Ulsob6Il6STVsEukV903tTV+Vm6tmmG/qJOqCC31T9SW3LCPorO+xjAfnpRXIebT2iSf PYYQCrPJj7hrFfdwgON8pPvmntC4RYE8KdZcyL1jTYRhrqs2m0yZprh2D21wcH1B1pt0 ts+g== 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=9R8iJ60JbxMhQCw3h2ERQNMct0KS2YPxrzCyxPzpQzc=; b=Or1G/Yn91phlKHctmmjG1EA88LoP5YZ1LPQI6WuQapgQoQwnNv3xmR//rY5K0ZW57w FwJdvlnZqpDaMJWaocI97DCa5KzLP8eiofNcNM6naKSQ2WYRiK8WnSvFcDsKVKYorvoX ijlnXSNX1CDvt0EkQUo8eUSI5Ogu7+/Bj3uzZLJXpGBm/jE+YcH+589BH2450SDlu/2B QXVLkMi+QKm88sC7WvP2iVoNCXSCGVFP1b4XtjSlu/x8/H8oJKK9APyUrVfem6uScnq2 C9v6vpMhEZvZke8obQmZM4g7Rzmbe+xEpocrQMkUDqLHRNmyL21BCd/xlRpSyj3+2FLr EP1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q3MlPRu0; 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.34.21; Tue, 20 Jul 2021 08:34:22 -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=q3MlPRu0; 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 S241754AbhGTOxU (ORCPT + 8 others); Tue, 20 Jul 2021 10:53:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:35614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240179AbhGTO2q (ORCPT ); Tue, 20 Jul 2021 10:28:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F2A7C61241; Tue, 20 Jul 2021 14:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626792420; bh=ffq2EmnnSYIsOdt3jn+/z20QSrWUCvGK3mFM0XQX+ik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q3MlPRu0cBLxae/emXsjtVmPa2V7fgym1jZ2J2NIVCMcnAIYfWtPdrxd4pgG7yGTd 7uSmh2A4ieQP8aNQBCvuWKzvk2krgXTYLDKLXccdpIbrsFdglyi6v8fC+UW+GoBS5z Dk9Mnr04u+/oOnZVPe1xXcDpXwTA4x5A9R1IrXECPL78HhKMHrLG91pufcWaltOb8P iikJuPk7msHTB93VHjL07wjVOE0czindc/1rNU4n12GKuBSQpucCrW2Oq01MmoO0vm NlI0GHMdHk+BU3v7d4brszwv5wVe8mPYQEMRaj4+6HfwkPKJZH9aS+7rVh/5XjwSfX KNO7jFFaLLgrg== From: Arnd Bergmann To: netdev@vger.kernel.org Cc: Christoph Hellwig , Arnd Bergmann Subject: [PATCH net-next v2 07/31] tulip: use ndo_siocdevprivate Date: Tue, 20 Jul 2021 16:46:14 +0200 Message-Id: <20210720144638.2859828-8-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 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. 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;