All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: "David S. Miller" <davem@redhat.com>
Cc: anton@samba.org, linux-arch@vger.kernel.org, rusty@rustcorp.com.au
Subject: Re: copy_mount_options()
Date: Fri, 20 Aug 2004 17:07:12 -0700	[thread overview]
Message-ID: <20040820170712.68e4cda9.akpm@osdl.org> (raw)
In-Reply-To: <20040820165133.67df8d1b.davem@redhat.com>

"David S. Miller" <davem@redhat.com> wrote:
>
> On Sat, 21 Aug 2004 09:18:33 +1000
> Anton Blanchard <anton@samba.org> wrote:
> 
> > I too hate that interface, Im continually getting it wrong. It would be
> > nice to remove the possibility of having similar such subtle bugs.
> 
> I agree.
> 
> There used to be clever code that would truncate the pipe write
> and stuff like that, and TCP even used to do something similar
> at one point.  But I go look now and neither of them do that
> any more.
> 
> It would even make the kernel smaller because all of these silly:
> 
> 	return copy_*_user(...) ? -EFAULT : 0;
> 
> would just expand to a direct use of the return value.
> 
> So many arch user copy routines would have enormous amounts
> of complexity removed, and I saw this quite well when doing
> the sparc64 stuff I did yesterday.

I'm all for it.  I'll sneak the below patch into -mm, see what breaks.

It's a bit weird that the usercopy functions return unsigned long.  If they
are to return -EFAULT they really should be changed to return an int.

--- 25/arch/i386/lib/usercopy.c~usercopy-return-EFAULT	Fri Aug 20 17:04:37 2004
+++ 25-akpm/arch/i386/lib/usercopy.c	Fri Aug 20 17:05:52 2004
@@ -560,14 +560,14 @@ survive:
 			to += len;
 			n -= len;
 		}
-		return n;
+		return n ? -EFAULT : 0;
 	}
 #endif
 	if (movsl_is_ok(to, from, n))
 		__copy_user(to, from, n);
 	else
 		n = __copy_user_intel(to, from, n);
-	return n;
+	return n ? -EFAULT : 0;
 }
 
 unsigned long
@@ -577,7 +577,7 @@ __copy_from_user_ll(void *to, const void
 		__copy_user_zeroing(to, from, n);
 	else
 		n = __copy_user_zeroing_intel(to, from, n);
-	return n;
+	return n ? -EFAULT : 0;
 }
 
 /**
@@ -599,7 +599,7 @@ copy_to_user(void __user *to, const void
 	might_sleep();
 	if (access_ok(VERIFY_WRITE, to, n))
 		n = __copy_to_user(to, from, n);
-	return n;
+	return n ? -EFAULT : 0;
 }
 EXPORT_SYMBOL(copy_to_user);
 
@@ -627,6 +627,6 @@ copy_from_user(void *to, const void __us
 		n = __copy_from_user(to, from, n);
 	else
 		memset(to, 0, n);
-	return n;
+	return n ? -EFAULT : 0;
 }
 EXPORT_SYMBOL(copy_from_user);
_

  reply	other threads:[~2004-08-21  0:03 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     ` copy_mount_options() Andrew Morton
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               ` Andrew Morton [this message]
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=20040820170712.68e4cda9.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=anton@samba.org \
    --cc=davem@redhat.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /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.