Skip to content

Commit c0e1b77

Browse files
hyuuko1akpm00
authored andcommitted
proc: proc_maps_open allow proc_mem_open to return NULL
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/[email protected] Fixes: 65c6604 ("proc: fix the issue of proc_mem_open returning NULL") Signed-off-by: Jialin Wang <[email protected]> Cc: Penglei Jiang <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 0b5be13 commit c0e1b77

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
@@ -340,8 +340,8 @@ static int proc_maps_open(struct inode *inode, struct file *file,
340340

341341
priv->inode = inode;
342342
priv->mm = proc_mem_open(inode, PTRACE_MODE_READ);
343-
if (IS_ERR_OR_NULL(priv->mm)) {
344-
int err = priv->mm ? PTR_ERR(priv->mm) : -ESRCH;
343+
if (IS_ERR(priv->mm)) {
344+
int err = PTR_ERR(priv->mm);
345345

346346
seq_release_private(inode, file);
347347
return err;

0 commit comments

Comments
 (0)