
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IC914B CVE: NA -------------------------------- This reverts commit 4838ae72aec7b153b801a6f4551ec00f3044db6e. When release smc socket, smc_buf_unuse() set buf_desc->used to 0. If there are some new smc connections, they find reusable slot in the link group first by smc_buf_get_slot(), if reusable slot is NULL, then create new buf in __smc_buf_create(). However, commit 4838ae72aec7 ("net/smc: Add size match for smc_buf_get_slot") add bufsize check in smc_buf_get_slot(). If the bufsize of previous connection is different from the new connection, smc_buf_get_slot() will return NULL, which may lead to alloc buf fail, and fallback to TCP. Revert it and keep the same with mainline. Fixes: 4838ae72aec7 ("net/smc: Add size match for smc_buf_get_slot") Conflicts: net/smc/smc_core.c [conflicts due to merged mainline 833bac7ec392 ("net/smc: Fix setsockopt and sysctl to specify same buffer size again")] Signed-off-by: Wang Liang <wangliang74@huawei.com> --- net/smc/smc_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index 254d4c89e520..124a3f06d237 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -1913,7 +1913,7 @@ int smc_uncompress_bufsize(u8 compressed) /* try to reuse a sndbuf or rmb description slot for a certain * buffer size; if not available, return NULL */ -static struct smc_buf_desc *smc_buf_get_slot(int bufsize, +static struct smc_buf_desc *smc_buf_get_slot(int compressed_bufsize, struct rw_semaphore *lock, struct list_head *buf_list) { @@ -1921,7 +1921,7 @@ static struct smc_buf_desc *smc_buf_get_slot(int bufsize, down_read(lock); list_for_each_entry(buf_slot, buf_list, list) { - if (buf_slot->len == bufsize && (cmpxchg(&buf_slot->used, 0, 1) == 0)) { + if (cmpxchg(&buf_slot->used, 0, 1) == 0) { up_read(lock); return buf_slot; } @@ -2254,7 +2254,7 @@ static int __smc_buf_create(struct smc_sock *smc, bool is_smcd, bool is_rmb) bufsize = smc_uncompress_bufsize(bufsize_comp); /* check for reusable slot in the link group */ - buf_desc = smc_buf_get_slot(bufsize, lock, buf_list); + buf_desc = smc_buf_get_slot(bufsize_comp, lock, buf_list); if (buf_desc) { buf_desc->is_dma_need_sync = 0; SMC_STAT_RMB_SIZE(is_smcd, is_rmb, bufsize); -- 2.34.1