From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Defang Bo <bodefang@126.com>,
"mpe@ellerman.id.au" <mpe@ellerman.id.au>,
"benh@kernel.crashing.org" <benh@kernel.crashing.org>,
"paulus@samba.org" <paulus@samba.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"geert@linux-m68k.org" <geert@linux-m68k.org>,
"rppt@kernel.org" <rppt@kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] powerpc/mm: add sanity check to avoid null pointer dereference
Date: Thu, 8 Sep 2022 06:21:03 +0000 [thread overview]
Message-ID: <48e444b9-ccdd-2aac-4cc6-3d9b75e90005@csgroup.eu> (raw)
In-Reply-To: <1609125050-240351-1-git-send-email-bodefang@126.com>
Le 28/12/2020 à 04:10, Defang Bo a écrit :
> Similar to commit<0dc294f717d4>("powerpc/mm: bail out early when flushing TLB page"),
> there should be a check for 'mm' to prevent Null pointer dereference
> in case of 'mm' argument was legitimately passed.
I don't understand what you are trying to do here.
In commit 0dc294f717d4, a call with a NULL mm is expected. The commit
just reorganises the code in order to bail out earlier and more explicitely.
In your patch, you are adding WARN_ON, which means that being called
with a NULL mm is unexpected. Why do you think it is necessary to do it
? Have you encountered any problem ?
Thanks
Christophe
>
> Signed-off-by: Defang Bo <bodefang@126.com>
> ---
> arch/powerpc/mm/nohash/tlb.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/mm/nohash/tlb.c b/arch/powerpc/mm/nohash/tlb.c
> index 5872f69..1d89335 100644
> --- a/arch/powerpc/mm/nohash/tlb.c
> +++ b/arch/powerpc/mm/nohash/tlb.c
> @@ -192,6 +192,9 @@ void local_flush_tlb_mm(struct mm_struct *mm)
> {
> unsigned int pid;
>
> + if (WARN_ON(!mm))
> + return;
> +
> preempt_disable();
> pid = mm->context.id;
> if (pid != MMU_NO_CONTEXT)
> @@ -205,8 +208,11 @@ void __local_flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
> {
> unsigned int pid;
>
> + if (WARN_ON(!mm))
> + return;
> +
> preempt_disable();
> - pid = mm ? mm->context.id : 0;
> + pid = mm->context.id;
> if (pid != MMU_NO_CONTEXT)
> _tlbil_va(vmaddr, pid, tsize, ind);
> preempt_enable();
> @@ -268,6 +274,9 @@ void flush_tlb_mm(struct mm_struct *mm)
> {
> unsigned int pid;
>
> + if (WARN_ON(!mm))
> + return;
> +
> preempt_disable();
> pid = mm->context.id;
> if (unlikely(pid == MMU_NO_CONTEXT))
prev parent reply other threads:[~2022-09-08 6:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-28 3:10 Defang Bo
2022-09-08 6:21 ` Christophe Leroy [this message]
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=48e444b9-ccdd-2aac-4cc6-3d9b75e90005@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=bodefang@126.com \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=rppt@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
all inboxes | Powered by JetHome®