Skip to content

Commit 01c7a6e

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/[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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2dbb5e9 commit 01c7a6e

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)