Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2604999pxk; Sun, 20 Sep 2020 10:01:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz62UPH2GFxleY71J6C6iB3OmpF/3a9+aAAdm5T9XAO2XOqkcp/hZJ/M43ST/l8PzT9oHIG X-Received: by 2002:a17:906:2818:: with SMTP id r24mr48137119ejc.100.1600621309108; Sun, 20 Sep 2020 10:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600621309; cv=none; d=google.com; s=arc-20160816; b=sBTjeABsNha9IIrqlFv35ap5Ge3AS7qiN2pIWrbTrYyQVMI4v9DqGXo9Yd0a4VicV4 CT9W8a6N5QsbRHPLk6IKlaru1gDrCU1QD33T0zvyfOwLRMBB2lPrR0IPCyS27BSBhUgM zx2JsBOBCsxti4TYWRFXehVSNzV/LTVat+PiZACsiEyry3BNgy8cwckeaXHIDgNJXM8e 0JJLydTU8Qj6vSkWl38AXyw6hDn6SuxqwGDVgPit4V7JCm9ZTqY7BnQKbR1RNRBfcjMP jHD/j+PhIecAGF2N9woQR4Ib1d+gzwm40l7Ol8feo5rYFo8m326C88YC9PDfljs5P2xn PS8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2P1mftROBGA0On2MHcXlpTT6yFJHT4WpFIliuZ7qozU=; b=nhgFwQQWUbpVokIUoFA925TgVP674ECWbWM9c6UD24MPkaA2FxRumHOiXmLISmmXA0 P5+6zPh/A16Wa7wWloeikmANkgDrMSEPlh5gZhHGtL5MaNGykbQifdPi/W6dOft9Axrn VXA4u32zSIs4w97qx8B+7sPty+Wcks/NsTT8njcMoq7v2VI8szzqIW9JiuxBLMrnhPrb j/A/wy10roQWL7p2/LIYmeD+gESQ5Yq+3F0HzLXIdxpAvlew5dKa3v2u/BgyZGHPtc4+ SGoJSivAvaaZisV5arO/BXJAZ8DDBAk6ntWhnPfdRJUVnhclGd0G/tlzg+yX6K/rLJF5 f/xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gJKTktW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 l19si6415788edj.152.2020.09.20.10.01.25; Sun, 20 Sep 2020 10:01:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=gJKTktW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1726467AbgITQ7v (ORCPT + 99 others); Sun, 20 Sep 2020 12:59:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:48302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbgITQ7u (ORCPT ); Sun, 20 Sep 2020 12:59:50 -0400 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 0253C2158C for ; Sun, 20 Sep 2020 16:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600621190; bh=x0CbGoy7QDKeuRiDyZ0r+bpumnscmCVOPI/85NlktW8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=gJKTktW4SZM9Nk5DOVt1OrRoD5xvcMTHGvsORGcnvvYrrRwkT7FctEN7F9OgfkMkf go8qh4j37RWcESJvMJRLehEaF3oKhwPYJJdJDts/+toGi7k1LIglAiuuVrdC6I4+Xp /LzZmxNyVgp/8l8nI8i/3m9FhkW6jCz/eC4EQY4Q= Received: by mail-wm1-f48.google.com with SMTP id s13so9863644wmh.4 for ; Sun, 20 Sep 2020 09:59:49 -0700 (PDT) X-Gm-Message-State: AOAM533O4JS3BMumURLQmyyTrgxWDZXOU6w4NiEmG7wGq94a8D4emCOx 3Y9BekiorryK5zsFc0FWAB3bb1xY+5HXH7Gz33Vvxw== X-Received: by 2002:a1c:7e15:: with SMTP id z21mr25730921wmc.21.1600621188572; Sun, 20 Sep 2020 09:59:48 -0700 (PDT) MIME-Version: 1.0 References: <20200919224122.GJ3421308@ZenIV.linux.org.uk> <36CF3DE7-7B4B-41FD-9818-FDF8A5B440FB@amacapital.net> <20200919232411.GK3421308@ZenIV.linux.org.uk> <20200920025745.GL3421308@ZenIV.linux.org.uk> In-Reply-To: <20200920025745.GL3421308@ZenIV.linux.org.uk> From: Andy Lutomirski Date: Sun, 20 Sep 2020 09:59:36 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/9] kernel: add a PF_FORCE_COMPAT flag To: Al Viro Cc: Andy Lutomirski , Christoph Hellwig , Andrew Morton , Jens Axboe , Arnd Bergmann , David Howells , linux-arm-kernel , X86 ML , LKML , "open list:MIPS" , Parisc List , linuxppc-dev , linux-s390 , sparclinux , linux-block , Linux SCSI List , Linux FS Devel , linux-aio , io-uring@vger.kernel.org, linux-arch , Linux-MM , Network Development , keyrings@vger.kernel.org, LSM List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 19, 2020 at 7:57 PM Al Viro wrote: > > On Sat, Sep 19, 2020 at 05:14:41PM -0700, Andy Lutomirski wrote: > > > > 2) have you counted the syscalls that do and do not need that? > > > > No. > > Might be illuminating... > > > > 3) how many of those realistically *can* be unified with their > > > compat counterparts? [hint: ioctl(2) cannot] > > > > There would be no requirement to unify anything. The idea is that > > we'd get rid of all the global state flags. > > _What_ global state flags? When you have separate SYSCALL_DEFINE3(ioctl...) > and COMPAT_SYSCALL_DEFINE3(ioctl...), there's no flags at all, global or > local. They only come into the play when you try to share the same function > for both, right on the top level. ... > > > For ioctl, we'd have a new file_operation: > > > > long ioctl(struct file *, unsigned int, unsigned long, enum syscall_arch); > > > > I'm not saying this is easy, but I think it's possible and the result > > would be more obviously correct than what we have now. > > No, it would not. Seriously, from time to time a bit of RTFS before grand > proposals turns out to be useful. As one example, look at __sys_setsockopt(). It's called for the native and compat versions, and it contains an in_compat_syscall() check. (This particularly check looks dubious to me, but that's another story.) If this were to be done with equivalent semantics without a separate COMPAT_DEFINE_SYSCALL and without in_compat_syscall(), there would need to be some indication as to whether this is compat or native setsockopt. There are other setsockopt implementations in the net stack with more legitimate-seeming uses of in_compat_syscall() that would need some other mechanism if in_compat_syscall() were to go away. setsockopt is (I hope!) out of scope for io_uring, but the situation isn't fundamentally different from read and write.