From: Borislav Petkov <bp@alien8.de>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
stable@vger.kernel.org
Subject: Re: [PATCH 2/4] x86: Fix the hw_breakpoint range check
Date: Sun, 24 Nov 2013 14:40:57 +0100 [thread overview]
Message-ID: <20131124134057.GA4531@pd.tnic> (raw)
In-Reply-To: <1385289171-3411-3-git-send-email-fweisbec@gmail.com>
On Sun, Nov 24, 2013 at 11:32:49AM +0100, Frederic Weisbecker wrote:
> From: Oleg Nesterov <oleg@redhat.com>
>
> arch_check_bp_in_kernelspace() tries to avoid the overflow and does 2
> TASK_SIZE checks but it needs OR, not AND. Consider va = TASK_SIZE -1
> and len = 2 case.
>
> Note: TASK_SIZE doesn't look right at least on x86, I think it should
> be replaced by TASK_SIZE_MAX.
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> Fixes: 0067f1297241ea567f2b22a455519752d70fcca9
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> ---
> arch/x86/kernel/hw_breakpoint.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
> index f66ff16..1131c1f 100644
> --- a/arch/x86/kernel/hw_breakpoint.c
> +++ b/arch/x86/kernel/hw_breakpoint.c
> @@ -200,7 +200,7 @@ int arch_check_bp_in_kernelspace(struct perf_event *bp)
> va = info->address;
> len = get_hbp_len(info->len);
>
> - 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;
AFAICT, the high end of the range matters, no?
Unless the original code was meant to short-circuit at the first
comparison already...
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
next prev parent reply other threads:[~2013-11-24 13:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-24 10:32 [PATCH 0/4] hw_breakpoints: Fix a bunch of adress range fixes Frederic Weisbecker
2013-11-24 10:32 ` [PATCH 1/4] arm: Fix the hw_breakpoint range check Frederic Weisbecker
2013-11-24 10:32 ` [PATCH 2/4] x86: " Frederic Weisbecker
2013-11-24 13:40 ` Borislav Petkov [this message]
2013-11-25 19:50 ` Oleg Nesterov
2013-11-25 20:11 ` Borislav Petkov
2013-11-26 18:09 ` Oleg Nesterov
2013-11-24 10:32 ` [PATCH 3/4] arm64: " Frederic Weisbecker
2013-11-24 10:32 ` [PATCH 4/4] sh: Fix hw_breakpoint the " Frederic Weisbecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131124134057.GA4531@pd.tnic \
--to=bp@alien8.de \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.