All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Ian Kent <raven@themaw.net>, Karel Zak <kzak@redhat.com>
Cc: Hugh Dickins <hughd@google.com>,
	Laura Abbott <labbott@redhat.com>,
	David Howells <dhowells@redhat.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Linux-MM <linux-mm@kvack.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-fsdevel@vger.kernel.org
Subject: Re: mount on tmpfs failing to parse context option
Date: Tue, 8 Oct 2019 12:51:02 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LSU.2.11.1910081219210.1204@eggly.anvils> (raw)
In-Reply-To: <20191008125610.s4fgnnba7yhclb3z@10.255.255.10>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 3048 bytes --]

On Tue, 8 Oct 2019, Karel Zak wrote:
> On Tue, Oct 08, 2019 at 08:38:18PM +0800, Ian Kent wrote:
> > > That's because the options in shmem_parse_options() are
> > > "size=4G,nr_inodes=0", which indeed looks like an attempt to
> > > retroactively limit size; but the user never asked "size=4G" there.
> > 
> > I believe that's mount(8) doing that.
> > I don't think it's specific to the new mount api.
> > 
> > AFAIK it's not new but it does mean the that things that come
> > through that have been found in mtab by mount(8) need to be
> > checked against the current value before failing or ignored if
> > changing them is not allowed.
> > 
> > I wonder if the problem has been present for quite a while but
> > gone unnoticed perhaps.
> > 
> > IIUC the order should always be command line options last and it
> > must be that way to honour the last specified option takes
> > precedence convention.
> > 
> > I thought this was well known, but maybe I'm wrong ... and TBH
> > I wasn't aware of it until recently myself.
> 
> Yep, the common behavior is "the last option wins". See man mount,
> remount option:
> 
>   remount  functionality  follows  the standard way the mount command
>   works with options from fstab.  This means that mount does not read
>   fstab (or mtab) only when both device and dir are specified.
> 
>         mount -o remount,rw /dev/foo /dir
> 
>   After this call all old mount options are replaced and arbitrary
>   stuff from fstab (or mtab) is ignored, except the loop= option which
>   is  internally  generated  and  maintained by the mount command.
> 
>         mount -o remount,rw  /dir
> 
>   After  this call, mount reads fstab and merges these options with
>   the options from the command line (-o).  If no mountpoint is found
>   in fstab, then a remount with unspeci‐ fied source is allowed.
> 
> 
> If you do not like this classic behavior than recent mount(8) versions
> provide --options-mode={ignore,append,prepend,replace} to keep it in
> your hands.

Ian, Karel, many thanks for your very helpful education.
I've not yet digested all of it, but the important thing is...

Yes, you're right: my unexpectedly failing remount sequence fails
equally on a v5.3 kernel, and I'll hazard a guess that it has failed
like that ever since v2.4.8.  I just never noticed (and nobody else
ever complained) until I tried testing the new mount API: which at
least has the courtesy to put an error message reflecting the final
decision in dmesg, when the older kernels just silently EINVALed.

(And it's not impossible to remount thereafter: one just has to add
a "size=0" into the options, to allow the other options through.)

So, I've no more worries for v5.4 tmpfs mount, and if there's anything
that can be improved, that's a background job for me to look into later,
once I've spent more time understanding the info you've given me.

And Laura has confirmed that Al's security_sb_eat_lsm_opts() patch
fixes the "context" issue: thanks.

Hugh

  reply	other threads:[~2019-10-08 19:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-30 16:07 mount on tmpfs failing to parse context option Laura Abbott
2019-10-07 14:45 ` Laura Abbott
2019-10-08  0:50   ` Hugh Dickins
2019-10-08  0:50     ` Hugh Dickins
2019-10-08  1:26     ` Al Viro
2019-10-08 16:33       ` Laura Abbott
2019-10-08 12:38     ` Ian Kent
2019-10-08 12:52       ` Ian Kent
2019-10-08 12:56       ` Karel Zak
2019-10-08 19:51         ` Hugh Dickins [this message]
2019-10-08 19:51           ` Hugh Dickins

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=alpine.LSU.2.11.1910081219210.1204@eggly.anvils \
    --to=hughd@google.com \
    --cc=dhowells@redhat.com \
    --cc=kzak@redhat.com \
    --cc=labbott@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=raven@themaw.net \
    --cc=viro@zeniv.linux.org.uk \
    /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.