From: Ingo Molnar <mingo@elte.hu>
To: "Figo.zhang" <figo1802@gmail.com>
Cc: lkml <linux-kernel@vger.kernel.org>, Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH]highmem_32.c: add argument pointer checking
Date: Mon, 29 Jun 2009 06:09:54 +0200 [thread overview]
Message-ID: <20090629040954.GA13117@elte.hu> (raw)
In-Reply-To: <1246244906.5759.5.camel@myhost>
* Figo.zhang <figo1802@gmail.com> wrote:
> It had better add argument pointer checking.
>
> If any guys write driver want to alloc hightmem and pass a no-initial pointer,
> it would be crashed.
>
> Signed-off-by: Figo.zhang <figo1802@gmail.com>
> ---
> arch/x86/mm/highmem_32.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
> index 58f621e..e52e1a9 100644
> --- a/arch/x86/mm/highmem_32.c
> +++ b/arch/x86/mm/highmem_32.c
> @@ -31,6 +31,7 @@ void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
> {
> enum fixed_addresses idx;
> unsigned long vaddr;
> + BUG_ON(!page);
>
> /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
> pagefault_disable();
> @@ -58,6 +59,9 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
> unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
> enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
>
> + if(!kvaddr)
> + return;
> +
(Please run patches through scripts/checkpatch.pl before
submission.)
Also, what's the improvement here? Before the patch we'd crash on a
NULL dereference ... after the patch we'd crash on a BUG_ON().
Furthermore, he kunmap_atomic() change is outright wrong - it will
now allow NULL kunmaps, which can hide bugs in drivers.
Ingo
next prev parent reply other threads:[~2009-06-29 4:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-29 3:08 [PATCH]highmem_32.c: add argument pointer checking Figo.zhang
2009-06-29 4:09 ` Ingo Molnar [this message]
2009-06-29 16:11 ` Figo.zhang
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=20090629040954.GA13117@elte.hu \
--to=mingo@elte.hu \
--cc=akpm@osdl.org \
--cc=figo1802@gmail.com \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox