net/rds: reset op_nents when zerocopy page pin fails
Subsystems (4)
Allison Henderson
maintainerPATCH 1/1 net/rds: reset op_nents when zerocopy page pin fails
When iov_iter_get_pages2() fails in rds_message_zcopy_from_user(), the pinned pages are released with put_page(), and rm->data.op_mmp_znotifier is cleared. But we fail to properly clear rm->data.op_nents.
Later when rds_message_purge() is called from rds_sendmsg() the cleanup loop iterates over the incorrectly non zero number of op_nents and frees them again.
Fix this by properly resetting op_nents when it should be in rds_message_zcopy_from_user().
--- net/rds/message.c | 1 + 1 file changed, 1 insertion(+)
net/rds/message.c +1 -0
@@ -448,6 +448,7 @@ static int rds_message_zcopy_from_user(struct rds_message *rm, struct iov_iter *for (i =0 ; i < rm->data.op_nents; i++)put_page (sg_page (&rm->data.op_sg[i])); + rm->data.op_nents =0 ; mmp = &rm->data.op_mmp_znotifier->z_mmp;mm_unaccount_pinned_pages (mmp); ret = -EFAULT ;
Signature · 1 line
2.43.0
Quoted 9 lines · Allison Henderson
When
iov_iter_get_pages2()fails inrds_message_zcopy_from_user(), the pinned pages are released withput_page(), andrm->data.op_mmp_znotifieris cleared. But we fail to properly clearrm->data.op_nents.Later when
rds_message_purge()is called fromrds_sendmsg()the cleanup loop iterates over the incorrectly non zero number ofop_nentsand frees them again.
Quoted 5 lines
Fix this by properly resetting
op_nentswhen it should be inrds_message_zcopy_from_user().Fixes 0cebaccef3ac ("rds: zerocopy Tx support.")Signed-off-by Allison Henderson <[email protected]>
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 10 lines · On Tue, 5 May 2026 16:43:36 -0700 you wrote:
When
iov_iter_get_pages2()fails inrds_message_zcopy_from_user(), the pinned pages are released withput_page(), andrm->data.op_mmp_znotifieris cleared. But we fail to properly clearrm->data.op_nents.Later when
rds_message_purge()is called fromrds_sendmsg()the cleanup loop iterates over the incorrectly non zero number ofop_nentsand frees them again.[...]
Here is the summary with links:
- [net,v1] net/rds: reset op_nents when zerocopy page pin fails
https://git.kernel.org/netdev/net/c/e17492979319
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html