mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: linux@horizon.com
To: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] s390: speedup strn{cpy,len}_from_user.
Date: 11 Jun 2004 23:49:01 -0000	[thread overview]
Message-ID: <20040611234901.18482.qmail@science.horizon.com> (raw)

>>  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'?

This deserves a comment, but no.

"count" is the maximum length of the string, not the actual length.
If you passed it to access_ok(), you'd falsely EFAULT a short string
near the end of the address space.

Assuming that there's a guard page at the end of the user address space,
__strncpy_from_user_asm is guaranteed to hit it as part of normal
operations, and will get the fault.

             reply	other threads:[~2004-06-11 23:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-11 23:49 linux [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-06-11 17:32 Martin Schwidefsky
2004-06-11 22:19 ` Andrew Morton
2004-06-14  8:40   ` Martin Schwidefsky

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=20040611234901.18482.qmail@science.horizon.com \
    --to=linux@horizon.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®