Skip to contentSkip to conversation

proc: proc_maps_open allow proc_mem_open to return NULL

PATCH New Dennis Beier 1 participant 1 message Aug 14, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc: proc_maps_open allow proc_mem_open to return NULL

From: Jialin Wang <[email protected]>

The commit 65c66047259f ("proc: fix the issue of proc_mem_open returning NULL") caused proc_maps_open() to return -ESRCH when proc_mem_open() returns NULL. This breaks legitimate /proc/<pid>/maps access for kernel threads since kernel threads have NULL mm_struct.

The regression causes perf to fail and exit when profiling a kernel thread:

  # perf record -v -g -p $(pgrep kswapd0)
  ...
  couldn't open /proc/65/task/65/maps

This patch partially reverts the commit to fix it.

Fixes 65c66047259f ("proc: fix the issue of proc_mem_open returning NULL")
Cc Penglei Jiang <[email protected]>
---
 fs/proc/task_mmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/proc/task_mmu.c +2 -2
index ee1e4ccd33bd..29cca0e6d0ff 100644
@@ -340,8 +340,8 @@ static int proc_maps_open(struct inode *inode, struct file *file,
 
 	priv->inode = inode;
 	priv->mm = proc_mem_open(inode, PTRACE_MODE_READ);
-	if (IS_ERR_OR_NULL(priv->mm)) {
-		int err = priv->mm ? PTR_ERR(priv->mm) : -ESRCH;
+	if (IS_ERR(priv->mm)) {
+		int err = PTR_ERR(priv->mm);
 
 		seq_release_private(inode, file);
 		return err;
Signature · 1 line
2.50.1