Re: [PATCH] s390: speedup strn{cpy,len} from user.

From: Arnd Bergmann
Date: Fri Jun 11 2004 - 17:49:39 EST



Andrew Morton <akpm@xxxxxxxx> schrieb am 12.06.2004, 00:19:18:
> Martin Schwidefsky wrote:
> > static inline long
> > strncpy_from_user(char *dst, const char *src, long count)
> > {
> > long res = -EFAULT;
> > might_sleep();
> > - if (access_ok(VERIFY_READ, src, 1))
> > - res = __strncpy_from_user_asm(dst, src, count);
> > + if (access_ok(VERIFY_READ, src, 1)) {
> > + res = __strncpy_from_user_asm(count, dst, src);
> > + }
> > return res;
> > }
>
> Shouldn't the access_ok() check be passed `count', rather than `1'?

No, AFAIU, the logic in strncpy_from_user is that it succeeds for any
string that is limited by either 'count' or a trailing zero or the end
of the user mapping, whichever comes first. This means only one
byte needs to be addressable.

On s390, it doesn't matter anyway because access_ok() is always true,
but the check for access_ok() is the same on all architectures.

Arnd <><
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/