Patch "netfilter: drop outermost socket lock in getsockopt()" has been added to the 4.4-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
netfilter: drop outermost socket lock in getsockopt()
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
netfilter-drop-outermost-socket-lock-in-getsockopt.patch
and it can be found in the queue-4.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
01ea306f2ac2baff98d472da719193e738759d93Mon Sep 17 00:00:00 2001
From: Paolo Abeni <[email protected]>
Date: Thu, 8 Feb 2018 12:19:00 +0100
Subject: netfilter: drop outermost socket lock in getsockopt()
From: Paolo Abeni <[email protected]>
commit 01ea306f2ac2baff98d472da719193e738759d93 upstream.
The Syzbot reported a possible deadlock in the netfilter area caused by rtnl lock, xt lock and socket lock being acquired with a different order on different code paths, leading to the following backtrace:
======================================================
WARNING: possible circular locking dependency detected 4.15.0+ #301 Not tainted
------------------------------------------------------
syzkaller233489/4179 is trying to acquire lock:
(rtnl_mutex){+.+.}, at: [<0000000048e996fd>] rtnl_lock+0x17/0x20net/core/rtnetlink.c:74
but task is already holding lock:
(&xt[i].mutex){+.+.}, at: [<00000000328553a2>]xt_find_table_lock+0x3e/0x3e0 net/netfilter/x_tables.c:1041
which lock already depends on the new lock.
===
Since commit 3f34cfae1230 ("netfilter: on sockopt() acquire sock lock only in the required scope"), we already acquire the socket lock in the innermost scope, where needed. In such commit I forgot to remove the outer-most socket lock from the getsockopt() path, this commit addresses the issues dropping it now.
v1 -> v2: fix bad subj, added relavant 'fixes' tag
--- net/ipv4/ip_sockglue.c | 7 +------ net/ipv6/ipv6_sockglue.c | 10 ++-------- 2 files changed, 3 insertions(+), 14 deletions(-)
net/ipv4/ip_sockglue.c +1 -6
@@ -1527,10 +1527,7 @@ int ip_getsockopt(struct sock *sk, int lif (get_user (len, optlen))return -EFAULT ; -lock_sock (sk); - err =nf_getsockopt (sk,PF_INET , optname, optval, - &len); -release_sock (sk); + err =nf_getsockopt (sk,PF_INET , optname, optval, &len);if (err >=0 ) err =put_user (len, optlen);return err;
@@ -1562,9 +1559,7 @@ int compat_ip_getsockopt(struct sock *skif (get_user (len, optlen))return -EFAULT ; -lock_sock (sk); err =compat_nf_getsockopt (sk,PF_INET , optname, optval, &len); -release_sock (sk);if (err >=0 ) err =put_user (len, optlen);return err;
net/ipv6/ipv6_sockglue.c +2 -8
@@ -1340,10 +1340,7 @@ int ipv6_getsockopt(struct sock *sk, intif (get_user (len, optlen))return -EFAULT ; -lock_sock (sk); - err =nf_getsockopt (sk,PF_INET6 , optname, optval, - &len); -release_sock (sk); + err =nf_getsockopt (sk,PF_INET6 , optname, optval, &len);if (err >=0 ) err =put_user (len, optlen); }
@@ -1382,10 +1379,7 @@ int compat_ipv6_getsockopt(struct sock *if (get_user (len, optlen))return -EFAULT ; -lock_sock (sk); - err =compat_nf_getsockopt (sk,PF_INET6 , - optname, optval, &len); -release_sock (sk); + err =compat_nf_getsockopt (sk,PF_INET6 , optname, optval, &len);if (err >=0 ) err =put_user (len, optlen); }
Patches currently in stable-queue which might be from [email protected] are
queue-4.4/netfilter-drop-outermost-socket-lock-in-getsockopt.patch