This file is indexed.

/usr/share/systemtap/runtime/linux/copy.c is in systemtap-common 3.1-3ubuntu0.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* -*- linux-c -*- 
 * Copy from user space functions
 * Copyright (C) 2005-2017 Red Hat Inc.
 * Copyright (C) 2005 Intel Corporation.
 *
 * This file is part of systemtap, and is free software.  You can
 * redistribute it and/or modify it under the terms of the GNU General
 * Public License (GPL); either version 2, or (at your option) any
 * later version.
 */

#ifndef _STAPLINUX_COPY_C_		/* -*- linux-c -*- */
#define _STAPLINUX_COPY_C_

/** @file copy.c
 * @brief Functions to copy from user space.
 */

/** @addtogroup copy Functions to copy from user space.
 * Functions to copy from user space.
 * None of these functions will sleep (for example to allow pages
 * to be swapped in). It is possible (although rare) that the data
 * in user space will not present and these functions will return an error.
 * @{
 */

/** Copy a NULL-terminated string from userspace.
 * On success, returns the length of the string (not including the trailing
 * NULL).
 *
 * If access to userspace fails, returns -EFAULT (some data may have been
 * copied).
 * @param dst Destination address, in kernel space.  This buffer must be at
 *         least <i>count</i> bytes long.
 * @param src Source address, in user space.
 * @param count Maximum number of bytes to copy, including the trailing NULL.
 * 
 * If <i>count</i> is smaller than the length of the string, copies 
 * <i>count</i> bytes and returns <i>count</i>.
 */

/* XXX: see also kread/uread in loc2c-runtime.h */
static long _stp_strncpy_from_user(char *dst, const char __user *src, long count)
{
	long res = -EFAULT;
        mm_segment_t _oldfs = get_fs();
        set_fs(USER_DS);
        pagefault_disable();
        /* XXX: The following preempt() manipulations should be
           redundant with probe entry/exit code, but for unknown
           reasons on RHEL5/6 conversions.exp intermittently fails
           without this.  */
        preempt_disable();
	if (!lookup_bad_addr(VERIFY_READ, (const unsigned long)src, count))
		res = strncpy_from_user(dst, src, count);
        preempt_enable_no_resched();
        pagefault_enable();
        set_fs(_oldfs);
	return res;
}

/** Copy a block of data from user space.
 *
 * If data could not be copied, this function will not modify the
 * destination.
 *
 * @param dst Destination address, in kernel space.
 * @param src Source address, in user space.
 * @param count Number of bytes to copy.
 * @return number of bytes that could not be copied. On success, 
 * this will be zero.
 *
 */

/* XXX: see also kread/uread in loc2c-runtime.h */
static unsigned long _stp_copy_from_user(char *dst, const char __user *src, unsigned long count)
{
	if (count) {
                mm_segment_t _oldfs = get_fs();
                set_fs(USER_DS);
                pagefault_disable();
		if (!lookup_bad_addr(VERIFY_READ, (const unsigned long)src, count))
			count = __copy_from_user_inatomic(dst, src, count);
		else
			/* Notice that if we fail, we don't modify
			 * the destination. In the failure case, we
			 * can't trust 'count' to be reasonable. */
			count = -EFAULT;
                pagefault_enable();
                set_fs(_oldfs);
	}
	return count;
}

/** @} */
#endif /* _STAPLINUX_COPY_C_ */