|
72 | 72 | #define PPP_PROTO_LEN 2
|
73 | 73 | #define PPP_LCP_HDRLEN 4
|
74 | 74 |
|
| 75 | +/* The filter instructions generated by libpcap are constructed |
| 76 | + * assuming a four-byte PPP header on each packet, where the last |
| 77 | + * 2 bytes are the protocol field defined in the RFC and the first |
| 78 | + * byte of the first 2 bytes indicates the direction. |
| 79 | + * The second byte is currently unused, but we still need to initialize |
| 80 | + * it to prevent crafted BPF programs from reading them which would |
| 81 | + * cause reading of uninitialized data. |
| 82 | + */ |
| 83 | +#define PPP_FILTER_OUTBOUND_TAG 0x0100 |
| 84 | +#define PPP_FILTER_INBOUND_TAG 0x0000 |
| 85 | + |
75 | 86 | /*
|
76 | 87 | * An instance of /dev/ppp can be associated with either a ppp
|
77 | 88 | * interface unit or a ppp channel. In both cases, file->private_data
|
@@ -1627,10 +1638,10 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
|
1627 | 1638 |
|
1628 | 1639 | if (proto < 0x8000) {
|
1629 | 1640 | #ifdef CONFIG_PPP_FILTER
|
1630 |
| - /* check if we should pass this packet */ |
1631 |
| - /* the filter instructions are constructed assuming |
1632 |
| - a four-byte PPP header on each packet */ |
1633 |
| - *(u8 *)skb_push(skb, 2) = 1; |
| 1641 | + /* check if the packet passes the pass and active filters. |
| 1642 | + * See comment for PPP_FILTER_OUTBOUND_TAG above. |
| 1643 | + */ |
| 1644 | + *(__be16 *)skb_push(skb, 2) = htons(PPP_FILTER_OUTBOUND_TAG); |
1634 | 1645 | if (ppp->pass_filter &&
|
1635 | 1646 | BPF_PROG_RUN(ppp->pass_filter, skb) == 0) {
|
1636 | 1647 | if (ppp->debug & 1)
|
@@ -2309,14 +2320,13 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
|
2309 | 2320 | /* network protocol frame - give it to the kernel */
|
2310 | 2321 |
|
2311 | 2322 | #ifdef CONFIG_PPP_FILTER
|
2312 |
| - /* check if the packet passes the pass and active filters */ |
2313 |
| - /* the filter instructions are constructed assuming |
2314 |
| - a four-byte PPP header on each packet */ |
2315 | 2323 | if (ppp->pass_filter || ppp->active_filter) {
|
2316 | 2324 | if (skb_unclone(skb, GFP_ATOMIC))
|
2317 | 2325 | goto err;
|
2318 |
| - |
2319 |
| - *(u8 *)skb_push(skb, 2) = 0; |
| 2326 | + /* Check if the packet passes the pass and active filters. |
| 2327 | + * See comment for PPP_FILTER_INBOUND_TAG above. |
| 2328 | + */ |
| 2329 | + *(__be16 *)skb_push(skb, 2) = htons(PPP_FILTER_INBOUND_TAG); |
2320 | 2330 | if (ppp->pass_filter &&
|
2321 | 2331 | BPF_PROG_RUN(ppp->pass_filter, skb) == 0) {
|
2322 | 2332 | if (ppp->debug & 1)
|
|
0 commit comments