All of lore.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Jeff Layton <jeff.layton@primarydata.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
	linux-fsdevel@vger.kernel.org,
	Benjamin Coddington <bcodding@redhat.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Linux Containers <containers@lists.linux-foundation.org>
Subject: Re: [RFC][PATCH] locks: Allow disabling mandatory locking at compile time
Date: Wed, 11 Nov 2015 17:22:33 -0600	[thread overview]
Message-ID: <876118ruiu.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <20151111174401.5778153c@tlielax.poochiereds.net> (Jeff Layton's message of "Wed, 11 Nov 2015 17:44:01 -0500")

Jeff Layton <jeff.layton@primarydata.com> writes:

> On Wed, 11 Nov 2015 15:26:07 -0500
> "J. Bruce Fields" <bfields@fieldses.org> wrote:
>
>> On Wed, Nov 11, 2015 at 11:49:20AM -0600, Eric W. Biederman wrote:
>> > 
>> > Mandatory locking appears to be almost unused and buggy and there
>> > appears no real interest in doing anything with it.  Since effectively
>> > no one uses the code and since the code is buggy let's allow it to be
>> > disabled at compile time.  I would just suggest removing the code but
>> > undoubtedly that will break some piece of userspace code somewhere.
>> > 
>> > For the distributions that don't care about this piece of code
>> > this gives a nice starting point to make mandatory locking go away.
>> > 
>> > Cc: Benjamin Coddington <bcodding@redhat.com>
>> > Cc: Dmitry Vyukov <dvyukov@google.com>
>> > Cc: Jeff Layton <jeff.layton@primarydata.com>
>> > Cc: J. Bruce Fields <bfields@fieldses.org>
>> > Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
>> > ---
>> > 
>> > A piece of userspace software having problematic interactions with
>> > mandatory locking recently came up as an issue
>> 
>> Is there any more interesting story there?

Only that I overlooked them when implementing user namespace support for
mounting filesystems so it is currently possible to without privilege to
mount tmpfs with mandatory locking enabled and pass a file descriptor to
a daemon that was not expecting them.  Causing nice denial of service
attacks.

So I need to decide what to do with mandatory locking in user
namespaces.

As the consensus of this thread is that users of mandatory locking are
as rare as hen's teeth I can just not allow mandatory locking if you
something is being mounted just user namespace permissions.  If users
would be more wide spread I would need to figure out how to avoid breaking
users.

>> > and I am wondering if there are enough people actually using and
>> > interested in mandatory locking that it makes sense to push people to
>> > support it, or if mandatory locking should be confined to it's own
>> > little corner of existence where it can wither and die.
>> 
>> I hate mandatory locking and would be delighted, but my opinion probably
>> shouldn't get too much weight.
>> 
>
> Ditto...It's really hard to believe that anyone uses them, given the
> well documented races in the Linux implementation.

>> > From what little I can glean we want to discourage people from using
>> > mandatory locking and to let it wither and die.  A Kconfig option that
>> > allows mandatory locking to be disabled at compile time seems like the
>> > first step in making that happen.  Perhaps in a decade or so when all
>> > linux distributions are setting the option we can remove the code.
>> > 
>> > Does anyone know of any real world use cases of mandatory locking?
>> 
>> Isn't byte-range locking on Windows mandatory?  So Samba people might be
>> the ones to talk to.  (Or Wine?  Or anyone else doing Windows
>> interoperability.)
>> 
>> My suspicion would be that the semantics they need are different enough
>> from what we support that we'd be better off ignoring it and starting
>> over from scratch anyway.  But I could be wrong.
>> 
>
> Windows BRLs are mandatory but they have totally different semantics.
>
> I think there is little reason to keep POSIX mandatory locks for
> windows emulation purposes. I'm pretty sure Samba doesn't rely on them,
> for instance, given that you have to use a funky mode bit combo to
> enable them.
>
> This patch seems like a logical step to me. I'll review it soon and
> will plan to queue it up for v4.5 unless there are objections between
> now and the next merge window.

Thanks.

Given the general concensus of this thread it looks like we will also
want this incremental patch to deal with the user namespace case.

From: "Eric W. Biederman" <ebiederm@xmission.com>
Date: Wed, 11 Nov 2015 17:18:07 -0600
Subject: [PATCH] locks: Don't allow mounts in user namespaces to enable mandatory locking

Since no one uses mandatory locking and files with mandatory locks can
cause problems don't allow them in user namespaces.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 fs/namespace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index dee44b4791f0..95a349d5003d 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1589,7 +1589,7 @@ static inline bool may_mandlock(void)
 #ifndef	CONFIG_MANDATORY_FILE_LOCKING
 	return false;
 #endif
-	return true;
+	return capable(CAP_SYS_ADMIN);
 }
 
 /*
-- 
2.2.1


  parent reply	other threads:[~2015-11-11 23:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-11 17:49 [RFC][PATCH] locks: Allow disabling mandatory locking at compile time Eric W. Biederman
2015-11-11 17:49 ` Eric W. Biederman
2015-11-11 20:26 ` J. Bruce Fields
     [not found]   ` <20151111202607.GD29410-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2015-11-11 22:44     ` Jeff Layton
2015-11-11 22:44   ` Jeff Layton
2015-11-11 22:46     ` Jeremy Allison
     [not found]     ` <20151111174401.5778153c-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2015-11-11 22:46       ` Jeremy Allison via Containers
2015-11-11 23:22       ` Eric W. Biederman
2015-11-11 23:22     ` Eric W. Biederman [this message]
2015-11-12  1:33       ` J. Bruce Fields
     [not found]         ` <20151112013311.GA32064-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2015-11-12  1:55           ` Jeff Layton
     [not found]       ` <876118ruiu.fsf-JOvCrm2gF+uungPnsOpG7nhyD016LWXt@public.gmane.org>
2015-11-12  1:33         ` J. Bruce Fields
2015-11-16 14:58         ` Jeff Layton
2015-11-16 14:58           ` Jeff Layton
     [not found]           ` <20151116095841.0f620a5c-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2015-11-16 21:34             ` Eric W. Biederman
2015-11-16 21:34           ` Eric W. Biederman
     [not found] ` <876118v333.fsf-JOvCrm2gF+uungPnsOpG7nhyD016LWXt@public.gmane.org>
2015-11-11 20:26   ` J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=876118ruiu.fsf@x220.int.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=bcodding@redhat.com \
    --cc=bfields@fieldses.org \
    --cc=containers@lists.linux-foundation.org \
    --cc=dvyukov@google.com \
    --cc=jeff.layton@primarydata.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.