aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorKris Katterjohn <kjak@users.sourceforge.net>2005-11-20 16:41:34 -0500
committerDavid S. Miller <davem@davemloft.net>2005-11-20 16:41:34 -0500
commitfb0d366b0803571f06a5b838f02c6706fc287995 (patch)
tree473d0e16f244ef7c7415d865419b7b0187f52a7f /net/core
parentaa8751667dcd757dd9a711b51140adf181501c44 (diff)
[NET]: Reject socket filter if division by constant zero is attempted.
This way we don't have to check it in sk_run_filter(). Signed-off-by: Kris Katterjohn <kjak@users.sourceforge.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/filter.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index 079c2edff78..2841bfce29d 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -116,8 +116,6 @@ int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen)
116 A /= X; 116 A /= X;
117 continue; 117 continue;
118 case BPF_ALU|BPF_DIV|BPF_K: 118 case BPF_ALU|BPF_DIV|BPF_K:
119 if (fentry->k == 0)
120 return 0;
121 A /= fentry->k; 119 A /= fentry->k;
122 continue; 120 continue;
123 case BPF_ALU|BPF_AND|BPF_X: 121 case BPF_ALU|BPF_AND|BPF_X:
@@ -320,6 +318,10 @@ int sk_chk_filter(struct sock_filter *filter, int flen)
320 } 318 }
321 } 319 }
322 320
321 /* check for division by zero -Kris Katterjohn 2005-10-30 */
322 if (ftest->code == (BPF_ALU|BPF_DIV|BPF_K) && ftest->k == 0)
323 return -EINVAL;
324
323 /* check that memory operations use valid addresses. */ 325 /* check that memory operations use valid addresses. */
324 if (ftest->k >= BPF_MEMWORDS) { 326 if (ftest->k >= BPF_MEMWORDS) {
325 /* but it might not be a memory operation... */ 327 /* but it might not be a memory operation... */