summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2017-11-17 14:23:25 -0500
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2017-11-17 14:23:25 -0500
commit7268b05e43469349ba19bdf63164d8c41b003759 (patch)
tree48994c8ce77630283af58c3ce58eeb7d97eef8e4
parentb096da53d1b63252a06823ff91623c9def595894 (diff)
parent9d36d3eff2f85efad0a3b0c6031081654ae33928 (diff)
downloadlinux-rt-7268b05e43469349ba19bdf63164d8c41b003759.tar.gz
Merge tag 'v4.9.56' into v4.9-rt
This is the 4.9.56 stable release
-rw-r--r--Makefile2
-rw-r--r--net/core/filter.c15
-rw-r--r--net/core/sock.c5
3 files changed, 4 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 2a995675d6bf..feab5f5a507c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
VERSION = 4
PATCHLEVEL = 9
-SUBLEVEL = 55
+SUBLEVEL = 56
EXTRAVERSION =
NAME = Roaring Lionus
diff --git a/net/core/filter.c b/net/core/filter.c
index 2b94a115677c..4f09d6a57217 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -937,31 +937,20 @@ void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp)
/* try to charge the socket memory if there is space available
* return true on success
*/
-static bool __sk_filter_charge(struct sock *sk, struct sk_filter *fp)
+bool sk_filter_charge(struct sock *sk, struct sk_filter *fp)
{
u32 filter_size = bpf_prog_size(fp->prog->len);
/* same check as in sock_kmalloc() */
if (filter_size <= sysctl_optmem_max &&
atomic_read(&sk->sk_omem_alloc) + filter_size < sysctl_optmem_max) {
+ atomic_inc(&fp->refcnt);
atomic_add(filter_size, &sk->sk_omem_alloc);
return true;
}
return false;
}
-bool sk_filter_charge(struct sock *sk, struct sk_filter *fp)
-{
- if (!atomic_inc_not_zero(&fp->refcnt))
- return false;
-
- if (!__sk_filter_charge(sk, fp)) {
- sk_filter_release(fp);
- return false;
- }
- return true;
-}
-
static struct bpf_prog *bpf_migrate_filter(struct bpf_prog *fp)
{
struct sock_filter *old_prog;
diff --git a/net/core/sock.c b/net/core/sock.c
index 24a7650c2c3b..d8e0aed19903 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1528,16 +1528,13 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
sock_reset_flag(newsk, SOCK_DONE);
skb_queue_head_init(&newsk->sk_error_queue);
- rcu_read_lock();
- filter = rcu_dereference(sk->sk_filter);
+ filter = rcu_dereference_protected(newsk->sk_filter, 1);
if (filter != NULL)
/* though it's an empty new sock, the charging may fail
* if sysctl_optmem_max was changed between creation of
* original socket and cloning
*/
is_charged = sk_filter_charge(newsk, filter);
- RCU_INIT_POINTER(newsk->sk_filter, filter);
- rcu_read_unlock();
if (unlikely(!is_charged || xfrm_sk_clone_policy(newsk, sk))) {
/* We need to make sure that we don't uncharge the new