Messages in this thread | | | Date | Thu, 17 Oct 2013 16:53:26 +0100 | From | "Jan Beulich" <> | Subject | Re: [PATCH] x86: unify copy_from_user() checking |
| |
>>> On 17.10.13 at 17:45, Arjan van de Ven <arjan@linux.intel.com> wrote: > for me, the value of the feature overall is this range checking, not the > fixed size part. > for fixed size... the chance of the programmer getting it wrong is near > zero. > the chance of getting one of the checks wrong is much higher > (we've had cases of wrong sign in the checks, off by ones in the checks etc) > and that is what it was supposed to find. > If that's not possible due practical issues (like the inline case above but > more > the compiler practicalities).... removing the warning part entirely is > likely just better.
But it would at least cover the case where, for some pointer, someone mixes up sizeof(ptr) and sizeof(*ptr). So I think - it being cheap - the current constant size check could stay, ...
> Having a runtime check for the case where the argument is not constant but > we know the buffer > size... is likely still clear value... cheap (perfect branch prediction > unless disaster hits!) > and the failure case is obviously the disaster case.
... and the non-constant case be taken care of at run time. That's precisely what the patch does.
Jan
| |