From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44186 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750934AbeFAImR (ORCPT ); Fri, 1 Jun 2018 04:42:17 -0400 From: David Howells In-Reply-To: References: <152720672288.9073.9868393448836301272.stgit@warthog.procyon.org.uk> <152720691829.9073.10564431140980997005.stgit@warthog.procyon.org.uk> To: Amir Goldstein Cc: dhowells@redhat.com, Al Viro , linux-fsdevel , linux-afs@lists.infradead.org, linux-kernel , linux-api@vger.kernel.org Subject: Re: [PATCH 30/32] vfs: Allow cloning of a mount tree with open(O_PATH|O_CLONE_MOUNT) [ver #8] MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7263.1527842535.1@warthog.procyon.org.uk> Date: Fri, 01 Jun 2018 09:42:15 +0100 Message-ID: <7264.1527842535@warthog.procyon.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Amir Goldstein wrote: > Reject O_NON_RECURSIVE without O_CLONE_MOUNT? Yes, I should add that. > I am not sure what are the consequences of opening O_PATH with old kernel > and getting an open file, can't think of anything bad. > Can the same be claimed for O_PATH|O_CLONE_MOUNT? Yes, actually, there can be consequences. Some files have side effects. Think open("/dev/foobar", O_PATH). > Wouldn't it be better to apply the O_TMPFILE kludge to the new > open flag, so that apps can check if O_CLONE_MOUNT feature is supported > by kernel? Ugh. The problem is that the O_TMPFILE kludge can't be done because O_PATH currently just masks off any bits it's not interested in rather than giving an error. Even the O_TMPFILE kludge doesn't protect you against someone having set random unassigned bits when testing on a kernel that didn't support it. And this bit: /* * Clear out all open flags we don't know about so that we don't report * them in fcntl(F_GETFD) or similar interfaces. */ flags &= VALID_OPEN_FLAGS; is just plain wrong. Effectively, it allows userspace to set random reserved bits without consequences. It should give an error instead. Probably we should really replace open() and openat() both before we can allocate any further open flags. David