linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Dmitry Kasatkin' <dmitry.kasatkin@gmail.com>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	linux-security-module <linux-security-module@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: Mount options may be silently discarded
Date: Mon, 28 Sep 2020 14:36:21 +0000	[thread overview]
Message-ID: <87bb66c2a7f94bd1ab768a8160e48e39@AcuMS.aculab.com> (raw)
In-Reply-To: <CACE9dm_eypZ4wn8PpYYCYNuM501_M-8pH7by=U-6hOmJCwuxig@mail.gmail.com>

From: Dmitry Kasatkin
> Sent: 28 September 2020 15:03
> 
> "copy_mount_options" function came to my eyes.
> It splits copy into 2 pieces - over page boundaries.
> I wonder what is the real reason for doing this?
> Original comment was that we need exact bytes and some user memcpy
> functions  do not return correct number on page fault.
> 
> But how would all other cases work?
> 
> https://elixir.bootlin.com/linux/latest/source/fs/namespace.c#L3075
> 
> if (size != PAGE_SIZE) {
>        if (copy_from_user(copy + size, data + size, PAGE_SIZE - size))
>             memset(copy + size, 0, PAGE_SIZE - size);
> }
> 
> This looks like some options may be just discarded?
> What if it is an important security option?
> 
> Why it does not return EFAULT, but just memset?

The user doesn't supply the transfer length, the max size
is a page.
Since the copy can only start to fail on a page boundary
reading in two pieces is exactly the same as knowing the
address at which the transfer started to fail.

Since the actual mount options can be much smaller than
a page (and usually are) zero-filling is best.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2020-09-28 14:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 14:02 Mount options may be silently discarded Dmitry Kasatkin
2020-09-28 14:36 ` David Laight [this message]
2020-09-28 18:00   ` Dmitry Kasatkin
2020-09-28 18:17     ` Al Viro

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=87bb66c2a7f94bd1ab768a8160e48e39@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).