|
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
|
@@ -1762,10 +1773,10 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
|
1762 | 1773 |
|
1763 | 1774 | if (proto < 0x8000) {
|
1764 | 1775 | #ifdef CONFIG_PPP_FILTER
|
1765 |
| - /* check if we should pass this packet */ |
1766 |
| - /* the filter instructions are constructed assuming |
1767 |
| - a four-byte PPP header on each packet */ |
1768 |
| - *(u8 *)skb_push(skb, 2) = 1; |
| 1776 | + /* check if the packet passes the pass and active filters. |
| 1777 | + * See comment for PPP_FILTER_OUTBOUND_TAG above. |
| 1778 | + */ |
| 1779 | + *(__be16 *)skb_push(skb, 2) = htons(PPP_FILTER_OUTBOUND_TAG); |
1769 | 1780 | if (ppp->pass_filter &&
|
1770 | 1781 | bpf_prog_run(ppp->pass_filter, skb) == 0) {
|
1771 | 1782 | if (ppp->debug & 1)
|
@@ -2482,14 +2493,13 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
|
2482 | 2493 | /* network protocol frame - give it to the kernel */
|
2483 | 2494 |
|
2484 | 2495 | #ifdef CONFIG_PPP_FILTER
|
2485 |
| - /* check if the packet passes the pass and active filters */ |
2486 |
| - /* the filter instructions are constructed assuming |
2487 |
| - a four-byte PPP header on each packet */ |
2488 | 2496 | if (ppp->pass_filter || ppp->active_filter) {
|
2489 | 2497 | if (skb_unclone(skb, GFP_ATOMIC))
|
2490 | 2498 | goto err;
|
2491 |
| - |
2492 |
| - *(u8 *)skb_push(skb, 2) = 0; |
| 2499 | + /* Check if the packet passes the pass and active filters. |
| 2500 | + * See comment for PPP_FILTER_INBOUND_TAG above. |
| 2501 | + */ |
| 2502 | + *(__be16 *)skb_push(skb, 2) = htons(PPP_FILTER_INBOUND_TAG); |
2493 | 2503 | if (ppp->pass_filter &&
|
2494 | 2504 | bpf_prog_run(ppp->pass_filter, skb) == 0) {
|
2495 | 2505 | if (ppp->debug & 1)
|
|
0 commit comments