File tree Expand file tree Collapse file tree 1 file changed +11
-14
lines changed Expand file tree Collapse file tree 1 file changed +11
-14
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,7 @@ void escape_to_root(void)
187181
188182 setup_groups (profile , cred );
189183
190- rcu_read_unlock ();
191- put_cred (cred );
184+ commit_creds (cred );
192185
193186 // Refer to kernel/seccomp.c: seccomp_set_mode_strict
194187 // When disabling Seccomp, ensure that current->sighand->siglock is held during the operation.
@@ -197,6 +190,10 @@ void escape_to_root(void)
197190 spin_unlock_irq (& current -> sighand -> siglock );
198191
199192 setup_selinux (profile -> selinux_domain );
193+
194+ // https://elixir.bootlin.com/linux/v5.4/source/fs/exec.c#L1456
195+ pr_info ("%s: freeing creds" , __func__ );
196+ cred = NULL ;
200197}
201198
202199int ksu_handle_rename (struct dentry * old_dentry , struct dentry * new_dentry )
You can’t perform that action at this time.
0 commit comments