[Yaffs] [PATCH 2/2] Fix the problem of proc_create in higher…

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: tianyu2
Date:  
To: cdhmanning, yaffs
Old-Topics: [Yaffs] [PATCH 1/2] Fix compilation errors on 5.10
Subject: [Yaffs] [PATCH 2/2] Fix the problem of proc_create in higher version kernels
After commit d56c0d45f0e2 ("proc: decouple proc from VFS with "struct proc_ops""),
core /proc code uses "struct proc_ops" for custom hooks.When I read the
/proc/yaffs interface in the 5.10 kernel, the following stack appears:

[<8010dd68>] (unwind_backtrace) from [<8010a6a0>] (show_stack+0x10/0x14)
[<8010a6a0>] (show_stack) from [<80a5238c>] (dump_stack+0x9c/0xb0)
[<80a5238c>] (dump_stack) from [<803de0dc>] (yaffs_proc_write+0x1e8/0x424)
[<803de0dc>] (yaffs_proc_write) from [<802ad714>] (proc_reg_read_iter+0x74/0xb0)
[<802ad714>] (proc_reg_read_iter) from [<8025ce98>] (generic_file_splice_read+0xf0/0x17c)
[<8025ce98>] (generic_file_splice_read) from [<8025d124>] (splice_direct_to_actor+0xd0/0x2b0)
[<8025d124>] (splice_direct_to_actor) from [<8025d39c>] (do_splice_direct+0x98/0xd0)
[<8025d39c>] (do_splice_direct) from [<8022cc1c>] (do_sendfile+0x1cc/0x480)
[<8022cc1c>] (do_sendfile) from [<8022df1c>] (sys_sendfile64+0x120/0x158)
[<8022df1c>] (sys_sendfile64) from [<80100060>] (ret_fast_syscall+0x0/0x5c)

It uses the wrong hooks.

Signed-off-by: tianyu2 <>
---
yaffs_vfs_multi.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/yaffs_vfs_multi.c b/yaffs_vfs_multi.c
index d387aaa..5527b1f 100644
--- a/yaffs_vfs_multi.c
+++ b/yaffs_vfs_multi.c
@@ -3699,6 +3699,7 @@ static int yaffs_proc_open(struct inode *inode, struct file *file)
     return single_open(file, yaffs_proc_show, NULL);
 }


+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0))
 static struct file_operations procfs_ops = {
     .owner = THIS_MODULE,
     .open  = yaffs_proc_open,
@@ -3706,6 +3707,14 @@ static struct file_operations procfs_ops = {
     .write = yaffs_proc_write,
     .release = single_release,
 };
+#else
+static const struct proc_ops procfs_ops = {
+    .proc_open = yaffs_proc_open,
+    .proc_read = seq_read,
+    .proc_release = single_release,
+    .proc_write = yaffs_proc_write,
+};
+#endif


static int yaffs_procfs_init(void)
{
--
2.25.1