From: Richard Sailer <richard_siegfried@systemli.org>
To: "Valdis Klētnieks" <valdis.kletnieks@vt.edu>
Cc: kernelnewbies <Kernelnewbies@kernelnewbies.org>
Subject: Re: Dubios pointer casting with put_user()
Date: Sun, 19 Jul 2020 14:15:36 +0200 [thread overview]
Message-ID: <8de3b54c-8731-4be1-3e69-228d99bc4384@systemli.org> (raw)
In-Reply-To: <96764.1595026006@turing-police>
[-- Attachment #1.1.1: Type: text/plain, Size: 1272 bytes --]
On 18/07/2020 00:46, Valdis Klētnieks wrote:
> On Fri, 17 Jul 2020 02:13:34 +0200, Richard Sailer said:
>
>> unsigned long. Is this (correctness and security wise) sane? Because as
>> I understand it put_user() determines the amount it copies from the
>> pointer type.
>
>> rc = put_user(amount, (int __user *)arg);
>
> If that were true, you wouldn't need to pass the 'amount' variable....
>
Hmm, that would make no sense to me. arg is a pointer to user space
memory, put_user would still need the value to copy to that memory.
And my understanding of put_user() comes from its definition in uaccess.h:
#define put_user(x, ptr) \
({ \
int __ret_pu; \
__typeof__(*(ptr)) __pu_val; \
__chk_user_ptr(ptr); \
might_fault(); \
__pu_val = x; \
switch (sizeof(*(ptr))) { \
case 1: \
__put_user_x(1, __pu_val, ptr, __ret_pu); \
break; \
case 2: \
__put_user_x(2, __pu_val, ptr, __ret_pu); \
break; \
case 4: \
__put_user_x(4, __pu_val, ptr, __ret_pu); \
break; \
case 8: \
__put_user_x8(__pu_val, ptr, __ret_pu); \
break; \
[...]
But please tell me if I got anything wrong here, I'm still not 100% sure
-- Richard
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
next prev parent reply other threads:[~2020-07-19 12:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-17 0:13 Dubios pointer casting with put_user() Richard Sailer
2020-07-17 0:19 ` Richard Sailer
2020-07-17 22:46 ` Valdis Klētnieks
2020-07-19 12:15 ` Richard Sailer [this message]
2020-07-19 22:50 ` Valdis Klētnieks
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=8de3b54c-8731-4be1-3e69-228d99bc4384@systemli.org \
--to=richard_siegfried@systemli.org \
--cc=Kernelnewbies@kernelnewbies.org \
--cc=valdis.kletnieks@vt.edu \
/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.