Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2275939ybl; Thu, 29 Aug 2019 06:10:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqx553nejC8sJXnqykjWRvymKSzDPqZcwJ8Gk4wMQIjyCqB4T1vVZMkMwEDkpizVmbqwvRLA X-Received: by 2002:a05:6a00:cd:: with SMTP id e13mr11672383pfj.202.1567084239754; Thu, 29 Aug 2019 06:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567084239; cv=none; d=google.com; s=arc-20160816; b=bri8n4AdMGU3FHwnnH3jKxw/GBPmzq4a5BNzTOGFDunC4IrCo/sFbunP5XMz7XClWR c3cd9YDnY4JILnkdwkA5+S3dnlBPwsI2FD4EDS/ZJXb4iDB42qq/kBDeo3t3h2XO+hv+ nKFUBqSTXlfmZHwCxZNRgVQCjedz+n5zbniZeN6fGqf6osz6ccIpEC7RiLCH0uzgecM9 4P7afq4gJiT5qQsqOP5tl9gmczLhf+Vh4AKbbhSJ0F1TEplxQvun3P2KFRsnT16eJ/XT R22Yqv2uzydkYSr5uhckaujzIZsD3HTlWs51+Owxc1fgjt4tv7hjRbWbZQFf/ov/2yFi wzPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=+pz1tJCvEpXqhYntc4a+eXdQw4YkeZzY/CUqzEnQfhI=; b=CGz33hSr3yb+Obxal5mffWLRL4ezA6JHTNmVehg5T3JUQ2Ccb4RGsayqk8ajrCtd1q D53ma6MkoQagfL5N/cneNBcE24Cw/GVqBDFWK96RypfxW3xbFV/O9IYMt+Nsq+JE75/F Z46t+V41hn8KKZvMTdiyoluFKHz+qQ5SRv/mTYTUSsZg6Mkn3sSfHTrfbBb4awGWOCfE VoIyBAKeEbZUWikWVUFJ8mE/aVRtvFV8YW57FmduhN2ZESQk3gjZZeRS/FYwQjfzKjEy YJ9DBnBmbCZbHItz5xxW+d+BTIcseLVDIhCzxeDc38f2HAeLpsM3RGTw52nyKLGIN1Ne XeAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=VwOF8bMU; 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 a13si1881084pgt.217.2019.08.29.06.10.19; Thu, 29 Aug 2019 06:10:39 -0700 (PDT) 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; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=VwOF8bMU; 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 S1727697AbfH2NFL (ORCPT + 99 others); Thu, 29 Aug 2019 09:05:11 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:34958 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727578AbfH2NFK (ORCPT ); Thu, 29 Aug 2019 09:05:10 -0400 Received: by mail-lf1-f65.google.com with SMTP id h27so2488997lfp.2 for ; Thu, 29 Aug 2019 06:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=+pz1tJCvEpXqhYntc4a+eXdQw4YkeZzY/CUqzEnQfhI=; b=VwOF8bMUMlpcVPjnH7KLm7q9YPGAJyoJCaqTHg0eB7cJNs33HPtWse0a6S+38yOz8O NHVqczdRdynKQIjzWAF9I3YpK+wBqgWsLCV+xSrpqG8v5x5MeuksDGvoajweRjwbjZ5a 38t56VL/f1C5Tbh/lNpCLIQcFzQtYKavA1iaY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=+pz1tJCvEpXqhYntc4a+eXdQw4YkeZzY/CUqzEnQfhI=; b=b4YDrg9NkwdSVlBsh4V4uQOPoESWoB28JUsWA7/EyGfnyzTHEd4hOcv6EFzVs1PRVO B+Y81Blf55cRhJPb6UvmajCh4zgttnh+MFc3uOsm7rKATfi25XAwqdWu/zGzflMz0CS0 wwzUt+WIacbsW+1eiWHCj3Fjxp2V9KmCabuh6D0ZB5v1aJySNcsMEJ7ztnp2QN6J6BIo glJ6uT0HSMjBuTz7+l8+LuLoSFnenKhX8C/lMTc2kgKgEPXCsL/cANBiVIvEoc93FkYi 12JOty48pZ0QovZ4xu0pYZJPovPgZweGhTjonMwEKbYX+qDoTLkUeo3j76nN0fd8XgL2 5y4A== X-Gm-Message-State: APjAAAVcM/1HyvvOObiU/aBhStTy5UQC2lznShRIVrYSgyMhpzRA9zYJ nbnmqmmDcXWtsMYgo19boWvXbQ== X-Received: by 2002:a19:ef05:: with SMTP id n5mr6063058lfh.192.1567083908173; Thu, 29 Aug 2019 06:05:08 -0700 (PDT) Received: from [172.16.11.28] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id j23sm346381ljc.6.2019.08.29.06.05.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Aug 2019 06:05:07 -0700 (PDT) Subject: Re: [PATCH RESEND v11 7/8] open: openat2(2) syscall To: Aleksa Sarai , Daniel Colascione Cc: Al Viro , Jeff Layton , "J. Bruce Fields" , Arnd Bergmann , David Howells , Shuah Khan , Shuah Khan , Christian Brauner , Eric Biederman , Andy Lutomirski , Andrew Morton , Alexei Starovoitov , Kees Cook , Jann Horn , Tycho Andersen , David Drysdale , Chanho Min , Oleg Nesterov , Aleksa Sarai , Linus Torvalds , containers@lists.linux-foundation.org, linux-alpha@vger.kernel.org, Linux API , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linux FS Devel , linux-ia64@vger.kernel.org, linux-kernel , "open list:KERNEL SELFTEST FRAMEWORK" , linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, sparclinux@vger.kernel.org References: <20190820033406.29796-1-cyphar@cyphar.com> <20190820033406.29796-8-cyphar@cyphar.com> <20190829121527.u2uvdyeatme5cgkb@yavin> From: Rasmus Villemoes Message-ID: <899401fa-ff0a-2ce9-8826-09904efab2d2@rasmusvillemoes.dk> Date: Thu, 29 Aug 2019 15:05:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190829121527.u2uvdyeatme5cgkb@yavin> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/08/2019 14.15, Aleksa Sarai wrote: > On 2019-08-24, Daniel Colascione wrote: >> Why pad the structure when new functionality (perhaps accommodated via >> a larger structure) could be signaled by passing a new flag? Adding >> reserved fields to a structure with a size embedded in the ABI makes a >> lot of sense --- e.g., pthread_mutex_t can't grow. But this structure >> can grow, so the reservation seems needless to me. > > Quite a few folks have said that ->reserved is either unnecessary or > too big. I will be changing this, though I am not clear what the best > way of extending the structure is. If anyone has a strong opinion on > this (or an alternative to the ones listed below), please chime in. I > don't have any really strong attachment to this aspect of the API. > > There appear to be a few ways we can do it (that all have precedence > with other syscalls): > > 1. Use O_* flags to indicate extensions. > 2. A separate "version" field that is incremented when we change. > 3. Add a size_t argument to openat2(2). > 4. Reserve space (as in this patchset). > > (My personal preference would be (3), followed closely by (2).) 3, definitely, and instead of having to invent a new scheme for every new syscall, make that the default pattern by providing a helper int __copy_abi_struct(void *kernel, size_t ksize, const void __user *user, size_t usize) { size_t copy = min(ksize, usize); if (copy_from_user(kernel, user, copy)) return -EFAULT; if (usize > ksize) { /* maybe a separate "return user_is_zero(user + ksize, usize - ksize);" helper */ char c; user += ksize; usize -= ksize; while (usize--) { if (get_user(c, user++)) return -EFAULT; if (c) return -EINVAL; } } else if (ksize > usize) { memset(kernel + usize, 0, ksize - usize); } return 0; } #define copy_abi_struct(kernel, user, usize) \ __copy_abi_struct(kernel, sizeof(*kernel), user, usize) > Both (1) and (2) have the problem that the "struct version" is inside > the struct so we'd need to copy_from_user() twice. This isn't the end of > the world, it just feels a bit less clean than is ideal. (3) fixes that > problem, at the cost of making the API slightly more cumbersome to use > directly (though again glibc could wrap that away). I don't see how 3 is cumbersome to use directly. Userspace code does struct openat_of_the_day args = {.field1 = x, .field3 = y} and passes &args, sizeof(args). What does glibc need to do beyond its usual munging of the userspace ABI registers to the syscall ABI registers? Rasmus