Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1355753ybz; Thu, 16 Apr 2020 07:46:11 -0700 (PDT) X-Google-Smtp-Source: APiQypKmoP60Dm45fxA0PJojXz4GejpndmYCieT8JZJX1Yy/NNsIqOg7tCjPIEfN5yMgPOQ29nU1 X-Received: by 2002:aa7:c90d:: with SMTP id b13mr13889073edt.14.1587048371472; Thu, 16 Apr 2020 07:46:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587048371; cv=none; d=google.com; s=arc-20160816; b=hYVMFRihVkKS7fya5RtU6vnLVmp1zeew9i5bbAbCMKqXfZYr20uc8+petdzDw6MxMp yAB6lpEV68gMFld88oJBnXefOIMVpr+Vx1pfVZfUTyIn3u2h0EUs6TOC33M+fx9AvoMg BxLDanZqJ9XYDsV+nTLZmlzZKnnza3I7BxdVLUZNoxhzRXeD9Vl+ssgVycXogzTcpIqs ghE9DNmwpbOefkTvIFrQKjKyJqVa8+OTRcG46eWW7s+d7uMcB1hB8w0Y8LsklTIQvEQP gdn5x6bKd9rjug3h/lY1uSBe0dOwq7UjpD+STNXcdrj0nMzVaLmft51Yx0uIl/TqsI9E G5GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:dkim-signature; bh=MWF7qeFYGcwjfe4u/XIKlxtmBa+zuBoTmVw0MA2bPLk=; b=dwdJQUHtYAG63sO4t92I1KH/3dy39iwrnId6DXhnY09XceysxjRe3wnSJgfaWrjGqX 5Dq+aEhA9ME/fd0WkRSA4OO7ABckVp9wvhrzuLN86CVX29U79TUbdbqgaJrd+kJrP2Qj vC9EYdpccHnCI4xpXMrrLyrop3WSo2KD5R9qrOKm7KMsYVlvgq3rnelsoXcBUdq5lQc5 A1gXnxUlvfGaltISd1aXrWdNjcEfRCR5K/Tv+Qep/S6Sma+bGU/+9BJNcJktSsHeE7hp U7RGckSs1jdH4+K45FVpuQBtICuwakQbgb44LvR56ah9x/G97Mqzca0krE5qCXuQzUBE EDsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Kj33VeBH; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m9si13563280eda.117.2020.04.16.07.45.48; Thu, 16 Apr 2020 07:46:11 -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=@redhat.com header.s=mimecast20190719 header.b=Kj33VeBH; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394545AbgDPOny (ORCPT + 99 others); Thu, 16 Apr 2020 10:43:54 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:29637 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730302AbgDPOnu (ORCPT ); Thu, 16 Apr 2020 10:43:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587048229; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MWF7qeFYGcwjfe4u/XIKlxtmBa+zuBoTmVw0MA2bPLk=; b=Kj33VeBHwI8PgzJfC4J+BOyht29ICVvsdy/GgOtSkS6uB+ACWBSIB3GpP4kXF7uVc0sljv eMK9JROD7C0+ZVdZFgXimAAKwDdEWjzpo2xYcNjxkvA9QrZR8zRtaAB6eIUVuGRE+Nprxn O8MQCfNS+y8F2DC7378ONAzmBSmTYWc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-94-wJELbwD0OO2EOCILcZJ6Yg-1; Thu, 16 Apr 2020 10:43:45 -0400 X-MC-Unique: wJELbwD0OO2EOCILcZJ6Yg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2AD988017FD; Thu, 16 Apr 2020 14:43:44 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-113-198.ams2.redhat.com [10.36.113.198]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A07A95D9E2; Thu, 16 Apr 2020 14:43:42 +0000 (UTC) From: Florian Weimer To: Miklos Szeredi Cc: Al Viro , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, Eric Sandeen Subject: Re: [PATCH] vfs: add faccessat2 syscall References: <20200416143532.11743-1-mszeredi@redhat.com> Date: Thu, 16 Apr 2020 16:43:40 +0200 In-Reply-To: <20200416143532.11743-1-mszeredi@redhat.com> (Miklos Szeredi's message of "Thu, 16 Apr 2020 16:35:32 +0200") Message-ID: <87a73bcwyr.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Miklos Szeredi: > POSIX defines faccessat() as having a fourth "flags" argument, while the > linux syscall doesn't have it. Glibc tries to emulate AT_EACCESS and > AT_SYMLINK_NOFOLLOW, but AT_EACCESS emulation is broken. > > Add a new faccessat(2) syscall with the added flags argument and implement > both flags. > > The value of AT_EACCESS is defined in glibc headers to be the same as > AT_REMOVEDIR. Use this value for the kernel interface as well, together > with the explanatory comment. Thanks a lot for this! > +long do_faccessat(int dfd, const char __user *filename, int mode, int flags) > +{ > + const struct cred *old_cred = NULL; > + struct path path; > + struct inode *inode; > + int res; > + unsigned int lookup_flags = LOOKUP_FOLLOW; > + > + if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */ > + return -EINVAL; > + > + if (flags & ~(AT_EACCESS | AT_SYMLINK_NOFOLLOW)) > + return -EINVAL; Should this accept AT_EMPTY_PATH as well? (I can't comment on the rest of the logic of the patch.) > diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h > index ca88b7bce553..2f86b2ad6d7e 100644 > --- a/include/uapi/linux/fcntl.h > +++ b/include/uapi/linux/fcntl.h > @@ -84,10 +84,20 @@ > #define DN_ATTRIB 0x00000020 /* File changed attibutes */ > #define DN_MULTISHOT 0x80000000 /* Don't remove notifier */ > > +/* > + * The constants AT_REMOVEDIR and AT_EACCESS have the same value. AT_EACCESS is > + * meaningful only to faccessat, while AT_REMOVEDIR is meaningful only to > + * unlinkat. The two functions do completely different things and therefore, > + * the flags can be allowed to overlap. For example, passing AT_REMOVEDIR to > + * faccessat would be undefined behavior and thus treating it equivalent to > + * AT_EACCESS is valid undefined behavior. > + */ > #define AT_FDCWD -100 /* Special value used to indicate > openat should use the current > working directory. */ > #define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */ > +#define AT_EACCESS 0x200 /* Test access permitted for > + effective IDs, not real IDs. */ > #define AT_REMOVEDIR 0x200 /* Remove directory instead of > unlinking file. */ > #define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */ I can confirm that this is what glibc does, ofr better or worse. Thanks, Florian