Received: by 10.223.176.46 with SMTP id f43csp403832wra; Thu, 18 Jan 2018 19:28:15 -0800 (PST) X-Google-Smtp-Source: ACJfBoslP4USDtYVWbu+m3mowypRJyfH3USZeIGanJDJi5S/IjtVJSYbIWj5HcBBjYVHFGBoH/BT X-Received: by 10.99.103.198 with SMTP id b189mr15711068pgc.20.1516332495200; Thu, 18 Jan 2018 19:28:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516332495; cv=none; d=google.com; s=arc-20160816; b=qU8fGzL3TaNtQjt7E6Ur6EkggjKiX4mXiHoZBBSdyLcpc07HbiknTPYx9h1pyDM69c SbGM+MqnHX+P+z8e+NShgN/+uVqYQVK9Knj5l3FCB8IkYQUBTjpjHKE6zAjhuQRHuQnu NCpPBj2AxCihhl6aGz/3hpt3DLufQgyZZjp2kGYFdRkqfr+qdfcm7bSMuqIDh7cC1SQJ BJeg639fQPtbiQ2yLvLeIaCcfCjx2NIFT8LvCnkI9/q6SM5XkPLLPrVpQ5c60PdqBj2I Hbo4v1P29ZTKf4sHxR66UZ1HeeTzXoNKqZTZHR0upopF+pdaR2Nl5elKX3wbkApTG9F/ WArw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=N6kgV7QNapOICetwLNsuTZhwuHD16mhETOgJ2cbYL/c=; b=I+9nRO+bRB+q+tuK1iyC3JOonflmFStVLOh5l5KLWc9jxKgX9zIF+xWqGaCU1GYkR/ UgEcDXzyy3MECFVZh3owsaYCffya9d2nUq4gSY920D+sM1jlCn8UUk3oNUz9awzXl0PI n0jxTrkV/Mn7G9WSEDSSZjZhzoHGAfFaaU8SYh1K5Z1BEJ9/QUHSyZKwfzta4A2npeOW e/B4TWtN0TxkWYTWW8rYLaoe2xzVjA8qtd6z+hb4bIUYU3GCFlvRVpMynQoAIOxDckAq APy6Mcs+vX9fCWe/2AFzqfdS3fZLV+ErWhqQ/ToyujJgjXIQibtBPv0sNCoDw8D7L1KD sKVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c64si7492323pga.513.2018.01.18.19.28.00; Thu, 18 Jan 2018 19:28:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932405AbeASD1f (ORCPT + 99 others); Thu, 18 Jan 2018 22:27:35 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:37760 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754836AbeASD1a (ORCPT ); Thu, 18 Jan 2018 22:27:30 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1ecNKq-0004Kj-0d; Fri, 19 Jan 2018 03:27:20 +0000 Date: Fri, 19 Jan 2018 03:27:19 +0000 From: Al Viro To: Network Development Cc: Dan Williams , Linux Kernel Mailing List , linux-arch@vger.kernel.org, Andi Kleen , Kees Cook , kernel-hardening@lists.openwall.com, Greg Kroah-Hartman , the arch/x86 maintainers , Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner , Andrew Morton , Alan Cox , David Miller , Linus Torvalds , Ralf Baechle Subject: Re: [RFC][PATCH] get rid of the use of set_fs() (by way of kernel_recvmsg()) in sunrpc Message-ID: <20180119032719.GG13338@ZenIV.linux.org.uk> References: <1516198646.4184.13.camel@linux.intel.com> <20180117185232.GW13338@ZenIV.linux.org.uk> <20180118030634.GY13338@ZenIV.linux.org.uk> <20180118044302.GZ13338@ZenIV.linux.org.uk> <20180118193156.GC13338@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180118193156.GC13338@ZenIV.linux.org.uk> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 18, 2018 at 07:31:56PM +0000, Al Viro wrote: > * SIOCADDRT/SIOCDELRT in compat ioctls To bring back a question I'd asked back in October - what do we do about SIOC...RT compat? To recap: * AF_INET sockets expect struct rtentry; it differs between 32bit and 64bit, so routing_ioctl() in net/socket.c is called from compat_sock_ioctl_trans() and does the right thing. All proto_ops instances with .family = PF_INET (and only they) have inet_ioctl() as ->ioctl(), and end up with ip_rt_ioctl() called for native ones. Three of those have ->compat_ioctl() set to inet_compat_ioctl(), the rest have it NULL. In any case, inet_compat_ioctl() ignores those, leaving them to compat_sock_ioctl_trans() to pick up. * for AF_INET6 the situation is similar, except that they use struct in6_rtmsg. Compat is also dealt with in routing_ioctl(). inet6_ioctl() for all such proto_ops (and only those), ipv6_route_ioctl() is what ends up handling the native ones. No ->compat_ioctl() in any of those. * AF_PACKET sockets expect struct rt_entry and actually bounce the native calls to inet_ioctl(). No ->compat_ioctl() there, but routing_ioctl() in net/socket.c does the right thing. * AF_APPLETALK sockets expect struct rt_entry. Native handled in atrtr_ioctl(); there is ->compat_ioctl(), but it ignores those ioctls, so we go through the conversion in net/socket.c. Also happens to work correctly. * ax25, ipx, netrom, rose and x25 use structures of their own, and those structures have identical layouts on 32bit and 64bit. x25 has ->compat_ioctl() that does the right thing (bounces to native), the rest either have ->compat_ioctl() ignoring those ioctls (ipx) or do not have ->compat_ioctl() at all. That ends up with generic code picking those and buggering them up - routing_ioctl() assumes that we want either in6_rtmsg (ipv6) or rtentry (everything else). Unfortunately, in case of these protocols we should just leave the suckers alone. Back then Ralf has verified that the bug exists and said he'd put together a fix. Looks like that fix has fallen through the cracks, though. * all other protocols fail those; usually with ENOTTY, except for AF_QIPCRTR that fails with EINVAL. Either way, compat is not an issue. Note that handling of SIOCADDRT on e.g. raw ipv4 sockets from 32bit process is convoluted as hell. The call chain is compat_sys_ioctl() compat_sock_ioctl() inet_compat_ioctl() compat_raw_ioctl() => -ENOIOCTLCMD, possibly by way of ipmr_compat_ioctl() compat_sock_ioctl_trans() routing_ioctl() [conversion done here] sock_do_ioctl() inet_ioctl() ip_rt_ioctl() A lot of those are method calls, BTW, and the overhead on those has just grown... Does anybody have objections against the following? 1) Somewhere in net/core (or net/compat.c, for that matter) add int compat_get_rtentry(struct rtentry *r, struct rtentry32 __user *p); 2) In inet_compat_ioctl() recognize SIOC{ADD,DEL}RT and do err = compat_get_rtentry(&r, (void __user *)arg); if (!err) err = ip_rt_ioctl(...) return err; 3) Add inet_compat_ioctl() as ->compat_ioctl in all PF_INET proto_ops. 4) Lift copyin from atrtr_ioctl() to atalk_ioctl(), teach atalk_compat_ioctl() about these ioctls (using compat_get_rtentry() and atrtr_ioctl(), that is). 5) Add ->compat_ioctl() to AF_PACKET, let it just call inet_compat_ioctl() for those two. 6) Lift copyin from ipv6_route_ioctl() to inet6_ioctl(). Add inet6_compat_ioctl() that would recognize those two, do compat copyin and call ipv6_route_ioctl(). Make it ->compat_ioctl for all PF_INET6 proto_ops. 7) Tell compat_sock_ioctl_trans() to move these two into the "just call sock_do_ioctl()" group of cases. Or, with Ralf's fix, just remove these two cases from compat_sock_ioctl_trans() completely. Either way, routing_ioctl() becomes dead code and can be removed.