diff options
| author | Christian Brauner <brauner@kernel.org> | 2025-04-14 15:55:06 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-06-04 14:42:24 +0200 |
| commit | 1846a7b92b863c194e549860d046e0b33ff37a24 (patch) | |
| tree | ed3ddb04b01cccca0363311c0d5e00b4f5d42e2a | |
| parent | 0ec1e98bf5366ce892febc575d25f6c9212bb4c0 (diff) | |
| download | linux-1846a7b92b863c194e549860d046e0b33ff37a24.tar.gz linux-1846a7b92b863c194e549860d046e0b33ff37a24.tar.bz2 linux-1846a7b92b863c194e549860d046e0b33ff37a24.zip | |
coredump: fix error handling for replace_fd()
commit 95c5f43181fe9c1b5e5a4bd3281c857a5259991f upstream.
The replace_fd() helper returns the file descriptor number on success
and a negative error code on failure. The current error handling in
umh_pipe_setup() only works because the file descriptor that is replaced
is zero but that's pretty volatile. Explicitly check for a negative
error code.
Link: https://lore.kernel.org/20250414-work-coredump-v2-2-685bf231f828@kernel.org
Tested-by: Luca Boccassi <luca.boccassi@gmail.com>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | fs/coredump.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/coredump.c b/fs/coredump.c index 9d235fa14ab9..f342f352b478 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -502,7 +502,9 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new) { struct file *files[2]; struct coredump_params *cp = (struct coredump_params *)info->data; - int err = create_pipe_files(files, 0); + int err; + + err = create_pipe_files(files, 0); if (err) return err; @@ -510,10 +512,13 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new) err = replace_fd(0, files[0], 0); fput(files[0]); + if (err < 0) + return err; + /* and disallow core files too */ current->signal->rlim[RLIMIT_CORE] = (struct rlimit){1, 1}; - return err; + return 0; } void do_coredump(const kernel_siginfo_t *siginfo) |
