Re: [PATCH] x86: unify copy_from_user() checking
From: Jan Beulich
Date: Thu Oct 17 2013 - 11:53:35 EST
>>> On 17.10.13 at 17:45, Arjan van de Ven <arjan@xxxxxxxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/