xref: /illumos-gate/usr/src/tools/smatch/src/validation/sm_user_data4.c (revision 4c87aefe8930bd07275b8dd2e96ea5f24d93a52e)
1 #include "check_debug.h"
2 
3 int copy_from_user(void *dest, void *src, int size);
4 
5 struct ear {
6 	int x, y;
7 };
8 
9 void *src;
10 int returns_user_data(void)
11 {
12 	int x;
13 
14 	copy_from_user(&x, src, sizeof(int));
15 	return x;
16 }
17 
18 struct ear *dest;
19 struct ear *returns_user_member(void)
20 {
21 	copy_from_user(&dest->x, src, sizeof(int));
22 	return dest;
23 }
24 void test(void)
25 {
26 	struct ear *p;
27 	int x;
28 
29 	x = returns_user_data();
30 	__smatch_user_rl(x);
31 	p = returns_user_member();
32 	__smatch_user_rl(p);
33 	__smatch_user_rl(p->x);
34 }
35 
36 /*
37  * check-name: smatch user data #4
38  * check-command: smatch -p=kernel -I.. sm_user_data4.c
39  *
40  * check-output-start
41 sm_user_data4.c:30 test() user rl: 'x' = 's32min-s32max'
42 sm_user_data4.c:32 test() user rl: 'p' = ''
43 sm_user_data4.c:33 test() user rl: 'p->x' = 's32min-s32max'
44  * check-output-end
45  */
46