[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zv_rz2DRYENY0K5d@x1n>
Date: Fri, 4 Oct 2024 09:21:19 -0400
From: Peter Xu <peterx@...hat.com>
To: manas18244@...td.ac.in
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Shuah Khan <skhan@...uxfoundation.org>,
Anup Sharma <anupnewsmail@...il.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
syzbot+093d096417e7038a689b@...kaller.appspotmail.com
Subject: Re: [PATCH v2] Fixes: null pointer dereference in
pfnmap_lockdep_assert
On Fri, Oct 04, 2024 at 06:35:53PM +0530, Manas via B4 Relay wrote:
> From: Manas <manas18244@...td.ac.in>
>
> syzbot has pointed to a possible null pointer dereference in
> pfnmap_lockdep_assert. vm_file member of vm_area_struct is being
> dereferenced without any checks.
>
> This fix returns if vm_file member in vm_area_struct is NULL.
>
> Reported-by: syzbot+093d096417e7038a689b@...kaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=093d096417e7038a689b
> ---
> This bug[1] triggers a general protection fault in follow_pfnmap_start
> function. An assertion pfnmap_lockdep_assert inside this function
> dereferences vm_file member of vm_area_struct. And panic gets triggered
> when vm_file is NULL.
>
> This patch returns from the assertion pfnmap_lockdep_assert if vm_file
> is found to be NULL.
>
> [1] https://syzkaller.appspot.com/bug?extid=093d096417e7038a689b
>
> Signed-off-by: Manas <manas18244@...td.ac.in>
Reviewed-by: Peter Xu <peterx@...hat.com>
One nitpick:
> ---
> Changes in v2:
> - v2: use ternary operator according to feedback
> - Link to v1: https://lore.kernel.org/r/20241003-fix-null-deref-v1-1-0a45df9d016a@iiitd.ac.in
> ---
> mm/memory.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index 2366578015ad..5ed109a8f02e 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -6346,7 +6346,7 @@ static inline void pfnmap_args_setup(struct follow_pfnmap_args *args,
> static inline void pfnmap_lockdep_assert(struct vm_area_struct *vma)
> {
> #ifdef CONFIG_LOCKDEP
> - struct address_space *mapping = vma->vm_file->f_mapping;
> + struct address_space *mapping = vma->vm_file ? vma->vm_file->f_mapping : NULL;
>
> if (mapping)
> lockdep_assert(lockdep_is_held(&vma->vm_file->f_mapping->i_mmap_rwsem) ||
This can use "mapping" directly, as I mentioned in previous email (but
probably got overlooked..).
Thanks!
>
> ---
> base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc
> change-id: 20241003-fix-null-deref-6bfa0337efc3
>
> Best regards,
> --
> Manas <manas18244@...td.ac.in>
>
>
--
Peter Xu
Powered by blists - more mailing lists