Implement ->proc_read_buf() so procfs copies what is read to userspace
after it unpinned the entry. Unloading configs.ko then no longer waits
for a reader that faults on its buffer. /proc/config.gz asks for
PROC_ENTRY_FULL_READS so that reading all of it at once keeps working.

Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 kernel/configs.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/configs.c b/kernel/configs.c
index a28c79c5f713..05b12c440168 100644
--- a/kernel/configs.c
+++ b/kernel/configs.c
@@ -38,17 +38,18 @@ extern char kernel_config_data;
 extern char kernel_config_data_end;
 
 static ssize_t
-ikconfig_read_current(struct file *file, char __user *buf,
+ikconfig_read_current(struct file *file, char *buf,
                      size_t len, loff_t * offset)
 {
-       return simple_read_from_buffer(buf, len, offset,
+       return memory_read_from_buffer(buf, len, offset,
                                       &kernel_config_data,
                                       &kernel_config_data_end -
                                       &kernel_config_data);
 }
 
 static const struct proc_ops config_gz_proc_ops = {
-       .proc_read      = ikconfig_read_current,
+       .proc_flags     = PROC_ENTRY_FULL_READS,
+       .proc_read_buf  = ikconfig_read_current,
        .proc_lseek     = default_llseek,
 };
 

-- 
2.53.0


Reply via email to