File tree Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -139,21 +139,15 @@ void escape_to_root(void)
139139{
140140 struct cred * cred ;
141141
142- rcu_read_lock ();
143-
144- do {
145- cred = (struct cred * )__task_cred ((current ));
146- if (!cred ) {
147- pr_err ("%s: cred is NULL! bailing out..\n" , __func__ );
148- rcu_read_unlock ();
149- return ;
150- }
151- } while (!get_cred_rcu (cred ));
142+ cred = prepare_creds ();
143+ if (!cred ) {
144+ pr_err ("%s: failed to allocate new cred.\n" , __func__ );
145+ return ;
146+ }
152147
153148 if (cred -> euid .val == 0 ) {
154149 pr_warn ("Already root, don't escape!\n" );
155- rcu_read_unlock ();
156- put_cred (cred );
150+ abort_creds (cred );
157151 return ;
158152 }
159153
@@ -187,8 +181,14 @@ void escape_to_root(void)
187181
188182 setup_groups (profile , cred );
189183
190- rcu_read_unlock ();
191- put_cred (cred );
184+ commit_creds (cred );
185+
186+ // FIXME: Maybe need to remove? The tests were fine.
187+ // reference: https://elixir.bootlin.com/linux/v5.4/source/fs/exec.c#L1456
188+ if (cred ) {
189+ pr_info ("%s: NULL-ing creds after committing..\n" , __func__ );
190+ cred = NULL ;
191+ }
192192
193193 // Refer to kernel/seccomp.c: seccomp_set_mode_strict
194194 // When disabling Seccomp, ensure that current->sighand->siglock is held during the operation.
@@ -912,4 +912,4 @@ void __init ksu_core_init(void)
912912
913913void ksu_core_exit (void )
914914{
915- }
915+ }
You can’t perform that action at this time.
0 commit comments