All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] proc: clear FMODE_LSEEK flag correctly for permanent pde
@ 2025-06-05  6:52 wangzijie
  2025-06-05 21:44 ` Andrew Morton
  0 siblings, 1 reply; 10+ messages in thread
From: wangzijie @ 2025-06-05  6:52 UTC (permalink / raw)
  To: akpm, rick.p.edgecombe, ast, adobriyan, kirill.shutemov,
	linux-fsdevel
  Cc: wangzijie

Clearing FMODE_LSEEK flag should not rely on whether proc_open ops exists, fix it.

Fixed: ad7f4ea6e36e ("proc: avoid use-after-free in proc_reg_open()")
Signed-off-by: wangzijie <wangzijie1@honor.com>
---
Based on mm-nonmm-unstable
---
 fs/proc/inode.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 8de0af8c3..10a8481cc 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -474,12 +474,11 @@ static int proc_reg_open(struct inode *inode, struct file *file)
 	struct pde_opener *pdeo;
 
 	if (pde_is_permanent(pde)) {
+		if (!pde->proc_ops->proc_lseek)
+			file->f_mode &= ~FMODE_LSEEK;
 		open = pde->proc_ops->proc_open;
-		if (open) {
-			if (!pde->proc_ops->proc_lseek)
-				file->f_mode &= ~FMODE_LSEEK;
+		if (open)
 			rv = open(inode, file);
-		}
 		return rv;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-06-06  5:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-05  6:52 [PATCH] proc: clear FMODE_LSEEK flag correctly for permanent pde wangzijie
2025-06-05 21:44 ` Andrew Morton
2025-06-06  1:56   ` Al Viro
2025-06-06  2:37     ` wangzijie
2025-06-06  3:57       ` Al Viro
2025-06-06  4:01         ` Andrew Morton
2025-06-06  5:13         ` wangzijie
2025-06-06  3:34     ` wangzijie
2025-06-06  3:44     ` Andrew Morton
2025-06-06  3:58       ` Al Viro

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.