Re: mount on tmpfs failing to parse context option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux