linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Manas via B4 Relay <devnull+manas18244.iiitd.ac.in@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Xu <peterx@redhat.com>,
	Shuah Khan <skhan@linuxfoundation.org>,
	 Anup Sharma <anupnewsmail@gmail.com>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	 syzbot+093d096417e7038a689b@syzkaller.appspotmail.com,
	 Manas <manas18244@iiitd.ac.in>
Subject: [PATCH] Fixes: null pointer dereference in pfnmap_lockdep_assert
Date: Thu, 03 Oct 2024 21:31:06 +0530	[thread overview]
Message-ID: <20241003-fix-null-deref-v1-1-0a45df9d016a@iiitd.ac.in> (raw)

From: Manas <manas18244@iiitd.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@syzkaller.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@iiitd.ac.in>
---
 mm/memory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/memory.c b/mm/memory.c
index 2366578015ad..b152a95e543f 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -6346,6 +6346,9 @@ 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
+	if (!vma->vm_file)
+		return;
+
 	struct address_space *mapping = vma->vm_file->f_mapping;
 
 	if (mapping)

---
base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc
change-id: 20241003-fix-null-deref-6bfa0337efc3

Best regards,
-- 
Manas <manas18244@iiitd.ac.in>




             reply	other threads:[~2024-10-03 16:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-03 16:01 Manas via B4 Relay [this message]
2024-10-03 16:41 ` Peter Xu
2024-10-04 10:13   ` Manas
2024-10-04 12:29     ` Peter Xu
2024-10-03 20:31 ` Matthew Wilcox
2024-10-03 21:06   ` Peter Xu

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=20241003-fix-null-deref-v1-1-0a45df9d016a@iiitd.ac.in \
    --to=devnull+manas18244.iiitd.ac.in@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=anupnewsmail@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=manas18244@iiitd.ac.in \
    --cc=peterx@redhat.com \
    --cc=skhan@linuxfoundation.org \
    --cc=syzbot+093d096417e7038a689b@syzkaller.appspotmail.com \
    /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