|
36 | 36 | #include <asm/uaccess.h> |
37 | 37 | #include <asm/unaligned.h> |
38 | 38 | #include <linux/filter.h> |
39 | | -#include <linux/reciprocal_div.h> |
40 | 39 | #include <linux/ratelimit.h> |
41 | 40 | #include <linux/seccomp.h> |
42 | 41 | #include <linux/if_vlan.h> |
@@ -166,7 +165,7 @@ unsigned int sk_run_filter(const struct sk_buff *skb, |
166 | 165 | A /= X; |
167 | 166 | continue; |
168 | 167 | case BPF_S_ALU_DIV_K: |
169 | | - A = reciprocal_divide(A, K); |
| 168 | + A /= K; |
170 | 169 | continue; |
171 | 170 | case BPF_S_ALU_MOD_X: |
172 | 171 | if (X == 0) |
@@ -553,11 +552,6 @@ int sk_chk_filter(struct sock_filter *filter, unsigned int flen) |
553 | 552 | /* Some instructions need special checks */ |
554 | 553 | switch (code) { |
555 | 554 | case BPF_S_ALU_DIV_K: |
556 | | - /* check for division by zero */ |
557 | | - if (ftest->k == 0) |
558 | | - return -EINVAL; |
559 | | - ftest->k = reciprocal_value(ftest->k); |
560 | | - break; |
561 | 555 | case BPF_S_ALU_MOD_K: |
562 | 556 | /* check for division by zero */ |
563 | 557 | if (ftest->k == 0) |
@@ -853,27 +847,7 @@ void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to) |
853 | 847 | to->code = decodes[code]; |
854 | 848 | to->jt = filt->jt; |
855 | 849 | to->jf = filt->jf; |
856 | | - |
857 | | - if (code == BPF_S_ALU_DIV_K) { |
858 | | - /* |
859 | | - * When loaded this rule user gave us X, which was |
860 | | - * translated into R = r(X). Now we calculate the |
861 | | - * RR = r(R) and report it back. If next time this |
862 | | - * value is loaded and RRR = r(RR) is calculated |
863 | | - * then the R == RRR will be true. |
864 | | - * |
865 | | - * One exception. X == 1 translates into R == 0 and |
866 | | - * we can't calculate RR out of it with r(). |
867 | | - */ |
868 | | - |
869 | | - if (filt->k == 0) |
870 | | - to->k = 1; |
871 | | - else |
872 | | - to->k = reciprocal_value(filt->k); |
873 | | - |
874 | | - BUG_ON(reciprocal_value(to->k) != filt->k); |
875 | | - } else |
876 | | - to->k = filt->k; |
| 850 | + to->k = filt->k; |
877 | 851 | } |
878 | 852 |
|
879 | 853 | int sk_get_filter(struct sock *sk, struct sock_filter __user *ubuf, unsigned int len) |
|
0 commit comments