@@ -110,38 +110,14 @@ static void setup_groups(struct root_profile *profile, struct cred *cred)
110
110
set_groups (cred , group_info );
111
111
}
112
112
113
- static void disable_seccomp ()
114
- {
115
- assert_spin_locked (& current -> sighand -> siglock );
116
- // disable seccomp
117
- #if defined(CONFIG_GENERIC_ENTRY ) && \
118
- LINUX_VERSION_CODE >= KERNEL_VERSION (5 , 11 , 0 )
119
- current_thread_info ()-> syscall_work &= ~SYSCALL_WORK_SECCOMP ;
120
- #else
121
- current_thread_info ()-> flags &= ~(TIF_SECCOMP | _TIF_SECCOMP );
122
- #endif
123
-
124
- #ifdef CONFIG_SECCOMP
125
- current -> seccomp .mode = 0 ;
126
- current -> seccomp .filter = NULL ;
127
- #else
128
- #endif
129
- }
130
-
131
113
void escape_to_root (void )
132
114
{
133
115
struct cred * cred ;
134
116
135
- rcu_read_lock ();
136
-
137
- do {
138
- cred = (struct cred * )__task_cred ((current ));
139
- BUG_ON (!cred );
140
- } while (!get_cred_rcu (cred ));
117
+ cred = (struct cred * )__task_cred (current );
141
118
142
119
if (cred -> euid .val == 0 ) {
143
120
pr_warn ("Already root, don't escape!\n" );
144
- rcu_read_unlock ();
145
121
return ;
146
122
}
147
123
struct root_profile * profile = ksu_get_root_profile (cred -> uid .val );
@@ -175,15 +151,21 @@ void escape_to_root(void)
175
151
memcpy (& cred -> cap_ambient , & profile -> capabilities .effective ,
176
152
sizeof (cred -> cap_ambient ));
177
153
178
- setup_groups (profile , cred );
154
+ // disable seccomp
155
+ #if defined(CONFIG_GENERIC_ENTRY ) && \
156
+ LINUX_VERSION_CODE >= KERNEL_VERSION (5 , 11 , 0 )
157
+ current_thread_info ()-> syscall_work &= ~SYSCALL_WORK_SECCOMP ;
158
+ #else
159
+ current_thread_info ()-> flags &= ~(TIF_SECCOMP | _TIF_SECCOMP );
160
+ #endif
179
161
180
- rcu_read_unlock ();
162
+ #ifdef CONFIG_SECCOMP
163
+ current -> seccomp .mode = 0 ;
164
+ current -> seccomp .filter = NULL ;
165
+ #else
166
+ #endif
181
167
182
- // Refer to kernel/seccomp.c: seccomp_set_mode_strict
183
- // When disabling Seccomp, ensure that current->sighand->siglock is held during the operation.
184
- spin_lock_irq (& current -> sighand -> siglock );
185
- disable_seccomp ();
186
- spin_unlock_irq (& current -> sighand -> siglock );
168
+ setup_groups (profile , cred );
187
169
188
170
setup_selinux (profile -> selinux_domain );
189
171
}
0 commit comments