Re: [PATCH 2/4] x86: Fix the hw_breakpoint range check

Oleg Nesterov
2013-11-25T19:50:28Z

Frederic. Thanks for doing this ;)

On 11/24, Borislav Petkov wrote:
>
> On Sun, Nov 24, 2013 at 11:32:49AM +0100, Frederic Weisbecker wrote:
> >
> > - return (va >= TASK_SIZE) && ((va + len - 1) >= TASK_SIZE);
> > + return (va >= TASK_SIZE) || ((va + len - 1) >= TASK_SIZE);
>
> Well, can't you simplify it even further?
>
> return (va + len - 1) >= TASK_SIZE;

This won't work if va + len overflows?

Perhaps we should makes this clear, and we can even check the overflow
in the generic code (iirc Linus suggested to do this).

But to me it would be better to add the generic helper, they all do
the same check. Even arch/powerpc/kernel/hw_breakpoint.c whch doesn't
look right. Or make it __weak, or turn it into
arch_check_bp_in_kernelspace(start, end).

Oleg.