Dave,
here are small fixes for SMC: The first patch makes sure, shutdown code
is not executed for sockets in state SMC_LISTEN. The second patch resets
send and receive buffer values for accepted sockets, since TCP buffer size
optimizations for the internal CLC socket should not be forwarded to the
outer SMC socket. The third patch solves a race between connect and ioctl
reported by syzbot.
Kind regards, Ursula
Ursula Braun (3):
net/smc: no shutdown in state SMC_LISTEN
net/smc: allow sysctl rmem and wmem defaults for servers
net/smc: move sock lock in smc_ioctl()
net/smc/af_smc.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
--
2.16.4
When an SMC socket is connecting it is decided whether fallback to
TCP is needed. To avoid races between connect and ioctl move the
sock lock before the use_fallback check.
Reported-by: syzbot+5b2cece1a8ecb2ca77d8@syzkaller.appspotmail.com
Reported-by: syzbot+19557374321ca3710990@syzkaller.appspotmail.com
Fixes: 1992d99882af ("net/smc: take sock lock in smc_ioctl()")
Signed-off-by: Ursula Braun <redacted>
---
net/smc/af_smc.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
@@ -1522,12 +1522,16 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd,smc=smc_sk(sock->sk);conn=&smc->conn;+lock_sock(&smc->sk);if(smc->use_fallback){-if(!smc->clcsock)+if(!smc->clcsock){+release_sock(&smc->sk);return-EBADF;-returnsmc->clcsock->ops->ioctl(smc->clcsock,cmd,arg);+}+answ=smc->clcsock->ops->ioctl(smc->clcsock,cmd,arg);+release_sock(&smc->sk);+returnansw;}-lock_sock(&smc->sk);switch(cmd){caseSIOCINQ:/* same as FIONREAD */if(smc->sk.sk_state==SMC_LISTEN){
Invoking shutdown for a socket in state SMC_LISTEN does not make
sense. Nevertheless programs like syzbot fuzzing the kernel may
try to do this. For SMC this means a socket refcounting problem.
This patch makes sure a shutdown call for an SMC socket in state
SMC_LISTEN simply returns with -ENOTCONN.
Signed-off-by: Ursula Braun <redacted>
---
net/smc/af_smc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Without setsockopt SO_SNDBUF and SO_RCVBUF settings, the sysctl
defaults net.ipv4.tcp_wmem and net.ipv4.tcp_rmem should be the base
for the sizes of the SMC sndbuf and rcvbuf. Any TCP buffer size
optimizations for servers should be ignored.
Signed-off-by: Ursula Braun <redacted>
---
net/smc/af_smc.c | 2 ++
1 file changed, 2 insertions(+)
here are small fixes for SMC: The first patch makes sure, shutdown code
is not executed for sockets in state SMC_LISTEN. The second patch resets
send and receive buffer values for accepted sockets, since TCP buffer size
optimizations for the internal CLC socket should not be forwarded to the
outer SMC socket. The third patch solves a race between connect and ioctl
reported by syzbot.