aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2014-05-23 12:43:58 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-23 16:48:05 -0400
commitb1fcd35cf53553a0a3ef949b05106d921446abc3 (patch)
tree4784eb248a9705f2eae7dcb10968497f0559499f /drivers/net
parent8556ce79d5986a87fee4c29300b4efee07c0f15e (diff)
net: filter: let unattached filters use sock_fprog_kern
The sk_unattached_filter_create() API is used by BPF filters that are not directly attached or related to sockets, and are used in team, ptp, xt_bpf, cls_bpf, etc. As such all users do their own internal managment of obtaining filter blocks and thus already have them in kernel memory and set up before calling into sk_unattached_filter_create(). As a result, due to __user annotation in sock_fprog, sparse triggers false positives (incorrect type in assignment [different address space]) when filters are set up before passing them to sk_unattached_filter_create(). Therefore, let sk_unattached_filter_create() API use sock_fprog_kern to overcome this issue. Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Acked-by: Alexei Starovoitov <ast@plumgrid.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ppp/ppp_generic.c4
-rw-r--r--drivers/net/team/team_mode_loadbalance.c10
2 files changed, 7 insertions, 7 deletions
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index e3923ebb693f..91d6c1272fcf 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -757,7 +757,7 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
757 757
758 err = get_filter(argp, &code); 758 err = get_filter(argp, &code);
759 if (err >= 0) { 759 if (err >= 0) {
760 struct sock_fprog fprog = { 760 struct sock_fprog_kern fprog = {
761 .len = err, 761 .len = err,
762 .filter = code, 762 .filter = code,
763 }; 763 };
@@ -778,7 +778,7 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
778 778
779 err = get_filter(argp, &code); 779 err = get_filter(argp, &code);
780 if (err >= 0) { 780 if (err >= 0) {
781 struct sock_fprog fprog = { 781 struct sock_fprog_kern fprog = {
782 .len = err, 782 .len = err,
783 .filter = code, 783 .filter = code,
784 }; 784 };
diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/team_mode_loadbalance.c
index dbde3412ee5e..0a6ee07bf0af 100644
--- a/drivers/net/team/team_mode_loadbalance.c
+++ b/drivers/net/team/team_mode_loadbalance.c
@@ -49,7 +49,7 @@ struct lb_port_mapping {
49struct lb_priv_ex { 49struct lb_priv_ex {
50 struct team *team; 50 struct team *team;
51 struct lb_port_mapping tx_hash_to_port_mapping[LB_TX_HASHTABLE_SIZE]; 51 struct lb_port_mapping tx_hash_to_port_mapping[LB_TX_HASHTABLE_SIZE];
52 struct sock_fprog *orig_fprog; 52 struct sock_fprog_kern *orig_fprog;
53 struct { 53 struct {
54 unsigned int refresh_interval; /* in tenths of second */ 54 unsigned int refresh_interval; /* in tenths of second */
55 struct delayed_work refresh_dw; 55 struct delayed_work refresh_dw;
@@ -241,10 +241,10 @@ static int lb_bpf_func_get(struct team *team, struct team_gsetter_ctx *ctx)
241 return 0; 241 return 0;
242} 242}
243 243
244static int __fprog_create(struct sock_fprog **pfprog, u32 data_len, 244static int __fprog_create(struct sock_fprog_kern **pfprog, u32 data_len,
245 const void *data) 245 const void *data)
246{ 246{
247 struct sock_fprog *fprog; 247 struct sock_fprog_kern *fprog;
248 struct sock_filter *filter = (struct sock_filter *) data; 248 struct sock_filter *filter = (struct sock_filter *) data;
249 249
250 if (data_len % sizeof(struct sock_filter)) 250 if (data_len % sizeof(struct sock_filter))
@@ -262,7 +262,7 @@ static int __fprog_create(struct sock_fprog **pfprog, u32 data_len,
262 return 0; 262 return 0;
263} 263}
264 264
265static void __fprog_destroy(struct sock_fprog *fprog) 265static void __fprog_destroy(struct sock_fprog_kern *fprog)
266{ 266{
267 kfree(fprog->filter); 267 kfree(fprog->filter);
268 kfree(fprog); 268 kfree(fprog);
@@ -273,7 +273,7 @@ static int lb_bpf_func_set(struct team *team, struct team_gsetter_ctx *ctx)
273 struct lb_priv *lb_priv = get_lb_priv(team); 273 struct lb_priv *lb_priv = get_lb_priv(team);
274 struct sk_filter *fp = NULL; 274 struct sk_filter *fp = NULL;
275 struct sk_filter *orig_fp; 275 struct sk_filter *orig_fp;
276 struct sock_fprog *fprog = NULL; 276 struct sock_fprog_kern *fprog = NULL;
277 int err; 277 int err;
278 278
279 if (ctx->data.bin_val.len) { 279 if (ctx->data.bin_val.len) {