From patchwork Fri Nov 6 22:17:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 320865 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp1674391ilc; Fri, 6 Nov 2020 14:18:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxE5fn88JYSnqAp+Jx1H76za2ktixxAi1xZzSafF1iokUAd7011zhhcXcX9etDW/6PTOSls X-Received: by 2002:a17:906:60c8:: with SMTP id f8mr4424082ejk.14.1604701105700; Fri, 06 Nov 2020 14:18:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604701105; cv=none; d=google.com; s=arc-20160816; b=ceH1hC8H36oJ0dET2T6lmIafXe3f7oq+XvF5g7fipQxZMuStvSn0Ly+mKVaTzBEb+N Qpzy0tPY3hFIQqNCxwS6fdfcG+wgn+kf2bCgm3j65p1SF7Q9Y+LnNnhsbAGQRQS63kEH Dci6D+/fpxthuYisq9wlBqsWstU268Ap0qqPb37GtlrGV4i0+hchxWfr9rFfAux1UUn4 ieYhBL4LYgRTQZvf1bP8i1yjx1lcNyW7W5IjLrPVITIZuf2jZjhUJFNmcu1eg9xN6J5S R2A51t5PPLB8SaO5dKm8H55h/d3jpd3bOpHe8bOF8wYdwIWU0PrI8pJPNNBhnmTNLDEN BBmQ== 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=OTLHWbGzGo0cABkg4ev35kp5rxjdIGJzhjmrgz0Q0Xo=; b=nv+d0PC/6yE+Xxj29HDEM+r8BvifnvLcTkI4iNb/NKkwJjBsKldKNANMVakeBRiX8x 8dJbErvgqt9i3Tmwe2HO8xBRvZal2sU/bVqs7IS9cGyFbZnWepfINqDajhHYEUr70ukT FSdA5cTMuxOw0j5n7Yqxux1e4k38oISjI7Q3ClM9GDz7oBkpy9tFJbi19nSHdb1j4SEP 9SNT0XojKupfxv55dg0uYWEBvmbbv6r10iGMtE0HeDKZmVOKYZ7VXdmH7vVtyertwZzt onBNSpIgA8rjPbaezp6x+6l/RxgQ9Z3wkxQgvQ2srlCbk7cLvoIG6hyqHx4cjgd/YHxR OF8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="o/hvgIT9"; 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 ci4si1848008ejb.436.2020.11.06.14.18.25; Fri, 06 Nov 2020 14:18:25 -0800 (PST) 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=default header.b="o/hvgIT9"; 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 S1728953AbgKFWSU (ORCPT + 8 others); Fri, 6 Nov 2020 17:18:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:41576 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728887AbgKFWSS (ORCPT ); Fri, 6 Nov 2020 17:18:18 -0500 Received: from localhost.localdomain (HSI-KBW-46-223-126-90.hsi.kabel-badenwuerttemberg.de [46.223.126.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 427922087E; Fri, 6 Nov 2020 22:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604701097; bh=ejrB3sfP8Vhn5+VAUXi+L6LpDodKnVmFjv0rU9L8csY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o/hvgIT92Bk0M83Xab3GbNkl+xpVG4NHaBN01+8U6H+Er1kiG4YsX3i4m4ZP00e2y 2mkHLMu1fUhv43aUCI7R9In7ltd2PSh6WT6PJ7Fex8Xg8/YNd0P6InD5wUyOKpnuDY Utxsq02pbsuZJdJjZeYJsUConVTbwpD/SQvJysOI= From: Arnd Bergmann To: netdev@vger.kernel.org Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, bridge@lists.linux-foundation.org, linux-hams@vger.kernel.org, Jakub Kicinski , Christoph Hellwig , Alexander Viro , Johannes Berg , Andrew Lunn , Heiner Kallweit Subject: [RFC net-next 08/28] tulip: use ndo_siocdevprivate Date: Fri, 6 Nov 2020 23:17:23 +0100 Message-Id: <20201106221743.3271965-9-arnd@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201106221743.3271965-1-arnd@kernel.org> References: <20201106221743.3271965-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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.27.0 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c index 683e328b5461..59a85f5b35fb 100644 --- a/drivers/net/ethernet/dec/tulip/de4x5.c +++ b/drivers/net/ethernet/dec/tulip/de4x5.c @@ -902,7 +902,7 @@ 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 +1084,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 +5357,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 +5371,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;