* [PATCH] mm: Add check for NULL for unlocked in fixup_user_fault
@ 2022-12-15 9:39 Anastasia Belova
2022-12-15 21:22 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Anastasia Belova @ 2022-12-15 9:39 UTC (permalink / raw)
To: Andrew Morton
Cc: Anastasia Belova, Max Filippov, Ingo Molnar, Vineet Gupta,
Russell King (Oracle),
Geert Uytterhoeven, linux-mm, linux-kernel, lvc-project
Check unlocked for NULL before dereference.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: d92725256b4f ("mm: avoid unnecessary page fault retires on shared memory types")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
---
mm/gup.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/gup.c b/mm/gup.c
index f212d571b563..905d5fb64c4c 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1282,7 +1282,8 @@ int fixup_user_fault(struct mm_struct *mm,
* could tell the callers so they do not need to unlock.
*/
mmap_read_lock(mm);
- *unlocked = true;
+ if (unlocked)
+ *unlocked = true;
return 0;
}
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] mm: Add check for NULL for unlocked in fixup_user_fault
2022-12-15 9:39 [PATCH] mm: Add check for NULL for unlocked in fixup_user_fault Anastasia Belova
@ 2022-12-15 21:22 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2022-12-15 21:22 UTC (permalink / raw)
To: Anastasia Belova
Cc: Max Filippov, Ingo Molnar, Vineet Gupta, Russell King (Oracle),
Geert Uytterhoeven, linux-mm, linux-kernel, lvc-project
On Thu, 15 Dec 2022 12:39:30 +0300 Anastasia Belova <abelova@astralinux.ru> wrote:
> Check unlocked for NULL before dereference.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> ...
>
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -1282,7 +1282,8 @@ int fixup_user_fault(struct mm_struct *mm,
> * could tell the callers so they do not need to unlock.
> */
> mmap_read_lock(mm);
> - *unlocked = true;
> + if (unlocked)
> + *unlocked = true;
> return 0;
> }
I don't believe this is necessary unless the caller passed
FAULT_FLAG_KILLABLE or FAULT_FLAG_ALLOW_RETRY in fault_flags.
It's clear as mud and some code comments would help.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-15 21:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 9:39 [PATCH] mm: Add check for NULL for unlocked in fixup_user_fault Anastasia Belova
2022-12-15 21:22 ` Andrew Morton
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®