user_data2: re-work handling of skb->data
[smatch.git] / check_user_data2.c
blob24151e44cfeb6651b46d3cbe511ea99f0aa75862
1 /*
2 * Copyright (C) 2011 Dan Carpenter.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
19 * There are a couple checks that try to see if a variable
20 * comes from the user. It would be better to unify them
21 * into one place. Also it we should follow the data down
22 * the call paths. Hence this file.
25 #include "smatch.h"
26 #include "smatch_slist.h"
27 #include "smatch_extra.h"
29 static int my_id;
30 static int my_call_id;
32 STATE(called);
33 static bool func_gets_user_data;
35 static const char * kstr_funcs[] = {
36 "kstrtoull", "kstrtoll", "kstrtoul", "kstrtol", "kstrtouint",
37 "kstrtoint", "kstrtou64", "kstrtos64", "kstrtou32", "kstrtos32",
38 "kstrtou16", "kstrtos16", "kstrtou8", "kstrtos8", "kstrtoull_from_user"
39 "kstrtoll_from_user", "kstrtoul_from_user", "kstrtol_from_user",
40 "kstrtouint_from_user", "kstrtoint_from_user", "kstrtou16_from_user",
41 "kstrtos16_from_user", "kstrtou8_from_user", "kstrtos8_from_user",
42 "kstrtou64_from_user", "kstrtos64_from_user", "kstrtou32_from_user",
43 "kstrtos32_from_user",
46 static void set_points_to_user_data(struct expression *expr);
48 static struct stree *start_states;
49 static struct stree_stack *saved_stack;
50 static void save_start_states(struct statement *stmt)
52 start_states = clone_stree(__get_cur_stree());
55 static void free_start_states(void)
57 free_stree(&start_states);
60 static void match_save_states(struct expression *expr)
62 push_stree(&saved_stack, start_states);
63 start_states = NULL;
66 static void match_restore_states(struct expression *expr)
68 free_stree(&start_states);
69 start_states = pop_stree(&saved_stack);
72 static struct smatch_state *empty_state(struct sm_state *sm)
74 return alloc_estate_empty();
77 static void pre_merge_hook(struct sm_state *sm)
79 struct smatch_state *user;
80 struct smatch_state *extra;
81 struct range_list *rl;
83 extra = get_state(SMATCH_EXTRA, sm->name, sm->sym);
84 if (!extra || !estate_rl(extra))
85 return;
86 user = get_state(my_id, sm->name, sm->sym);
87 if (!user || !estate_rl(user))
88 return;
89 rl = rl_intersection(estate_rl(user), estate_rl(extra));
90 set_state(my_id, sm->name, sm->sym, alloc_estate_rl(clone_rl(rl)));
93 static void tag_inner_struct_members(struct expression *expr, struct symbol *member)
95 struct expression *edge_member;
96 struct symbol *base = get_real_base_type(member);
97 struct symbol *tmp;
99 if (member->ident)
100 expr = member_expression(expr, '.', member->ident);
102 FOR_EACH_PTR(base->symbol_list, tmp) {
103 struct symbol *type;
105 type = get_real_base_type(tmp);
106 if (!type)
107 continue;
109 if (type->type == SYM_UNION || type->type == SYM_STRUCT) {
110 tag_inner_struct_members(expr, tmp);
111 continue;
114 if (!tmp->ident)
115 continue;
117 edge_member = member_expression(expr, '.', tmp->ident);
118 set_state_expr(my_id, edge_member, alloc_estate_whole(type));
119 } END_FOR_EACH_PTR(tmp);
122 static void tag_struct_members(struct symbol *type, struct expression *expr)
124 struct symbol *tmp;
125 struct expression *member;
126 int op = '*';
128 if (expr->type == EXPR_PREOP && expr->op == '&') {
129 expr = strip_expr(expr->unop);
130 op = '.';
133 FOR_EACH_PTR(type->symbol_list, tmp) {
134 type = get_real_base_type(tmp);
135 if (!type)
136 continue;
138 if (type->type == SYM_UNION || type->type == SYM_STRUCT) {
139 tag_inner_struct_members(expr, tmp);
140 continue;
143 if (!tmp->ident)
144 continue;
146 member = member_expression(expr, op, tmp->ident);
147 set_state_expr(my_id, member, alloc_estate_whole(get_type(member)));
149 if (type->type == SYM_ARRAY)
150 set_points_to_user_data(member);
151 } END_FOR_EACH_PTR(tmp);
154 static void tag_base_type(struct expression *expr)
156 if (expr->type == EXPR_PREOP && expr->op == '&')
157 expr = strip_expr(expr->unop);
158 else
159 expr = deref_expression(expr);
160 set_state_expr(my_id, expr, alloc_estate_whole(get_type(expr)));
163 static void tag_as_user_data(struct expression *expr)
165 struct symbol *type;
167 expr = strip_expr(expr);
169 type = get_type(expr);
170 if (!type || type->type != SYM_PTR)
171 return;
172 type = get_real_base_type(type);
173 if (!type)
174 return;
175 if (type == &void_ctype) {
176 set_state_expr(my_id, deref_expression(expr), alloc_estate_whole(&ulong_ctype));
177 return;
179 if (type->type == SYM_BASETYPE)
180 tag_base_type(expr);
181 if (type->type == SYM_STRUCT) {
182 if (expr->type != EXPR_PREOP || expr->op != '&')
183 expr = deref_expression(expr);
184 else
185 set_state_expr(my_id, deref_expression(expr), alloc_estate_whole(&ulong_ctype));
186 tag_struct_members(type, expr);
190 static void match_user_copy(const char *fn, struct expression *expr, void *_param)
192 int param = PTR_INT(_param);
193 struct expression *dest;
195 func_gets_user_data = true;
197 dest = get_argument_from_call_expr(expr->args, param);
198 dest = strip_expr(dest);
199 if (!dest)
200 return;
201 tag_as_user_data(dest);
204 static void match_sscanf(const char *fn, struct expression *expr, void *unused)
206 struct expression *arg;
207 int i;
209 func_gets_user_data = true;
211 i = -1;
212 FOR_EACH_PTR(expr->args, arg) {
213 i++;
214 if (i < 2)
215 continue;
216 tag_as_user_data(arg);
217 } END_FOR_EACH_PTR(arg);
220 static int points_to_user_data(struct expression *expr)
222 struct smatch_state *state;
223 char buf[256];
224 struct symbol *sym;
225 char *name;
226 int ret = 0;
228 expr = strip_expr(expr);
230 if (expr->type == EXPR_BINOP && expr->op == '+') {
231 if (points_to_user_data(expr->left))
232 return 1;
233 if (points_to_user_data(expr->right))
234 return 1;
235 return 0;
238 name = expr_to_var_sym(expr, &sym);
239 if (!name || !sym)
240 goto free;
241 snprintf(buf, sizeof(buf), "*%s", name);
242 state = get_state(my_id, buf, sym);
243 if (state && estate_rl(state))
244 ret = 1;
245 free:
246 free_string(name);
247 return ret;
250 static void set_points_to_user_data(struct expression *expr)
252 char *name;
253 struct symbol *sym;
254 char buf[256];
256 name = expr_to_var_sym(expr, &sym);
257 if (!name || !sym)
258 goto free;
259 snprintf(buf, sizeof(buf), "*%s", name);
260 set_state(my_id, buf, sym, alloc_estate_whole(&llong_ctype));
261 free:
262 free_string(name);
265 static int is_skb_data(struct expression *expr)
267 struct symbol *sym;
269 expr = strip_expr(expr);
270 if (!expr)
271 return 0;
272 if (expr->type != EXPR_DEREF || expr->op != '.')
273 return 0;
275 if (!expr->member)
276 return 0;
277 if (strcmp(expr->member->name, "data") != 0)
278 return 0;
280 sym = expr_to_sym(expr->deref);
281 if (!sym)
282 return 0;
283 sym = get_real_base_type(sym);
284 if (!sym || sym->type != SYM_PTR)
285 return 0;
286 sym = get_real_base_type(sym);
287 if (!sym || sym->type != SYM_STRUCT || !sym->ident)
288 return 0;
289 if (strcmp(sym->ident->name, "sk_buff") != 0)
290 return 0;
292 return 1;
295 static int comes_from_skb_data(struct expression *expr)
297 expr = strip_expr(expr);
298 if (!expr || expr->type != EXPR_PREOP || expr->op != '*')
299 return 0;
301 expr = strip_expr(expr->unop);
302 if (expr->type == EXPR_BINOP && expr->op == '+')
303 expr = strip_expr(expr->left);
305 return is_skb_data(expr);
308 static int handle_struct_assignment(struct expression *expr)
310 struct expression *right;
311 struct symbol *left_type, *right_type;
313 left_type = get_type(expr->left);
314 if (!left_type || left_type->type != SYM_PTR)
315 return 0;
316 left_type = get_real_base_type(left_type);
317 if (!left_type || left_type->type != SYM_STRUCT)
318 return 0;
321 * Ignore struct to struct assignments because for those we look at the
322 * individual members.
324 right = strip_expr(expr->right);
325 right_type = get_type(right);
326 if (!right_type || right_type->type != SYM_PTR)
327 return 0;
329 /* If we are assigning struct members then normally that is handled
330 * by fake assignments, however if we cast one struct to a different
331 * of struct then we handle that here.
333 right_type = get_real_base_type(right_type);
334 if (right_type == left_type)
335 return 0;
337 if (!points_to_user_data(right) && !is_skb_data(right))
338 return 0;
340 tag_as_user_data(expr->left);
341 return 1;
344 static int handle_get_user(struct expression *expr)
346 char *name;
347 int ret = 0;
349 name = get_macro_name(expr->pos);
350 if (!name || strcmp(name, "get_user") != 0)
351 return 0;
353 name = expr_to_var(expr->right);
354 if (!name || strcmp(name, "__val_gu") != 0)
355 goto free;
356 set_state_expr(my_id, expr->left, alloc_estate_whole(get_type(expr->left)));
357 ret = 1;
358 free:
359 free_string(name);
360 return ret;
363 static void match_assign(struct expression *expr)
365 struct range_list *rl;
367 if (is_fake_call(expr->right))
368 return;
369 if (handle_get_user(expr))
370 return;
371 if (points_to_user_data(expr->right))
372 set_points_to_user_data(expr->left);
373 if (handle_struct_assignment(expr))
374 return;
376 if (!get_user_rl(expr->right, &rl))
377 goto clear_old_state;
379 rl = cast_rl(get_type(expr->left), rl);
380 set_state_expr(my_id, expr->left, alloc_estate_rl(rl));
382 return;
384 clear_old_state:
385 if (get_state_expr(my_id, expr->left))
386 set_state_expr(my_id, expr->left, alloc_estate_empty());
389 static void match_condition(struct expression *expr)
391 struct smatch_state *left_orig = NULL;
392 struct smatch_state *right_orig = NULL;
394 if (expr->type != EXPR_COMPARE || expr->op != SPECIAL_EQUAL)
395 return;
397 left_orig = get_state_expr(my_id, expr->left);
398 right_orig = get_state_expr(my_id, expr->right);
400 if (!left_orig && !right_orig)
401 return;
402 if (left_orig && right_orig)
403 return;
405 if (left_orig)
406 set_true_false_states_expr(my_id, expr->left, alloc_estate_empty(), NULL);
407 else
408 set_true_false_states_expr(my_id, expr->right, alloc_estate_empty(), NULL);
411 static void match_user_assign_function(const char *fn, struct expression *expr, void *unused)
413 func_gets_user_data = true;
415 tag_as_user_data(expr->left);
416 set_points_to_user_data(expr->left);
419 static void match_simple_strtoul(const char *fn, struct expression *expr, void *unused)
421 func_gets_user_data = true;
423 set_state_expr(my_id, expr->left, alloc_estate_whole(get_type(expr->left)));
426 static int get_user_macro_rl(struct expression *expr, struct range_list **rl)
428 char *macro;
430 if (!expr)
431 return 0;
432 macro = get_macro_name(expr->pos);
434 if (!macro)
435 return 0;
437 if (strcmp(macro, "ntohl") == 0) {
438 *rl = alloc_whole_rl(&uint_ctype);
439 return 1;
441 if (strcmp(macro, "ntohs") == 0) {
442 *rl = alloc_whole_rl(&ushort_ctype);
443 return 1;
445 return 0;
448 struct db_info {
449 struct range_list *rl;
450 struct expression *call;
452 static int returned_rl_callback(void *_info, int argc, char **argv, char **azColName)
454 struct db_info *db_info = _info;
455 struct range_list *rl;
456 char *return_ranges = argv[0];
457 char *user_ranges = argv[1];
458 struct expression *arg;
459 int comparison;
461 if (argc != 2)
462 return 0;
464 call_results_to_rl(db_info->call, get_type(db_info->call), user_ranges, &rl);
465 if (str_to_comparison_arg(return_ranges, db_info->call, &comparison, &arg) &&
466 comparison == SPECIAL_EQUAL) {
467 struct range_list *orig_rl;
469 if (!get_user_rl(arg, &orig_rl))
470 return 0;
471 rl = rl_intersection(rl, orig_rl);
472 if (!rl)
473 return 0;
475 db_info->rl = rl_union(db_info->rl, rl);
477 return 0;
480 static int has_user_data(struct symbol *sym)
482 struct sm_state *tmp;
484 FOR_EACH_MY_SM(my_id, __get_cur_stree(), tmp) {
485 if (tmp->sym == sym)
486 return 1;
487 } END_FOR_EACH_SM(tmp);
488 return 0;
491 static int we_pass_user_data(struct expression *call)
493 struct expression *arg;
494 struct symbol *sym;
496 FOR_EACH_PTR(call->args, arg) {
497 sym = expr_to_sym(arg);
498 if (!sym)
499 continue;
500 if (has_user_data(sym))
501 return 1;
502 } END_FOR_EACH_PTR(arg);
504 return 0;
507 static int db_returned_user_rl(struct expression *call, struct range_list **rl)
509 struct db_info db_info = {};
511 /* for function pointers assume everything is used */
512 if (call->fn->type != EXPR_SYMBOL)
513 return 0;
514 if (is_fake_call(call))
515 return 0;
517 db_info.call = call;
518 run_sql(&returned_rl_callback, &db_info,
519 "select return, value from return_states where %s and type = %d and parameter = -1 and key = '$';",
520 get_static_filter(call->fn->symbol), USER_DATA3_SET);
521 if (db_info.rl) {
522 func_gets_user_data = true;
523 *rl = db_info.rl;
524 return 1;
527 run_sql(&returned_rl_callback, &db_info,
528 "select return, value from return_states where %s and type = %d and parameter = -1 and key = '$';",
529 get_static_filter(call->fn->symbol), USER_DATA3);
530 if (db_info.rl) {
531 if (!we_pass_user_data(call))
532 return 0;
533 func_gets_user_data = true;
534 *rl = db_info.rl;
535 return 1;
538 return 0;
541 static int user_data_flag;
542 static struct range_list *var_user_rl(struct expression *expr)
544 struct smatch_state *state;
545 struct range_list *rl;
546 struct range_list *absolute_rl;
548 if (get_user_macro_rl(expr, &rl))
549 goto found;
551 if (comes_from_skb_data(expr)) {
552 rl = alloc_whole_rl(get_type(expr));
553 goto found;
556 state = get_state_expr(my_id, expr);
557 if (state && estate_rl(state)) {
558 rl = estate_rl(state);
559 goto found;
562 if (expr->type == EXPR_CALL && db_returned_user_rl(expr, &rl))
563 goto found;
565 return NULL;
566 found:
567 user_data_flag = 1;
568 absolute_rl = var_to_absolute_rl(expr);
569 return clone_rl(rl_intersection(rl, absolute_rl));
572 int get_user_rl(struct expression *expr, struct range_list **rl)
575 user_data_flag = 0;
576 custom_get_absolute_rl(expr, &var_user_rl, rl);
577 if (!user_data_flag) {
578 *rl = NULL;
579 return 0;
581 return 1;
584 int get_user_rl_var_sym(const char *name, struct symbol *sym, struct range_list **rl)
586 struct smatch_state *state;
588 state = get_state(my_id, name, sym);
589 if (state && estate_rl(state)) {
590 *rl = estate_rl(state);
591 return 1;
593 return 0;
596 static void match_call_info(struct expression *expr)
598 struct range_list *rl;
599 struct expression *arg;
600 int i = 0;
602 i = -1;
603 FOR_EACH_PTR(expr->args, arg) {
604 i++;
606 if (!get_user_rl(arg, &rl))
607 continue;
609 sql_insert_caller_info(expr, USER_DATA3, i, "$", show_rl(rl));
610 } END_FOR_EACH_PTR(arg);
613 static void struct_member_callback(struct expression *call, int param, char *printed_name, struct sm_state *sm)
615 struct smatch_state *state;
616 struct range_list *rl;
618 if (strcmp(sm->state->name, "") == 0)
619 return;
621 state = get_state(SMATCH_EXTRA, sm->name, sm->sym);
622 if (!state || !estate_rl(state))
623 rl = estate_rl(sm->state);
624 else
625 rl = rl_intersection(estate_rl(sm->state), estate_rl(state));
627 sql_insert_caller_info(call, USER_DATA3, param, printed_name, show_rl(rl));
630 static void set_param_user_data(const char *name, struct symbol *sym, char *key, char *value)
632 struct range_list *rl = NULL;
633 struct smatch_state *state;
634 struct symbol *type;
635 char fullname[256];
637 if (strcmp(key, "*$") == 0)
638 snprintf(fullname, sizeof(fullname), "*%s", name);
639 else if (strncmp(key, "$", 1) == 0)
640 snprintf(fullname, 256, "%s%s", name, key + 1);
641 else
642 return;
644 type = get_member_type_from_key(symbol_expression(sym), key);
646 /* if the caller passes a void pointer with user data */
647 if (strcmp(key, "*$") == 0 && type && type != &void_ctype) {
648 struct expression *expr = symbol_expression(sym);
650 tag_as_user_data(expr);
651 set_points_to_user_data(expr);
652 return;
654 str_to_rl(type, value, &rl);
655 state = alloc_estate_rl(rl);
656 set_state(my_id, fullname, sym, state);
659 static void set_called(const char *name, struct symbol *sym, char *key, char *value)
661 set_state(my_call_id, "this_function", NULL, &called);
664 static void match_syscall_definition(struct symbol *sym)
666 struct symbol *arg;
667 char *macro;
668 char *name;
669 int is_syscall = 0;
671 macro = get_macro_name(sym->pos);
672 if (macro &&
673 (strncmp("SYSCALL_DEFINE", macro, strlen("SYSCALL_DEFINE")) == 0 ||
674 strncmp("COMPAT_SYSCALL_DEFINE", macro, strlen("COMPAT_SYSCALL_DEFINE")) == 0))
675 is_syscall = 1;
677 name = get_function();
678 if (!option_no_db && get_state(my_call_id, "this_function", NULL) != &called) {
679 if (name && strncmp(name, "sys_", 4) == 0)
680 is_syscall = 1;
683 if (name && strncmp(name, "compat_sys_", 11) == 0)
684 is_syscall = 1;
686 if (!is_syscall)
687 return;
689 FOR_EACH_PTR(sym->ctype.base_type->arguments, arg) {
690 set_state(my_id, arg->ident->name, arg, alloc_estate_whole(get_real_base_type(arg)));
691 } END_FOR_EACH_PTR(arg);
694 static void set_to_user_data(struct expression *expr, char *key, char *value)
696 char *name;
697 struct symbol *sym;
698 struct symbol *type;
699 struct range_list *rl = NULL;
701 type = get_member_type_from_key(expr, key);
702 name = get_variable_from_key(expr, key, &sym);
703 if (!name || !sym)
704 goto free;
706 call_results_to_rl(expr, type, value, &rl);
708 set_state(my_id, name, sym, alloc_estate_rl(rl));
709 free:
710 free_string(name);
714 static void returns_param_user_data(struct expression *expr, int param, char *key, char *value)
716 struct expression *arg;
717 struct expression *call;
719 call = expr;
720 while (call->type == EXPR_ASSIGNMENT)
721 call = strip_expr(call->right);
722 if (call->type != EXPR_CALL)
723 return;
725 if (!we_pass_user_data(call))
726 return;
728 if (param == -1) {
729 if (expr->type != EXPR_ASSIGNMENT)
730 return;
731 set_to_user_data(expr->left, key, value);
732 return;
735 arg = get_argument_from_call_expr(call->args, param);
736 if (!arg)
737 return;
738 set_to_user_data(arg, key, value);
741 static void returns_param_user_data_set(struct expression *expr, int param, char *key, char *value)
743 struct expression *arg;
745 func_gets_user_data = true;
747 if (param == -1) {
748 if (expr->type != EXPR_ASSIGNMENT)
749 return;
750 set_to_user_data(expr->left, key, value);
751 return;
754 while (expr->type == EXPR_ASSIGNMENT)
755 expr = strip_expr(expr->right);
756 if (expr->type != EXPR_CALL)
757 return;
759 arg = get_argument_from_call_expr(expr->args, param);
760 if (!arg)
761 return;
762 set_to_user_data(arg, key, value);
765 static int has_empty_state(struct sm_state *sm)
767 struct sm_state *tmp;
769 FOR_EACH_PTR(sm->possible, tmp) {
770 if (!estate_rl(tmp->state))
771 return 1;
772 } END_FOR_EACH_PTR(tmp);
774 return 0;
777 static void param_set_to_user_data(int return_id, char *return_ranges, struct expression *expr)
779 struct sm_state *sm;
780 struct smatch_state *start_state;
781 struct range_list *rl;
782 int param;
783 const char *param_name;
785 FOR_EACH_MY_SM(my_id, __get_cur_stree(), sm) {
786 if (has_empty_state(sm))
787 continue;
789 param = get_param_num_from_sym(sm->sym);
790 if (param < 0) {
791 if (expr_to_sym(expr) == sm->sym)
792 param = -1;
793 else
794 continue;
797 /* The logic here was that if we were passed in a user data then
798 * we don't record that. It's like the difference between
799 * param_filter and param_set. When I think about it, I'm not
800 * sure it actually works. It's probably harmless because we
801 * checked earlier that we're not returning a parameter...
802 * Let's mark this as a TODO.
804 start_state = get_state_stree(start_states, my_id, sm->name, sm->sym);
805 if (start_state && estates_equiv(sm->state, start_state))
806 continue;
808 param_name = get_param_name(sm);
809 if (!param_name)
810 continue;
811 if (strcmp(param_name, "$") == 0)
812 continue;
814 sql_insert_return_states(return_id, return_ranges,
815 func_gets_user_data ? USER_DATA3_SET : USER_DATA3,
816 param, param_name, show_rl(estate_rl(sm->state)));
817 } END_FOR_EACH_SM(sm);
819 if (get_user_rl(expr, &rl)) {
820 sql_insert_return_states(return_id, return_ranges,
821 func_gets_user_data ? USER_DATA3_SET : USER_DATA3,
822 -1, "$", show_rl(rl));
826 static void match_function_def(struct symbol *sym)
828 func_gets_user_data = false;
831 void check_user_data2(int id)
833 int i;
835 my_id = id;
837 if (option_project != PROJ_KERNEL)
838 return;
840 add_hook(&match_function_def, FUNC_DEF_HOOK);
842 add_hook(&save_start_states, AFTER_DEF_HOOK);
843 add_hook(&free_start_states, AFTER_FUNC_HOOK);
844 add_hook(&match_save_states, INLINE_FN_START);
845 add_hook(&match_restore_states, INLINE_FN_END);
847 add_unmatched_state_hook(my_id, &empty_state);
848 add_pre_merge_hook(my_id, &pre_merge_hook);
849 add_merge_hook(my_id, &merge_estates);
851 add_function_hook("copy_from_user", &match_user_copy, INT_PTR(0));
852 add_function_hook("__copy_from_user", &match_user_copy, INT_PTR(0));
853 add_function_hook("memcpy_fromiovec", &match_user_copy, INT_PTR(0));
854 for (i = 0; i < ARRAY_SIZE(kstr_funcs); i++)
855 add_function_hook(kstr_funcs[i], &match_user_copy, INT_PTR(2));
857 add_function_assign_hook("simple_strtol", &match_simple_strtoul, NULL);
858 add_function_assign_hook("simple_strtoll", &match_simple_strtoul, NULL);
859 add_function_assign_hook("simple_strtoul", &match_simple_strtoul, NULL);
860 add_function_assign_hook("simple_strtoull", &match_simple_strtoul, NULL);
862 add_function_hook("sscanf", &match_sscanf, NULL);
864 add_function_assign_hook("memdup_user", &match_user_assign_function, NULL);
865 add_function_assign_hook("kmap_atomic", &match_user_assign_function, NULL);
866 add_function_assign_hook("skb_network_header", &match_user_assign_function, NULL);
868 add_hook(&match_syscall_definition, AFTER_DEF_HOOK);
870 add_hook(&match_assign, ASSIGNMENT_HOOK);
871 add_hook(&match_condition, CONDITION_HOOK);
873 add_hook(&match_call_info, FUNCTION_CALL_HOOK);
874 add_member_info_callback(my_id, struct_member_callback);
875 select_caller_info_hook(set_param_user_data, USER_DATA3);
876 select_return_states_hook(USER_DATA3, &returns_param_user_data);
877 select_return_states_hook(USER_DATA3_SET, &returns_param_user_data_set);
878 add_split_return_callback(&param_set_to_user_data);
881 void check_user_data3(int id)
883 my_call_id = id;
885 if (option_project != PROJ_KERNEL)
886 return;
887 select_caller_info_hook(set_called, INTERNAL);