From patchwork Tue Jul 27 13:44:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 486703 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp231870jas; Tue, 27 Jul 2021 06:46:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqnWzeQ7fnbh+mEzcXOKDQd+VcavBW1rldhr4UAGHr86dSnAjOhVIXUePB7r/PwpXN4P3h X-Received: by 2002:a17:906:6d54:: with SMTP id a20mr22283204ejt.322.1627393591514; Tue, 27 Jul 2021 06:46:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627393591; cv=none; d=google.com; s=arc-20160816; b=FPN/jNYC8R9JGsebVBnZ5hvkQ/yxwCOXLbEkMCp/YBG7tlBpv4Vz17B9qmehfPH+Ip Wuq49ORFW+U+L1XeRR3ugWmFSrs80lVrnTbeSs6O0bVPhlGD0jNm1v1ClxQ9cRTMj8EX B7UTmaM0kTwVIzqa6wFtnKoig/X5fQ6F9jkMsWHM06RifHTLp5S5qYvKiiGk36/5w8k/ 8yBk8O3sLZxLNjTIbTyxAPHmDkjTvz0LJuuJxo8wRWR9XGr0C8TqMtkC8h5Ht+7XVfW3 YzYJ9m6HrxIN6XXqqq03wic4RPgHpAKZ1w+gJ+otU+kUgl9TrL1+H49KIV5Rw+IfUyYE Q2/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=4IQuqws10R03UGg7qhVWfgK5GrLPkRYKSaU+1pem9Co=; b=S/U9cpoBsg1cnX6yKPi5zLt+kC3oyN154J1jNKl3crZzEwWx1W9gD4AoViDHLyWaP2 7wr9Rfy3SIMtYSlyjeVw6sXsq+f9J6QilfijaWL61y7NyvN2h0cLxRuM0JGYTc3pD4Ss OWEcxx7kEWKysRyDf8ZX1IroziaEp/7NkDzcY7wjHsKxKwDkZoDaKSVYFlIgLQZqG89F rwXsiq+AYRSgf+OZ0ElWOZK+3QmkjHHZVLwf8KjYKloKXkZdXIaDIaEYt5+zPComy0XA XOZ9qnSBNcqos1XRCw5ooK5joa0urHKLGwIHYwQ3OWkRVBbTUGweJ32CrSia3snN1f1p dkSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MstiQWuz; 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 hc43si3594933ejc.1.2021.07.27.06.46.31; Tue, 27 Jul 2021 06:46:31 -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=MstiQWuz; 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 S236981AbhG0Nq3 (ORCPT + 8 others); Tue, 27 Jul 2021 09:46:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:46428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236828AbhG0NqP (ORCPT ); Tue, 27 Jul 2021 09:46:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1481161A54; Tue, 27 Jul 2021 13:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627393575; bh=ae1hfH8QF/RCzo7dEv8MK0I6559MFhj95aqCe+aAmz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MstiQWuzJx8TGB9tI9V9t0NnuYyHtNmfD/5gEPaiqYsxSJTS3w28VPtR5wJtO+hVa XEDCm8+oYSkcG/TOZY1vbMuHYTWGSZ1WbTr2qNbfkkJFhCp+SvNvw6+9pqydAlqxUG 5UwLIXM9xdAtLsq2LugkwdE+P46pkOx92UMOJey4cVS9+a6wSj6YyeyUkvJdR8ZuKE 68aRj3pdvRNTMNXVX5oNClxKqMJS8UrQkf/FZQBUk2j++H8HzrCFQUnZYX9ojpdkNG GkKDjMcEpdT2jDIvU3hmsUiCVjZR1bKaRoiiwxyb+uO3x5O+7ytlujO76sh6xFnb9Z hNeRQGybvXhUA== From: Arnd Bergmann To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Arnd Bergmann Subject: [PATCH net-next v3 09/31] appletalk: use ndo_siocdevprivate Date: Tue, 27 Jul 2021 15:44:55 +0200 Message-Id: <20210727134517.1384504-10-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 appletalk has three SIOCDEVPRIVATE ioctl commands that are broken in compat mode because the passed structure contains a pointer. Change it over to ndo_siocdevprivate for consistency and make it return an error when called in compat mode. This could be fixed if there are still users. Signed-off-by: Arnd Bergmann --- drivers/net/appletalk/ipddp.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) -- 2.29.2 diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c index 51cf5eca9c7f..5566daefbff4 100644 --- a/drivers/net/appletalk/ipddp.c +++ b/drivers/net/appletalk/ipddp.c @@ -54,11 +54,12 @@ static netdev_tx_t ipddp_xmit(struct sk_buff *skb, static int ipddp_create(struct ipddp_route *new_rt); static int ipddp_delete(struct ipddp_route *rt); static struct ipddp_route* __ipddp_find_route(struct ipddp_route *rt); -static int ipddp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); +static int ipddp_siocdevprivate(struct net_device *dev, struct ifreq *ifr, + void __user *data, int cmd); static const struct net_device_ops ipddp_netdev_ops = { .ndo_start_xmit = ipddp_xmit, - .ndo_do_ioctl = ipddp_ioctl, + .ndo_siocdevprivate = ipddp_siocdevprivate, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, }; @@ -268,15 +269,18 @@ static struct ipddp_route* __ipddp_find_route(struct ipddp_route *rt) return NULL; } -static int ipddp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) +static int ipddp_siocdevprivate(struct net_device *dev, struct ifreq *ifr, + void __user *data, int cmd) { - struct ipddp_route __user *rt = ifr->ifr_data; struct ipddp_route rcp, rcp2, *rp; + if (in_compat_syscall()) + return -EOPNOTSUPP; + if(!capable(CAP_NET_ADMIN)) return -EPERM; - if(copy_from_user(&rcp, rt, sizeof(rcp))) + if (copy_from_user(&rcp, data, sizeof(rcp))) return -EFAULT; switch(cmd) @@ -296,7 +300,7 @@ static int ipddp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) spin_unlock_bh(&ipddp_route_lock); if (rp) { - if (copy_to_user(rt, &rcp2, + if (copy_to_user(data, &rcp2, sizeof(struct ipddp_route))) return -EFAULT; return 0;