[CRIU] [PATCH 7/9] seccomp: test -- Add seccomp_filter_threads
Dmitry Safonov
0x7f454c46 at gmail.com
Fri May 4 23:17:54 MSK 2018
2018-05-04 21:11 GMT+01:00 Cyrill Gorcunov <gorcunov at gmail.com>:
> On Fri, May 04, 2018 at 08:51:32PM +0100, Dmitry Safonov wrote:
>> 2018-04-26 21:14 GMT+01:00 Cyrill Gorcunov <gorcunov at gmail.com>:
>> [..]
>> > + if (pid == 0) {
>> > + pthread_t thread;
>> > + void *p = NULL;
>> > +
>> > + zdtm_seccomp = 1;
>> > +
>> > + pthread_create(&thread, NULL, thread_main, NULL);
>> > + if (pthread_join(thread, &p) != 0) {
>> > + pr_perror("pthread_join");
>> > + exit(1);
>> > + }
>> > +
>> > + syscall(__NR_exit, p);
>>
>> Hmm.
>> a) why syscall() and not _exit()?
>
> Because here we're already inside filtering mode so we should not
> rely on any library calls, plain syscalls only.
Fair enough.
>> b) (void *p) is 64-bit long on 64-bit platfoms, exit() has (int)
>> parameter == 32-bit long.
>> Does this work as expected without a cast?
>
> It is a pointer with value 1 due to pthread_join specifics.
> Works without a cast.
Hmm, I got the idea where the pointer comes from.
I'm about:
SYSCALL_DEFINE1(exit, int, error_code)
{
do_exit((error_code&0xff)<<8);
}
I think it should work on little-endian, but maybe
simplify it with syscall(__NR_exit, !!p), hmm?
--
Dmitry
More information about the CRIU
mailing list