Skip to content

Commit ec8d823

Browse files
hyuuko1gregkh
authored andcommitted
proc: proc_maps_open allow proc_mem_open to return NULL
commit c0e1b77 upstream. The commit 65c6604 ("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. Link: https://lkml.kernel.org/r/20250807165455.73656-1-wjl.linux@gmail.com Fixes: 65c6604 ("proc: fix the issue of proc_mem_open returning NULL") Signed-off-by: Jialin Wang <wjl.linux@gmail.com> Cc: Penglei Jiang <superman.xpt@gmail.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 69dbdc7 commit ec8d823

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/proc/task_mmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ static int proc_maps_open(struct inode *inode, struct file *file,
212212

213213
priv->inode = inode;
214214
priv->mm = proc_mem_open(inode, PTRACE_MODE_READ);
215-
if (IS_ERR_OR_NULL(priv->mm)) {
216-
int err = priv->mm ? PTR_ERR(priv->mm) : -ESRCH;
215+
if (IS_ERR(priv->mm)) {
216+
int err = PTR_ERR(priv->mm);
217217

218218
seq_release_private(inode, file);
219219
return err;

0 commit comments

Comments
 (0)