* [PATCH] proc: proc_maps_open allow proc_mem_open to return NULL
@ 2025-08-07 16:54 Jialin Wang
2025-08-07 22:46 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: Jialin Wang @ 2025-08-07 16:54 UTC (permalink / raw)
To: Penglei Jiang, Andrew Morton; +Cc: Jialin Wang, linux-kernel, linux-fsdevel
The commit 65c66047259f ("proc: fix the issue of proc_mem_open returning NULL")
breaks `perf record -g -p PID` when profiling a kernel thread.
The strace of `perf record -g -p $(pgrep kswapd0)` shows:
openat(AT_FDCWD, "/proc/65/task/65/maps", O_RDONLY) = -1 ESRCH (No such process)
This patch partially reverts the commit to fix it.
Fixes: 65c66047259f ("proc: fix the issue of proc_mem_open returning NULL")
Signed-off-by: Jialin Wang <wjl.linux@gmail.com>
---
fs/proc/task_mmu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 3d6d8a9f13fc..7a7ce26106ac 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -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;
--
2.50.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] proc: proc_maps_open allow proc_mem_open to return NULL
2025-08-07 16:54 [PATCH] proc: proc_maps_open allow proc_mem_open to return NULL Jialin Wang
@ 2025-08-07 22:46 ` Andrew Morton
2025-08-08 12:53 ` [PATCH v2] " Jialin Wang
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2025-08-07 22:46 UTC (permalink / raw)
To: Jialin Wang; +Cc: Penglei Jiang, linux-kernel, linux-fsdevel
On Fri, 8 Aug 2025 00:54:55 +0800 Jialin Wang <wjl.linux@gmail.com> wrote:
> The commit 65c66047259f ("proc: fix the issue of proc_mem_open returning NULL")
> breaks `perf record -g -p PID` when profiling a kernel thread.
>
> The strace of `perf record -g -p $(pgrep kswapd0)` shows:
>
> openat(AT_FDCWD, "/proc/65/task/65/maps", O_RDONLY) = -1 ESRCH (No such process)
>
> This patch partially reverts the commit to fix it.
Thanks. But "breaks" is a rather thin description of the problem!
Can you please describe the observed misbehavior fully?
> Fixes: 65c66047259f ("proc: fix the issue of proc_mem_open returning NULL")
Because we should backport this fix into 6.16.x -stable kernels. The
-stable maintainers may wonder why we're requesting this. Also, any
person who is having problems with their 6.16-based kernel will want
such a description so they can decide whether this fix might address
their problem.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] proc: proc_maps_open allow proc_mem_open to return NULL
2025-08-07 22:46 ` Andrew Morton
@ 2025-08-08 12:53 ` Jialin Wang
0 siblings, 0 replies; 4+ messages in thread
From: Jialin Wang @ 2025-08-08 12:53 UTC (permalink / raw)
To: akpm; +Cc: linux-fsdevel, linux-kernel, superman.xpt, wjl.linux
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")
Signed-off-by: Jialin Wang <wjl.linux@gmail.com>
---
Changes in v2 (Thanks to Andrew):
- Add more detailed misbehavior description in commit message
fs/proc/task_mmu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 3d6d8a9f13fc..7a7ce26106ac 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -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;
--
2.50.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] proc: proc_maps_open allow proc_mem_open to return NULL
@ 2025-08-14 16:09 Dennis Beier
0 siblings, 0 replies; 4+ messages in thread
From: Dennis Beier @ 2025-08-14 16:09 UTC (permalink / raw)
To: nanovim; +Cc: Jialin Wang, Penglei Jiang, stable, Andrew Morton
From: Jialin Wang <wjl.linux@gmail.com>
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.
Link: https://lkml.kernel.org/r/20250807165455.73656-1-wjl.linux@gmail.com
Fixes: 65c66047259f ("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>
---
fs/proc/task_mmu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index ee1e4ccd33bd..29cca0e6d0ff 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -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;
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-14 16:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07 16:54 [PATCH] proc: proc_maps_open allow proc_mem_open to return NULL Jialin Wang
2025-08-07 22:46 ` Andrew Morton
2025-08-08 12:53 ` [PATCH v2] " Jialin Wang
-- strict thread matches above, loose matches on Subject: below --
2025-08-14 16:09 [PATCH] " Dennis Beier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.