@@ -1443,6 +1443,31 @@ void setup_new_exec(struct linux_binprm * bprm)
14431443 group */
14441444 WRITE_ONCE (current -> self_exec_id , current -> self_exec_id + 1 );
14451445 flush_signal_handlers (current , 0 );
1446+
1447+ /*
1448+ * install the new credentials for this executable
1449+ */
1450+ security_bprm_committing_creds (bprm );
1451+
1452+ commit_creds (bprm -> cred );
1453+ bprm -> cred = NULL ;
1454+
1455+ /*
1456+ * Disable monitoring for regular users
1457+ * when executing setuid binaries. Must
1458+ * wait until new credentials are committed
1459+ * by commit_creds() above
1460+ */
1461+ if (get_dumpable (current -> mm ) != SUID_DUMP_USER )
1462+ perf_event_exit_task (current );
1463+ /*
1464+ * cred_guard_mutex must be held at least to this point to prevent
1465+ * ptrace_attach() from altering our determination of the task's
1466+ * credentials; any time after this it may be unlocked.
1467+ */
1468+ security_bprm_committed_creds (bprm );
1469+ mutex_unlock (& current -> signal -> exec_update_mutex );
1470+ mutex_unlock (& current -> signal -> cred_guard_mutex );
14461471}
14471472EXPORT_SYMBOL (setup_new_exec );
14481473
@@ -1458,7 +1483,7 @@ EXPORT_SYMBOL(finalize_exec);
14581483
14591484/*
14601485 * Prepare credentials and lock ->cred_guard_mutex.
1461- * install_exec_creds () commits the new creds and drops the lock.
1486+ * setup_new_exec () commits the new creds and drops the lock.
14621487 * Or, if exec fails before, free_bprm() should release ->cred and
14631488 * and unlock.
14641489 */
@@ -1504,35 +1529,6 @@ int bprm_change_interp(const char *interp, struct linux_binprm *bprm)
15041529}
15051530EXPORT_SYMBOL (bprm_change_interp );
15061531
1507- /*
1508- * install the new credentials for this executable
1509- */
1510- void install_exec_creds (struct linux_binprm * bprm )
1511- {
1512- security_bprm_committing_creds (bprm );
1513-
1514- commit_creds (bprm -> cred );
1515- bprm -> cred = NULL ;
1516-
1517- /*
1518- * Disable monitoring for regular users
1519- * when executing setuid binaries. Must
1520- * wait until new credentials are committed
1521- * by commit_creds() above
1522- */
1523- if (get_dumpable (current -> mm ) != SUID_DUMP_USER )
1524- perf_event_exit_task (current );
1525- /*
1526- * cred_guard_mutex must be held at least to this point to prevent
1527- * ptrace_attach() from altering our determination of the task's
1528- * credentials; any time after this it may be unlocked.
1529- */
1530- security_bprm_committed_creds (bprm );
1531- mutex_unlock (& current -> signal -> exec_update_mutex );
1532- mutex_unlock (& current -> signal -> cred_guard_mutex );
1533- }
1534- EXPORT_SYMBOL (install_exec_creds );
1535-
15361532/*
15371533 * determine how safe it is to execute the proposed program
15381534 * - the caller must hold ->cred_guard_mutex to protect against
0 commit comments