]> git.baikalelectronics.ru Git - kernel.git/commit
net: rds: acquire refcount on TCP sockets
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Mon, 2 May 2022 01:40:18 +0000 (10:40 +0900)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 3 May 2022 11:22:50 +0000 (13:22 +0200)
commitd6d7567c341950a0c958647e146f939947163464
tree3eda76075a30db339d54da4746f32546448acc0f
parent839b9a88ca8b5584d2ca537af8d5f9f8d34e9b90
net: rds: acquire refcount on TCP sockets

syzbot is reporting use-after-free read in tcp_retransmit_timer() [1],
for TCP socket used by RDS is accessing sock_net() without acquiring a
refcount on net namespace. Since TCP's retransmission can happen after
a process which created net namespace terminated, we need to explicitly
acquire a refcount.

Link: https://syzkaller.appspot.com/bug?extid=694120e1002c117747ed
Reported-by: syzbot <syzbot+694120e1002c117747ed@syzkaller.appspotmail.com>
Fixes: 645b84d8bec9d544 ("net: Modify sk_alloc to not reference count the netns of kernel sockets.")
Fixes: f1ab38c355cf5745 ("net: sk_clone_lock() should only do get_net() if the parent is not a kernel socket")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tested-by: syzbot <syzbot+694120e1002c117747ed@syzkaller.appspotmail.com>
Link: https://lore.kernel.org/r/a5fb1fc4-2284-3359-f6a0-e4e390239d7b@I-love.SAKURA.ne.jp
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/rds/tcp.c