From: Andrew Morton <akpm@osdl.org>
To: "David S. Miller" <davem@redhat.com>
Cc: linux-arch@vger.kernel.org
Subject: Re: copy_mount_options()
Date: Fri, 20 Aug 2004 14:31:11 -0700 [thread overview]
Message-ID: <20040820143111.3fd0070e.akpm@osdl.org> (raw)
In-Reply-To: <20040820141137.646c349f.davem@redhat.com>
"David S. Miller" <davem@redhat.com> wrote:
>
> On Fri, 20 Aug 2004 13:10:53 -0700
> Andrew Morton <akpm@osdl.org> wrote:
>
> > For some reason, copy_mount_options() is a continual pain in the ass. It
> > just comes up again and again.
> >
> > For this problem I'd suggest we just rip the copy_from_user() out of there
> > and rewrite the function to use byte-at-a-time get_user()s.
>
> I totally agree.
Something like this?
--- 25/fs/namespace.c~copy_mount_options-size-fix Fri Aug 20 14:25:39 2004
+++ 25-akpm/fs/namespace.c Fri Aug 20 14:30:09 2004
@@ -930,7 +930,29 @@ void mark_mounts_for_expiry(struct list_
EXPORT_SYMBOL_GPL(mark_mounts_for_expiry);
-int copy_mount_options (const void __user *data, unsigned long *where)
+/*
+ * Some copy_from_user() implementations do not return the exact number of
+ * bytes remaining to copy on a fault. But copy_mount_options() requires that.
+ */
+
+static long
+exact_copy_from_user(void *to, const void __user *from, unsigned long n)
+{
+ char *t = to;
+ const char __user *f = from;
+ char c;
+
+ while (n) {
+ if (get_user(c, f))
+ break;
+ *t++ = c;
+ f++;
+ n--;
+ }
+ return n;
+}
+
+int copy_mount_options(const void __user *data, unsigned long *where)
{
int i;
unsigned long page;
@@ -952,7 +974,7 @@ int copy_mount_options (const void __use
if (size > PAGE_SIZE)
size = PAGE_SIZE;
- i = size - copy_from_user((void *)page, data, size);
+ i = size - exact_copy_from_user((void *)page, data, size);
if (!i) {
free_page(page);
return -EFAULT;
_
next prev parent reply other threads:[~2004-08-20 21:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-20 20:01 copy_mount_options() David S. Miller
2004-08-20 20:10 ` copy_mount_options() Andrew Morton
2004-08-20 21:11 ` copy_mount_options() David S. Miller
2004-08-20 21:31 ` Andrew Morton [this message]
2004-08-20 21:40 ` copy_mount_options() David S. Miller
2004-08-20 22:47 ` copy_mount_options() Andrew Morton
2004-08-20 23:18 ` copy_mount_options() Anton Blanchard
2004-08-20 23:51 ` copy_mount_options() David S. Miller
2004-08-21 0:07 ` copy_mount_options() Andrew Morton
2004-08-21 7:50 ` copy_mount_options() Rusty Russell
2004-08-20 23:15 ` copy_mount_options() Benjamin Herrenschmidt
2004-08-22 11:50 ` copy_mount_options() Ralf Baechle
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=20040820143111.3fd0070e.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=davem@redhat.com \
--cc=linux-arch@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.