2 * Copyright (C) 2010 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
26 {.name_param
= 0, .mode_param
= 1},
27 {.name_param
= 1, .mode_param
= 2},
32 static void match_create(const char *fn
, struct expression
*expr
, void *_param_type
)
34 struct expression
*arg_expr
;
37 int idx
= PTR_INT(_param_type
);
39 arg_expr
= get_argument_from_call_expr(expr
->args
, param_index
[idx
].mode_param
);
40 if (!get_implied_value(arg_expr
, &sval
))
42 if (!(sval
.uvalue
& S_IWOTH
))
44 arg_expr
= get_argument_from_call_expr(expr
->args
, param_index
[idx
].name_param
);
45 name
= expr_to_var(arg_expr
);
46 sm_msg("warn: proc file '%s' is world writable", name
);
50 void check_proc_create(int id
)
53 if (option_project
!= PROJ_KERNEL
)
56 add_function_hook("proc_create", &match_create
, INT_PTR(0));
57 add_function_hook("create_proc_entry", &match_create
, INT_PTR(0));
58 add_function_hook("proc_create_data", &match_create
, INT_PTR(0));
59 add_function_hook("proc_net_fops_create", match_create
, INT_PTR(1));