aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/filter.h3
-rw-r--r--net/core/filter.c8
-rw-r--r--net/core/sock_diag.c2
3 files changed, 6 insertions, 7 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 00640edc166f..3769341a745d 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -344,8 +344,7 @@ static inline unsigned int sk_filter_size(unsigned int proglen)
344 offsetof(struct sk_filter, insns[proglen])); 344 offsetof(struct sk_filter, insns[proglen]));
345} 345}
346 346
347#define sk_filter_proglen(fprog) \ 347#define bpf_classic_proglen(fprog) (fprog->len * sizeof(fprog->filter[0]))
348 (fprog->len * sizeof(fprog->filter[0]))
349 348
350int sk_filter(struct sock *sk, struct sk_buff *skb); 349int sk_filter(struct sock *sk, struct sk_buff *skb);
351 350
diff --git a/net/core/filter.c b/net/core/filter.c
index 5a6aeb1d40b8..d6cb287e4f59 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -813,7 +813,7 @@ EXPORT_SYMBOL(sk_chk_filter);
813static int sk_store_orig_filter(struct sk_filter *fp, 813static int sk_store_orig_filter(struct sk_filter *fp,
814 const struct sock_fprog *fprog) 814 const struct sock_fprog *fprog)
815{ 815{
816 unsigned int fsize = sk_filter_proglen(fprog); 816 unsigned int fsize = bpf_classic_proglen(fprog);
817 struct sock_fprog_kern *fkprog; 817 struct sock_fprog_kern *fkprog;
818 818
819 fp->orig_prog = kmalloc(sizeof(*fkprog), GFP_KERNEL); 819 fp->orig_prog = kmalloc(sizeof(*fkprog), GFP_KERNEL);
@@ -1001,7 +1001,7 @@ static struct sk_filter *__sk_prepare_filter(struct sk_filter *fp)
1001int sk_unattached_filter_create(struct sk_filter **pfp, 1001int sk_unattached_filter_create(struct sk_filter **pfp,
1002 struct sock_fprog_kern *fprog) 1002 struct sock_fprog_kern *fprog)
1003{ 1003{
1004 unsigned int fsize = sk_filter_proglen(fprog); 1004 unsigned int fsize = bpf_classic_proglen(fprog);
1005 struct sk_filter *fp; 1005 struct sk_filter *fp;
1006 1006
1007 /* Make sure new filter is there and in the right amounts. */ 1007 /* Make sure new filter is there and in the right amounts. */
@@ -1053,7 +1053,7 @@ EXPORT_SYMBOL_GPL(sk_unattached_filter_destroy);
1053int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk) 1053int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk)
1054{ 1054{
1055 struct sk_filter *fp, *old_fp; 1055 struct sk_filter *fp, *old_fp;
1056 unsigned int fsize = sk_filter_proglen(fprog); 1056 unsigned int fsize = bpf_classic_proglen(fprog);
1057 unsigned int sk_fsize = sk_filter_size(fprog->len); 1057 unsigned int sk_fsize = sk_filter_size(fprog->len);
1058 int err; 1058 int err;
1059 1059
@@ -1154,7 +1154,7 @@ int sk_get_filter(struct sock *sk, struct sock_filter __user *ubuf,
1154 goto out; 1154 goto out;
1155 1155
1156 ret = -EFAULT; 1156 ret = -EFAULT;
1157 if (copy_to_user(ubuf, fprog->filter, sk_filter_proglen(fprog))) 1157 if (copy_to_user(ubuf, fprog->filter, bpf_classic_proglen(fprog)))
1158 goto out; 1158 goto out;
1159 1159
1160 /* Instead of bytes, the API requests to return the number 1160 /* Instead of bytes, the API requests to return the number
diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
index a4216a4c9572..57d922320c59 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -69,7 +69,7 @@ int sock_diag_put_filterinfo(bool may_report_filterinfo, struct sock *sk,
69 goto out; 69 goto out;
70 70
71 fprog = filter->orig_prog; 71 fprog = filter->orig_prog;
72 flen = sk_filter_proglen(fprog); 72 flen = bpf_classic_proglen(fprog);
73 73
74 attr = nla_reserve(skb, attrtype, flen); 74 attr = nla_reserve(skb, attrtype, flen);
75 if (attr == NULL) { 75 if (attr == NULL) {