public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Accessing user-land memory without safe functions
@ 2015-12-03 20:54 Scotty Bauer
  2015-12-04  0:12 ` Jonathan Corbet
  0 siblings, 1 reply; 3+ messages in thread
From: Scotty Bauer @ 2015-12-03 20:54 UTC (permalink / raw)
  To: linux-kernel

I Have been auditing a few drivers and have found some of them are
accessing user-land memory without either mapping the pages in, or
copying the data via the safe user access apis. 

The thing I have mostly been seeing is something along the lines of:

ioctl(etc, etc, arg) {

char buf[32];
__user *some_struct  = (type cast) arg;
 
size_t amount = some_struct->amount;

** do size check on amount **

copy_from_user(buf, some_struct->some_uland_addr, amount);

}


Above you see 2 unsafe user-land dereferences, the
some_struct->amount and some_struct->some_uland_addr.


Since I've seen this a couple times now I'm wondering if my
understanding of touching user-land memory is flawed.

For the above example Ioctl, the proper way to get access to those fields
through the safe copy_from_user or get_user() functions, correct?

I'm wondering if I should submit patches to fix the issues I've found,
but now I'm doubting whether they're really issues at all.

Thanks,
Scotty

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Accessing user-land memory without safe functions
  2015-12-03 20:54 Accessing user-land memory without safe functions Scotty Bauer
@ 2015-12-04  0:12 ` Jonathan Corbet
  2015-12-04  0:32   ` Scotty Bauer
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Corbet @ 2015-12-04  0:12 UTC (permalink / raw)
  To: Scotty Bauer; +Cc: linux-kernel

On Thu, 3 Dec 2015 13:54:30 -0700
Scotty Bauer <sbauer@eng.utah.edu> wrote:

> Since I've seen this a couple times now I'm wondering if my
> understanding of touching user-land memory is flawed.
> 
> For the above example Ioctl, the proper way to get access to those fields
> through the safe copy_from_user or get_user() functions, correct?
> 
> I'm wondering if I should submit patches to fix the issues I've found,
> but now I'm doubting whether they're really issues at all.

They sound like bugs to me, though it would be easier to say for sure with
a pointer to a specific function in the kernel source.  Please point
something out, or, perhaps better, send a patch fixing one of them.

Thanks,

jon

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Accessing user-land memory without safe functions
  2015-12-04  0:12 ` Jonathan Corbet
@ 2015-12-04  0:32   ` Scotty Bauer
  0 siblings, 0 replies; 3+ messages in thread
From: Scotty Bauer @ 2015-12-04  0:32 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: linux-kernel

Hi Jon,

Thanks for the response.

Here is one such example, although benign due to the
function being called with CAP_SYS_ADMIN. I'll work on patches for some of the
other issues and send those soon as well.

https://lkml.org/lkml/2015/12/1/566




On 12/03/2015 05:12 PM, Jonathan Corbet wrote:
> On Thu, 3 Dec 2015 13:54:30 -0700
> Scotty Bauer <sbauer@eng.utah.edu> wrote:
> 
>> Since I've seen this a couple times now I'm wondering if my
>> understanding of touching user-land memory is flawed.
>>
>> For the above example Ioctl, the proper way to get access to those fields
>> through the safe copy_from_user or get_user() functions, correct?
>>
>> I'm wondering if I should submit patches to fix the issues I've found,
>> but now I'm doubting whether they're really issues at all.
> 
> They sound like bugs to me, though it would be easier to say for sure with
> a pointer to a specific function in the kernel source.  Please point
> something out, or, perhaps better, send a patch fixing one of them.
> 
> Thanks,
> 
> jon
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-04  0:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-03 20:54 Accessing user-land memory without safe functions Scotty Bauer
2015-12-04  0:12 ` Jonathan Corbet
2015-12-04  0:32   ` Scotty Bauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox