Skip to content

Commit 68d85f0

Browse files
committed
init: Deal with the init process being a user mode process
It is silly for user_mode_thread to leave PF_KTHREAD set on the resulting task. Update the init process so that it does not care if PF_KTHREAD is set or not. Ensure do_populate_rootfs flushes all delayed fput work by calling task_work_run. In the rare instance that async_schedule_domain calls do_populate_rootfs synchronously it is possible do_populate_rootfs will be called directly from the init process. At which point fput will call "task_work_add(current, ..., TWA_RESUME)". The files on the initramfs need to be completely put before we attempt to exec them (which is before the code enters userspace). So call task_work_run just in case there are any pending fput operations. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 5bd2e97 commit 68d85f0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

init/initramfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/mm.h>
1616
#include <linux/namei.h>
1717
#include <linux/init_syscalls.h>
18+
#include <linux/task_work.h>
1819
#include <linux/umh.h>
1920

2021
static ssize_t __init xwrite(struct file *file, const char *p, size_t count,
@@ -703,6 +704,7 @@ static void __init do_populate_rootfs(void *unused, async_cookie_t cookie)
703704
initrd_end = 0;
704705

705706
flush_delayed_fput();
707+
task_work_run();
706708
}
707709

708710
static ASYNC_DOMAIN_EXCLUSIVE(initramfs_domain);

0 commit comments

Comments
 (0)