Linux Audio

Check our new training course

Loading...
v5.9
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * Copyright (C) 2015 Thomas Meyer (thomas@m3y3r.de)
 4 * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
 
 5 */
 6
 7#include <signal.h>
 8#include <sched.h>
 9#include <asm/unistd.h>
10#include <sys/time.h>
11#include <as-layout.h>
12#include <ptrace_user.h>
13#include <stub-data.h>
14#include <sysdep/stub.h>
15
16/*
17 * This is in a separate file because it needs to be compiled with any
18 * extraneous gcc flags (-pg, -fprofile-arcs, -ftest-coverage) disabled
19 *
20 * Use UM_KERN_PAGE_SIZE instead of PAGE_SIZE because that calls getpagesize
21 * on some systems.
22 */
23
24void __attribute__ ((__section__ (".__syscall_stub")))
25stub_clone_handler(void)
26{
27	struct stub_data *data = (struct stub_data *) STUB_DATA;
28	long err;
29
30	err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD,
31			    STUB_DATA + UM_KERN_PAGE_SIZE / 2 - sizeof(void *));
32	if (err != 0)
33		goto out;
34
35	err = stub_syscall4(__NR_ptrace, PTRACE_TRACEME, 0, 0, 0);
 
 
 
 
 
36	if (err)
37		goto out;
38
39	remap_stack(data->fd, data->offset);
40	goto done;
41
42 out:
43	/*
44	 * save current result.
45	 * Parent: pid;
46	 * child: retcode of mmap already saved and it jumps around this
47	 * assignment
48	 */
49	data->err = err;
50 done:
51	trap_myself();
52}
v3.15
 
 1/*
 
 2 * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
 3 * Licensed under the GPL
 4 */
 5
 6#include <signal.h>
 7#include <sched.h>
 8#include <asm/unistd.h>
 9#include <sys/time.h>
10#include <as-layout.h>
11#include <ptrace_user.h>
12#include <stub-data.h>
13#include <sysdep/stub.h>
14
15/*
16 * This is in a separate file because it needs to be compiled with any
17 * extraneous gcc flags (-pg, -fprofile-arcs, -ftest-coverage) disabled
18 *
19 * Use UM_KERN_PAGE_SIZE instead of PAGE_SIZE because that calls getpagesize
20 * on some systems.
21 */
22
23void __attribute__ ((__section__ (".__syscall_stub")))
24stub_clone_handler(void)
25{
26	struct stub_data *data = (struct stub_data *) STUB_DATA;
27	long err;
28
29	err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD,
30			    STUB_DATA + UM_KERN_PAGE_SIZE / 2 - sizeof(void *));
31	if (err != 0)
32		goto out;
33
34	err = stub_syscall4(__NR_ptrace, PTRACE_TRACEME, 0, 0, 0);
35	if (err)
36		goto out;
37
38	err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL,
39			    (long) &data->timer, 0);
40	if (err)
41		goto out;
42
43	remap_stack(data->fd, data->offset);
44	goto done;
45
46 out:
47	/*
48	 * save current result.
49	 * Parent: pid;
50	 * child: retcode of mmap already saved and it jumps around this
51	 * assignment
52	 */
53	data->err = err;
54 done:
55	trap_myself();
56}