buf_comparison: record if we pass an ARRAY_SIZE to the function
[smatch.git] / check_user_data2.c
blobad032830b1abe83c0218bb639a86775912b3fe04
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 if (expr->type == EXPR_BINOP && expr->op == '+')
270 return is_skb_data(expr->left);
272 expr = strip_expr(expr);
273 if (!expr)
274 return 0;
275 if (expr->type != EXPR_DEREF || expr->op != '.')
276 return 0;
278 if (!expr->member)
279 return 0;
280 if (strcmp(expr->member->name, "data") != 0)
281 return 0;
283 sym = expr_to_sym(expr->deref);
284 if (!sym)
285 return 0;
286 sym = get_real_base_type(sym);
287 if (!sym || sym->type != SYM_PTR)
288 return 0;
289 sym = get_real_base_type(sym);
290 if (!sym || sym->type != SYM_STRUCT || !sym->ident)
291 return 0;
292 if (strcmp(sym->ident->name, "sk_buff") != 0)
293 return 0;
295 return 1;
298 static int comes_from_skb_data(struct expression *expr)
300 expr = strip_expr(expr);
301 if (!expr || expr->type != EXPR_PREOP || expr->op != '*')
302 return 0;
304 expr = strip_expr(expr->unop);
305 if (expr->type == EXPR_BINOP && expr->op == '+')
306 expr = strip_expr(expr->left);
308 return is_skb_data(expr);
311 static int handle_struct_assignment(struct expression *expr)
313 struct expression *right;
314 struct symbol *left_type, *right_type;
316 left_type = get_type(expr->left);
317 if (!left_type || left_type->type != SYM_PTR)
318 return 0;
319 left_type = get_real_base_type(left_type);
320 if (!left_type || left_type->type != SYM_STRUCT)
321 return 0;
324 * Ignore struct to struct assignments because for those we look at the
325 * individual members.
327 right = strip_expr(expr->right);
328 right_type = get_type(right);
329 if (!right_type || right_type->type != SYM_PTR)
330 return 0;
332 /* If we are assigning struct members then normally that is handled
333 * by fake assignments, however if we cast one struct to a different
334 * of struct then we handle that here.
336 right_type = get_real_base_type(right_type);
337 if (right_type == left_type)
338 return 0;
340 if (!points_to_user_data(right) && !is_skb_data(right))
341 return 0;
343 tag_as_user_data(expr->left);
344 return 1;
347 static int handle_get_user(struct expression *expr)
349 char *name;
350 int ret = 0;
352 name = get_macro_name(expr->pos);
353 if (!name || strcmp(name, "get_user") != 0)
354 return 0;
356 name = expr_to_var(expr->right);
357 if (!name || strcmp(name, "__val_gu") != 0)
358 goto free;
359 set_state_expr(my_id, expr->left, alloc_estate_whole(get_type(expr->left)));
360 ret = 1;
361 free:
362 free_string(name);
363 return ret;
366 static void match_assign(struct expression *expr)
368 struct range_list *rl;
370 if (is_fake_call(expr->right))
371 return;
372 if (handle_get_user(expr))
373 return;
374 if (points_to_user_data(expr->right))
375 set_points_to_user_data(expr->left);
376 if (handle_struct_assignment(expr))
377 return;
379 if (!get_user_rl(expr->right, &rl))
380 goto clear_old_state;
382 rl = cast_rl(get_type(expr->left), rl);
383 set_state_expr(my_id, expr->left, alloc_estate_rl(rl));
385 return;
387 clear_old_state:
388 if (get_state_expr(my_id, expr->left))
389 set_state_expr(my_id, expr->left, alloc_estate_empty());
392 static void match_condition(struct expression *expr)
394 struct smatch_state *left_orig = NULL;
395 struct smatch_state *right_orig = NULL;
397 if (expr->type != EXPR_COMPARE || expr->op != SPECIAL_EQUAL)
398 return;
400 left_orig = get_state_expr(my_id, expr->left);
401 right_orig = get_state_expr(my_id, expr->right);
403 if (!left_orig && !right_orig)
404 return;
405 if (left_orig && right_orig)
406 return;
408 if (left_orig)
409 set_true_false_states_expr(my_id, expr->left, alloc_estate_empty(), NULL);
410 else
411 set_true_false_states_expr(my_id, expr->right, alloc_estate_empty(), NULL);
414 static void match_user_assign_function(const char *fn, struct expression *expr, void *unused)
416 func_gets_user_data = true;
418 tag_as_user_data(expr->left);
419 set_points_to_user_data(expr->left);
422 static void match_simple_strtoul(const char *fn, struct expression *expr, void *unused)
424 func_gets_user_data = true;
426 set_state_expr(my_id, expr->left, alloc_estate_whole(get_type(expr->left)));
429 static int get_user_macro_rl(struct expression *expr, struct range_list **rl)
431 char *macro;
433 if (!expr)
434 return 0;
435 macro = get_macro_name(expr->pos);
437 if (!macro)
438 return 0;
440 if (strcmp(macro, "ntohl") == 0) {
441 *rl = alloc_whole_rl(&uint_ctype);
442 return 1;
444 if (strcmp(macro, "ntohs") == 0) {
445 *rl = alloc_whole_rl(&ushort_ctype);
446 return 1;
448 return 0;
451 struct db_info {
452 struct range_list *rl;
453 struct expression *call;
455 static int returned_rl_callback(void *_info, int argc, char **argv, char **azColName)
457 struct db_info *db_info = _info;
458 struct range_list *rl;
459 char *return_ranges = argv[0];
460 char *user_ranges = argv[1];
461 struct expression *arg;
462 int comparison;
464 if (argc != 2)
465 return 0;
467 call_results_to_rl(db_info->call, get_type(db_info->call), user_ranges, &rl);
468 if (str_to_comparison_arg(return_ranges, db_info->call, &comparison, &arg) &&
469 comparison == SPECIAL_EQUAL) {
470 struct range_list *orig_rl;
472 if (!get_user_rl(arg, &orig_rl))
473 return 0;
474 rl = rl_intersection(rl, orig_rl);
475 if (!rl)
476 return 0;
478 db_info->rl = rl_union(db_info->rl, rl);
480 return 0;
483 static int has_user_data(struct symbol *sym)
485 struct sm_state *tmp;
487 FOR_EACH_MY_SM(my_id, __get_cur_stree(), tmp) {
488 if (tmp->sym == sym)
489 return 1;
490 } END_FOR_EACH_SM(tmp);
491 return 0;
494 static int we_pass_user_data(struct expression *call)
496 struct expression *arg;
497 struct symbol *sym;
499 FOR_EACH_PTR(call->args, arg) {
500 sym = expr_to_sym(arg);
501 if (!sym)
502 continue;
503 if (has_user_data(sym))
504 return 1;
505 } END_FOR_EACH_PTR(arg);
507 return 0;
510 static int db_returned_user_rl(struct expression *call, struct range_list **rl)
512 struct db_info db_info = {};
514 /* for function pointers assume everything is used */
515 if (call->fn->type != EXPR_SYMBOL)
516 return 0;
517 if (is_fake_call(call))
518 return 0;
520 db_info.call = call;
521 run_sql(&returned_rl_callback, &db_info,
522 "select return, value from return_states where %s and type = %d and parameter = -1 and key = '$';",
523 get_static_filter(call->fn->symbol), USER_DATA3_SET);
524 if (db_info.rl) {
525 func_gets_user_data = true;
526 *rl = db_info.rl;
527 return 1;
530 run_sql(&returned_rl_callback, &db_info,
531 "select return, value from return_states where %s and type = %d and parameter = -1 and key = '$';",
532 get_static_filter(call->fn->symbol), USER_DATA3);
533 if (db_info.rl) {
534 if (!we_pass_user_data(call))
535 return 0;
536 *rl = db_info.rl;
537 return 1;
540 return 0;
543 static int user_data_flag;
544 static struct range_list *var_user_rl(struct expression *expr)
546 struct smatch_state *state;
547 struct range_list *rl;
548 struct range_list *absolute_rl;
550 if (get_user_macro_rl(expr, &rl))
551 goto found;
553 if (comes_from_skb_data(expr)) {
554 rl = alloc_whole_rl(get_type(expr));
555 goto found;
558 state = get_state_expr(my_id, expr);
559 if (state && estate_rl(state)) {
560 rl = estate_rl(state);
561 goto found;
564 if (expr->type == EXPR_CALL && db_returned_user_rl(expr, &rl))
565 goto found;
567 return NULL;
568 found:
569 user_data_flag = 1;
570 absolute_rl = var_to_absolute_rl(expr);
571 return clone_rl(rl_intersection(rl, absolute_rl));
574 int get_user_rl(struct expression *expr, struct range_list **rl)
577 user_data_flag = 0;
578 custom_get_absolute_rl(expr, &var_user_rl, rl);
579 if (!user_data_flag) {
580 *rl = NULL;
581 return 0;
583 return 1;
586 int get_user_rl_var_sym(const char *name, struct symbol *sym, struct range_list **rl)
588 struct smatch_state *state;
590 state = get_state(my_id, name, sym);
591 if (state && estate_rl(state)) {
592 *rl = estate_rl(state);
593 return 1;
595 return 0;
598 static void match_call_info(struct expression *expr)
600 struct range_list *rl;
601 struct expression *arg;
602 int i = 0;
604 i = -1;
605 FOR_EACH_PTR(expr->args, arg) {
606 i++;
608 if (!get_user_rl(arg, &rl))
609 continue;
611 sql_insert_caller_info(expr, USER_DATA3, i, "$", show_rl(rl));
612 } END_FOR_EACH_PTR(arg);
615 static void struct_member_callback(struct expression *call, int param, char *printed_name, struct sm_state *sm)
617 struct smatch_state *state;
618 struct range_list *rl;
620 if (strcmp(sm->state->name, "") == 0)
621 return;
623 state = get_state(SMATCH_EXTRA, sm->name, sm->sym);
624 if (!state || !estate_rl(state))
625 rl = estate_rl(sm->state);
626 else
627 rl = rl_intersection(estate_rl(sm->state), estate_rl(state));
629 sql_insert_caller_info(call, USER_DATA3, param, printed_name, show_rl(rl));
632 static void set_param_user_data(const char *name, struct symbol *sym, char *key, char *value)
634 struct range_list *rl = NULL;
635 struct smatch_state *state;
636 struct symbol *type;
637 char fullname[256];
639 if (strcmp(key, "*$") == 0)
640 snprintf(fullname, sizeof(fullname), "*%s", name);
641 else if (strncmp(key, "$", 1) == 0)
642 snprintf(fullname, 256, "%s%s", name, key + 1);
643 else
644 return;
646 type = get_member_type_from_key(symbol_expression(sym), key);
648 /* if the caller passes a void pointer with user data */
649 if (strcmp(key, "*$") == 0 && type && type != &void_ctype) {
650 struct expression *expr = symbol_expression(sym);
652 tag_as_user_data(expr);
653 set_points_to_user_data(expr);
654 return;
656 str_to_rl(type, value, &rl);
657 state = alloc_estate_rl(rl);
658 set_state(my_id, fullname, sym, state);
661 static void set_called(const char *name, struct symbol *sym, char *key, char *value)
663 set_state(my_call_id, "this_function", NULL, &called);
666 static void match_syscall_definition(struct symbol *sym)
668 struct symbol *arg;
669 char *macro;
670 char *name;
671 int is_syscall = 0;
673 macro = get_macro_name(sym->pos);
674 if (macro &&
675 (strncmp("SYSCALL_DEFINE", macro, strlen("SYSCALL_DEFINE")) == 0 ||
676 strncmp("COMPAT_SYSCALL_DEFINE", macro, strlen("COMPAT_SYSCALL_DEFINE")) == 0))
677 is_syscall = 1;
679 name = get_function();
680 if (!option_no_db && get_state(my_call_id, "this_function", NULL) != &called) {
681 if (name && strncmp(name, "sys_", 4) == 0)
682 is_syscall = 1;
685 if (name && strncmp(name, "compat_sys_", 11) == 0)
686 is_syscall = 1;
688 if (!is_syscall)
689 return;
691 FOR_EACH_PTR(sym->ctype.base_type->arguments, arg) {
692 set_state(my_id, arg->ident->name, arg, alloc_estate_whole(get_real_base_type(arg)));
693 } END_FOR_EACH_PTR(arg);
696 static void set_to_user_data(struct expression *expr, char *key, char *value)
698 char *name;
699 struct symbol *sym;
700 struct symbol *type;
701 struct range_list *rl = NULL;
703 type = get_member_type_from_key(expr, key);
704 name = get_variable_from_key(expr, key, &sym);
705 if (!name || !sym)
706 goto free;
708 call_results_to_rl(expr, type, value, &rl);
710 set_state(my_id, name, sym, alloc_estate_rl(rl));
711 free:
712 free_string(name);
716 static void returns_param_user_data(struct expression *expr, int param, char *key, char *value)
718 struct expression *arg;
719 struct expression *call;
721 call = expr;
722 while (call->type == EXPR_ASSIGNMENT)
723 call = strip_expr(call->right);
724 if (call->type != EXPR_CALL)
725 return;
727 if (!we_pass_user_data(call))
728 return;
730 if (param == -1) {
731 if (expr->type != EXPR_ASSIGNMENT)
732 return;
733 set_to_user_data(expr->left, key, value);
734 return;
737 arg = get_argument_from_call_expr(call->args, param);
738 if (!arg)
739 return;
740 set_to_user_data(arg, key, value);
743 static void returns_param_user_data_set(struct expression *expr, int param, char *key, char *value)
745 struct expression *arg;
747 func_gets_user_data = true;
749 if (param == -1) {
750 if (expr->type != EXPR_ASSIGNMENT)
751 return;
752 set_to_user_data(expr->left, key, value);
753 return;
756 while (expr->type == EXPR_ASSIGNMENT)
757 expr = strip_expr(expr->right);
758 if (expr->type != EXPR_CALL)
759 return;
761 arg = get_argument_from_call_expr(expr->args, param);
762 if (!arg)
763 return;
764 set_to_user_data(arg, key, value);
767 static int has_empty_state(struct sm_state *sm)
769 struct sm_state *tmp;
771 FOR_EACH_PTR(sm->possible, tmp) {
772 if (!estate_rl(tmp->state))
773 return 1;
774 } END_FOR_EACH_PTR(tmp);
776 return 0;
779 static void param_set_to_user_data(int return_id, char *return_ranges, struct expression *expr)
781 struct sm_state *sm;
782 struct smatch_state *start_state;
783 struct range_list *rl;
784 int param;
785 const char *param_name;
787 FOR_EACH_MY_SM(my_id, __get_cur_stree(), sm) {
788 if (has_empty_state(sm))
789 continue;
791 param = get_param_num_from_sym(sm->sym);
792 if (param < 0) {
793 if (expr_to_sym(expr) == sm->sym)
794 param = -1;
795 else
796 continue;
799 /* The logic here was that if we were passed in a user data then
800 * we don't record that. It's like the difference between
801 * param_filter and param_set. When I think about it, I'm not
802 * sure it actually works. It's probably harmless because we
803 * checked earlier that we're not returning a parameter...
804 * Let's mark this as a TODO.
806 start_state = get_state_stree(start_states, my_id, sm->name, sm->sym);
807 if (start_state && rl_equiv(estate_rl(sm->state), estate_rl(start_state)))
808 continue;
810 param_name = get_param_name(sm);
811 if (!param_name)
812 continue;
813 if (strcmp(param_name, "$") == 0)
814 continue;
816 sql_insert_return_states(return_id, return_ranges,
817 func_gets_user_data ? USER_DATA3_SET : USER_DATA3,
818 param, param_name, show_rl(estate_rl(sm->state)));
819 } END_FOR_EACH_SM(sm);
821 if (get_user_rl(expr, &rl)) {
822 sql_insert_return_states(return_id, return_ranges,
823 func_gets_user_data ? USER_DATA3_SET : USER_DATA3,
824 -1, "$", show_rl(rl));
828 static struct int_stack *gets_data_stack;
829 static void match_function_def(struct symbol *sym)
831 func_gets_user_data = false;
834 static void match_inline_start(struct expression *expr)
836 push_int(&gets_data_stack, func_gets_user_data);
839 static void match_inline_end(struct expression *expr)
841 func_gets_user_data = pop_int(&gets_data_stack);
844 void check_user_data2(int id)
846 int i;
848 my_id = id;
850 if (option_project != PROJ_KERNEL)
851 return;
853 add_hook(&match_function_def, FUNC_DEF_HOOK);
854 add_hook(&match_inline_start, INLINE_FN_START);
855 add_hook(&match_inline_end, INLINE_FN_END);
857 add_hook(&save_start_states, AFTER_DEF_HOOK);
858 add_hook(&free_start_states, AFTER_FUNC_HOOK);
859 add_hook(&match_save_states, INLINE_FN_START);
860 add_hook(&match_restore_states, INLINE_FN_END);
862 add_unmatched_state_hook(my_id, &empty_state);
863 add_pre_merge_hook(my_id, &pre_merge_hook);
864 add_merge_hook(my_id, &merge_estates);
866 add_function_hook("copy_from_user", &match_user_copy, INT_PTR(0));
867 add_function_hook("__copy_from_user", &match_user_copy, INT_PTR(0));
868 add_function_hook("memcpy_fromiovec", &match_user_copy, INT_PTR(0));
869 for (i = 0; i < ARRAY_SIZE(kstr_funcs); i++)
870 add_function_hook(kstr_funcs[i], &match_user_copy, INT_PTR(2));
872 add_function_assign_hook("simple_strtol", &match_simple_strtoul, NULL);
873 add_function_assign_hook("simple_strtoll", &match_simple_strtoul, NULL);
874 add_function_assign_hook("simple_strtoul", &match_simple_strtoul, NULL);
875 add_function_assign_hook("simple_strtoull", &match_simple_strtoul, NULL);
877 add_function_hook("sscanf", &match_sscanf, NULL);
879 add_function_assign_hook("memdup_user", &match_user_assign_function, NULL);
880 add_function_assign_hook("kmap_atomic", &match_user_assign_function, NULL);
881 add_function_assign_hook("skb_network_header", &match_user_assign_function, NULL);
883 add_hook(&match_syscall_definition, AFTER_DEF_HOOK);
885 add_hook(&match_assign, ASSIGNMENT_HOOK);
886 add_hook(&match_condition, CONDITION_HOOK);
888 add_hook(&match_call_info, FUNCTION_CALL_HOOK);
889 add_member_info_callback(my_id, struct_member_callback);
890 select_caller_info_hook(set_param_user_data, USER_DATA3);
891 select_return_states_hook(USER_DATA3, &returns_param_user_data);
892 select_return_states_hook(USER_DATA3_SET, &returns_param_user_data_set);
893 add_split_return_callback(&param_set_to_user_data);
896 void check_user_data3(int id)
898 my_call_id = id;
900 if (option_project != PROJ_KERNEL)
901 return;
902 select_caller_info_hook(set_called, INTERNAL);