net: rds: fix MR cleanup on copy error
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 net: rds: fix MR cleanup on copy error
From: Ao Zhou <[email protected]>
__rds_rdma_map() hands sg/pages ownership to the transport after get_mr() succeeds. If copying the generated cookie back to user space fails after that point, the error path must not free those resources again before dropping the MR reference.
Remove the duplicate unpin/free from the put_user() failure branch so that MR teardown is handled only through the existing final cleanup path.
--- net/rds/rdma.c | 4 ---- 1 file changed, 4 deletions(-)
net/rds/rdma.c +0 -4
@@ -326,10 +326,6 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,if (args->cookie_addr &&put_user (cookie, (u64 __user *)(unsigned long )args->cookie_addr)) { -if (!need_odp) { -unpin_user_pages (pages, nr_pages); -kfree (sg); - } ret = -EFAULT ; goto out; }
Signature · 1 line
2.43.0
Quoted 11 lines · Ren Wei
From: Ao Zhou <[email protected]>
__rds_rdma_map()hands sg/pages ownership to the transport afterget_mr()succeeds. If copying the generated cookie back to user space fails after that point, the error path must not free those resources again before dropping the MR reference.Remove the duplicate unpin/free from the
put_user()failure branch so that MR teardown is handled only through the existing final cleanup path.
Quoted 8 lines
Fixes 0d4597c8c5ab ("net/rds: Track user mapped pages through special API")Reported-by Yuan Tan <[email protected]>Reported-by Yifan Wu <[email protected]>Reported-by Juefei Pu <[email protected]>Reported-by Xin Liu <[email protected]>Signed-off-by Ao Zhou <[email protected]>Signed-off-by Ren Wei <[email protected]>
Hi Aso,
This fix looks good to me. Since this is a bug fix, this patch should be cc'd to [email protected]. Also be sure to note the target tree and component in the subject line like this:
[PATCH net v2 1/1] net/net: rds: fix MR cleanup on copy error
Other than that, the patch looks good to me. Thanks Aso.
Allison
Quoted 19 lines
--- net/rds/rdma.c | 4 ---- 1 file changed, 4 deletions(-)net/rds/rdma.c +0
-4@@ -326,10 +326,6 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,if (args->cookie_addr &&put_user (cookie, (u64 __user *)(unsigned long )args->cookie_addr)) { -if (!need_odp) { -unpin_user_pages (pages, nr_pages); -kfree (sg); - } ret = -EFAULT ; goto out; }
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Wed, 22 Apr 2026 22:52:07 +0800 you wrote:
From: Ao Zhou <[email protected]>
__rds_rdma_map()hands sg/pages ownership to the transport afterget_mr()succeeds. If copying the generated cookie back to user space fails after that point, the error path must not free those resources again before dropping the MR reference.[...]
Here is the summary with links:
- [net,1/1] net: rds: fix MR cleanup on copy error
https://git.kernel.org/netdev/net/c/8141a2dc7008
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html