linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: "Pavel V. Panteleev" <panteleev_p@mcst.ru>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: copy_mount_options() problem
Date: Tue, 15 Oct 2019 23:03:07 +0100	[thread overview]
Message-ID: <20191015220307.GA21325@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20191015184034.GN26530@ZenIV.linux.org.uk>

On Tue, Oct 15, 2019 at 07:40:34PM +0100, Al Viro wrote:
> On Tue, Oct 15, 2019 at 09:09:02PM +0300, Pavel V. Panteleev wrote:
> > Hello,
> > 
> > copy_mount_options() checks that data doesn't cross TASK_SIZE boundary. It's
> > not correct. Really it should check USER_DS boudary, because some archs have
> > TASK_SIZE not equal to USER_DS. In this case (USER_DS != TASK_SIZE)
> > exact_copy_from_user() will stop on access_ok() check, if data cross
> > USER_DS, but doesn't cross TASK_SIZE.
> 
> Details of the call chain, please.

FWIW, what I want to do with copy_mount_options() is this:
void *copy_mount_options(const void __user * data)
{
	unsigned offs, size;
	char *copy;

	if (!data)
		return NULL;

	copy = kmalloc(PAGE_SIZE, GFP_KERNEL);
	if (!copy)
		return ERR_PTR(-ENOMEM);

	offs = (unsigned long)data & (PAGE_SIZE - 1);

	if (copy_from_user(copy, data, PAGE_SIZE - offs)) {
		kfree(copy);
		return ERR_PTR(-EFAULT);
	}
	if (offs) {
		if (copy_from_user(copy, data + PAGE_SIZE - offs, offs))
			memset(copy + PAGE_SIZE - offs, 0, offs);
	}
	return copy;
}

which should get rid of any TASK_SIZE references whatsoever, but I really
wonder where have you run into the problem.

  reply	other threads:[~2019-10-15 22:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15 18:09 copy_mount_options() problem Pavel V. Panteleev
2019-10-15 18:40 ` Al Viro
2019-10-15 22:03   ` Al Viro [this message]
2019-10-16  7:39     ` Pavel V. Panteleev
2019-10-16  7:31   ` Pavel V. Panteleev
  -- strict thread matches above, loose matches on Subject: below --
2019-10-15 15:12 Pavel V. Panteleev

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=20191015220307.GA21325@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=panteleev_p@mcst.ru \
    /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).