kernel_samsung_a53x/net/smc
Guangguan Wang 61ad4ce8cb net/smc: check sndbuf_space again after NOSPACE flag is set in smc_poll
[ Upstream commit 679e9ddcf90dbdf98aaaa71a492454654b627bcb ]

When application sending data more than sndbuf_space, there have chances
application will sleep in epoll_wait, and will never be wakeup again. This
is caused by a race between smc_poll and smc_cdc_tx_handler.

application                                      tasklet
smc_tx_sendmsg(len > sndbuf_space)   |
epoll_wait for EPOLL_OUT,timeout=0   |
  smc_poll                           |
    if (!smc->conn.sndbuf_space)     |
                                     |  smc_cdc_tx_handler
                                     |    atomic_add sndbuf_space
                                     |    smc_tx_sndbuf_nonfull
                                     |      if (!test_bit SOCK_NOSPACE)
                                     |        do not sk_write_space;
      set_bit SOCK_NOSPACE;          |
    return mask=0;                   |

Application will sleep in epoll_wait as smc_poll returns 0. And
smc_cdc_tx_handler will not call sk_write_space because the SOCK_NOSPACE
has not be set. If there is no inflight cdc msg, sk_write_space will not be
called any more, and application will sleep in epoll_wait forever.
So check sndbuf_space again after NOSPACE flag is set to break the race.

Fixes: 8dce2786a290 ("net/smc: smc_poll improvements")
Signed-off-by: Guangguan Wang <guangguan.wang@linux.alibaba.com>
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-01-15 16:29:41 +01:00
..
af_smc.c net/smc: check sndbuf_space again after NOSPACE flag is set in smc_poll 2025-01-15 16:29:41 +01:00
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc.h net/smc: fix dangling sock under state SMC_APPFINCLOSEWAIT 2024-11-18 11:43:08 +01:00
smc_cdc.c net/smc: allow cdc msg send rather than drop it with NULL sndbuf_desc 2024-11-18 11:43:08 +01:00
smc_cdc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_clc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_clc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_close.c net/smc: put sk reference if close work was canceled 2024-11-18 11:43:08 +01:00
smc_close.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_core.c Revert "net/smc: Allow SMC-D 1MB DMB allocations" 2024-11-24 00:23:56 +01:00
smc_core.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_diag.c net/smc: fix illegal rmb_desc access in SMC-D connection dump 2024-11-18 12:12:59 +01:00
smc_ib.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_ib.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_ism.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_ism.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_llc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_llc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_netns.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_pnet.c net/smc: Fix searching in list of known pnetids in smc_pnet_add_pnetid 2024-11-23 23:21:59 +01:00
smc_pnet.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_rx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_rx.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_tx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_tx.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_wr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smc_wr.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00