aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-07-23 19:31:37 -0400
committerDavid S. Miller <davem@davemloft.net>2016-07-24 00:53:32 -0400
commitde0ba9a0d8909996f9e293d311c2cc459fa77d67 (patch)
tree199214afc477824bf431d11d08834ff7555c994b /net/core
parentd95a93a9b71677a43f967a1b7986decab84b7765 (diff)
parent107df03203bb66de56e2caec3bde6d22b55480c5 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Just several instances of overlapping changes. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/filter.c10
-rw-r--r--net/core/sock.c11
2 files changed, 13 insertions, 8 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index 6c627bc4be6e..0b521353008d 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -53,9 +53,10 @@
53#include <net/sock_reuseport.h> 53#include <net/sock_reuseport.h>
54 54
55/** 55/**
56 * sk_filter - run a packet through a socket filter 56 * sk_filter_trim_cap - run a packet through a socket filter
57 * @sk: sock associated with &sk_buff 57 * @sk: sock associated with &sk_buff
58 * @skb: buffer to filter 58 * @skb: buffer to filter
59 * @cap: limit on how short the eBPF program may trim the packet
59 * 60 *
60 * Run the eBPF program and then cut skb->data to correct size returned by 61 * Run the eBPF program and then cut skb->data to correct size returned by
61 * the program. If pkt_len is 0 we toss packet. If skb->len is smaller 62 * the program. If pkt_len is 0 we toss packet. If skb->len is smaller
@@ -64,7 +65,7 @@
64 * be accepted or -EPERM if the packet should be tossed. 65 * be accepted or -EPERM if the packet should be tossed.
65 * 66 *
66 */ 67 */
67int sk_filter(struct sock *sk, struct sk_buff *skb) 68int sk_filter_trim_cap(struct sock *sk, struct sk_buff *skb, unsigned int cap)
68{ 69{
69 int err; 70 int err;
70 struct sk_filter *filter; 71 struct sk_filter *filter;
@@ -85,14 +86,13 @@ int sk_filter(struct sock *sk, struct sk_buff *skb)
85 filter = rcu_dereference(sk->sk_filter); 86 filter = rcu_dereference(sk->sk_filter);
86 if (filter) { 87 if (filter) {
87 unsigned int pkt_len = bpf_prog_run_save_cb(filter->prog, skb); 88 unsigned int pkt_len = bpf_prog_run_save_cb(filter->prog, skb);
88 89 err = pkt_len ? pskb_trim(skb, max(cap, pkt_len)) : -EPERM;
89 err = pkt_len ? pskb_trim(skb, pkt_len) : -EPERM;
90 } 90 }
91 rcu_read_unlock(); 91 rcu_read_unlock();
92 92
93 return err; 93 return err;
94} 94}
95EXPORT_SYMBOL(sk_filter); 95EXPORT_SYMBOL(sk_filter_trim_cap);
96 96
97static u64 __skb_get_pay_offset(u64 ctx, u64 a, u64 x, u64 r4, u64 r5) 97static u64 __skb_get_pay_offset(u64 ctx, u64 a, u64 x, u64 r4, u64 r5)
98{ 98{
diff --git a/net/core/sock.c b/net/core/sock.c
index 08bf97eceeb3..25dab8b60223 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -452,11 +452,12 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
452} 452}
453EXPORT_SYMBOL(sock_queue_rcv_skb); 453EXPORT_SYMBOL(sock_queue_rcv_skb);
454 454
455int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested) 455int __sk_receive_skb(struct sock *sk, struct sk_buff *skb,
456 const int nested, unsigned int trim_cap)
456{ 457{
457 int rc = NET_RX_SUCCESS; 458 int rc = NET_RX_SUCCESS;
458 459
459 if (sk_filter(sk, skb)) 460 if (sk_filter_trim_cap(sk, skb, trim_cap))
460 goto discard_and_relse; 461 goto discard_and_relse;
461 462
462 skb->dev = NULL; 463 skb->dev = NULL;
@@ -492,7 +493,7 @@ discard_and_relse:
492 kfree_skb(skb); 493 kfree_skb(skb);
493 goto out; 494 goto out;
494} 495}
495EXPORT_SYMBOL(sk_receive_skb); 496EXPORT_SYMBOL(__sk_receive_skb);
496 497
497struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie) 498struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie)
498{ 499{
@@ -1938,6 +1939,10 @@ int __sock_cmsg_send(struct sock *sk, struct msghdr *msg, struct cmsghdr *cmsg,
1938 sockc->tsflags &= ~SOF_TIMESTAMPING_TX_RECORD_MASK; 1939 sockc->tsflags &= ~SOF_TIMESTAMPING_TX_RECORD_MASK;
1939 sockc->tsflags |= tsflags; 1940 sockc->tsflags |= tsflags;
1940 break; 1941 break;
1942 /* SCM_RIGHTS and SCM_CREDENTIALS are semantically in SOL_UNIX. */
1943 case SCM_RIGHTS:
1944 case SCM_CREDENTIALS:
1945 break;
1941 default: 1946 default:
1942 return -EINVAL; 1947 return -EINVAL;
1943 } 1948 }