Re: [PATCH V2] Fix unsafe memory access by memcmp
From: Fabio M. De Francesco
Date: Mon Apr 04 2022 - 10:48:46 EST
On luned? 4 aprile 2022 16:35:31 CEST Dan Carpenter wrote:
> On Mon, Apr 04, 2022 at 04:29:48PM +0200, Fabio M. De Francesco wrote:
> > Is it safe to access user space pointers without using proper helpers?
> > In those cases I mean: is it safe without using copy_from_user()?
> Correct. You need to use copy_from_user().
> > As I said, perhaps I'm overlooking something. However my conclusions
> > follow by your own argument.
> > If I understand what you wrote, you asked to delete rtw_p2p_get()
> > because it looks like nobody "has ever tested or used this code".
> > rtw_p2p_get2() and rtw_p2p_set() use the same pattern of rtw_p2p_get()
> > when they access user space without using the proper helpers.
> Those functions use "extra" which is a kernel pointer. Which user
> pointer do they use? Sparse doesn't detect it.
You're right, sorry. This is what I had overlooked. I took a brief look
(just 5 seconds or something) and saw the same arguments that
rtw_p2p_get() takes and then a long list of calls to memcmp().
I overlooked that they were called using the 4th argument ("extra").
Sorry for the noise.