Skip to content

Commit da9029b

Browse files
committed
coredump: add coredump_skip() helper
Link: https://lore.kernel.org/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 9dd88f3 commit da9029b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

fs/coredump.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,14 +1079,26 @@ static void coredump_cleanup(struct core_name *cn, struct coredump_params *cprm)
10791079
coredump_finish(cn->core_dumped);
10801080
}
10811081

1082+
static inline bool coredump_skip(const struct coredump_params *cprm,
1083+
const struct linux_binfmt *binfmt)
1084+
{
1085+
if (!binfmt)
1086+
return true;
1087+
if (!binfmt->core_dump)
1088+
return true;
1089+
if (!__get_dumpable(cprm->mm_flags))
1090+
return true;
1091+
return false;
1092+
}
1093+
10821094
void vfs_coredump(const kernel_siginfo_t *siginfo)
10831095
{
10841096
struct cred *cred __free(put_cred) = NULL;
10851097
size_t *argv __free(kfree) = NULL;
10861098
struct core_state core_state;
10871099
struct core_name cn;
10881100
struct mm_struct *mm = current->mm;
1089-
struct linux_binfmt * binfmt;
1101+
struct linux_binfmt *binfmt = mm->binfmt;
10901102
const struct cred *old_cred;
10911103
int argc = 0;
10921104
struct coredump_params cprm = {
@@ -1104,10 +1116,7 @@ void vfs_coredump(const kernel_siginfo_t *siginfo)
11041116

11051117
audit_core_dumps(siginfo->si_signo);
11061118

1107-
binfmt = mm->binfmt;
1108-
if (!binfmt || !binfmt->core_dump)
1109-
return;
1110-
if (!__get_dumpable(cprm.mm_flags))
1119+
if (coredump_skip(&cprm, binfmt))
11111120
return;
11121121

11131122
cred = prepare_creds();

0 commit comments

Comments
 (0)