rds: mark snapshot pages dirty in rds_info_getsockopt()
Subsystems (4)
PATCH 1/1 rds: mark snapshot pages dirty in rds_info_getsockopt()
rds_info_getsockopt() pins the destination user pages with FOLL_WRITE and the RDS_INFO_* producers memcpy the snapshot into them through kmap_atomic(). Because that copy goes through the kernel direct map, the dirty bit on the user PTE is never set, so unpin_user_pages() releases the pages without marking them dirty. A file-backed destination page can then be reclaimed without writeback, silently discarding the copied data.
Use unpin_user_pages_dirty_lock() with make_dirty=true so the modified pages are marked dirty before they are unpinned.
--- net/rds/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rds/info.c +1 -1
@@ -235,7 +235,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval, out:if (pages) -unpin_user_pages (pages, nr_pages); +unpin_user_pages_dirty_lock (pages, nr_pages, true);kfree (pages);return ret;
---
base-commit: 9772589b57e44aedc240211c5c3f7a684a034d3a
change-id: 20260608-rds_fix-92d6c7f04fe2
Best regards,
Signature · 1 line
Breno Leitao <[email protected]>
Quoted 7 lines · Breno Leitao
rds_info_getsockopt()pins the destination user pages withFOLL_WRITEand the RDS_INFO_* producers memcpy the snapshot into them throughkmap_atomic(). Because that copy goes through the kernel direct map, the dirty bit on the user PTE is never set, sounpin_user_pages()releases the pages without marking them dirty. A file-backed destination page can then be reclaimed without writeback, silently discarding the copied data.
Quoted 5 lines
Use
unpin_user_pages_dirty_lock()with make_dirty=true so the modified pages are marked dirty before they are unpinned.Fixes a8c879a7ee98 ("RDS: Info and stats")Signed-off-by Breno Leitao <[email protected]>
Hi Breno,
Thanks for adding the Fixes tag. One thing though: now that this is standalone, it collides with "[PATCH net-next v3 2/2] rds: convert to getsockopt_iter" since both rewrite the same unpin in the out: block of rds_info_getsockopt().
Easiest on everyone is to just keep it folded into the net-next series as a three-patch set, rather than splitting the fix out to net.
With that, you can add my:
Thanks!
Allison
Quoted 23 lines
--- net/rds/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/rds/info.c +1
-2@@ -235,7 +235,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval, out:if (pages) -unpin_user_pages (pages, nr_pages); +unpin_user_pages_dirty_lock (pages, nr_pages, true);kfree (pages);return ret; ---base-commit:
9772589b57e44aedc240211c5c3f7a684a034d3a
change-id: 20260608-rds_fix-92d6c7f04fe2Best regards,
Quoted 16 lines · Allison Henderson
Quoted 7 lines · Breno Leitao
rds_info_getsockopt()pins the destination user pages withFOLL_WRITEand the RDS_INFO_* producers memcpy the snapshot into them throughkmap_atomic(). Because that copy goes through the kernel direct map, the dirty bit on the user PTE is never set, sounpin_user_pages()releases the pages without marking them dirty. A file-backed destination page can then be reclaimed without writeback, silently discarding the copied data.Quoted 5 lines
Use
unpin_user_pages_dirty_lock()with make_dirty=true so the modified pages are marked dirty before they are unpinned.Fixes a8c879a7ee98 ("RDS: Info and stats")Signed-off-by Breno Leitao <[email protected]>Hi Breno,
Quoted 7 lines
Thanks for adding the Fixes tag. One thing though: now that this is standalone, it collides with "[PATCH net-next v3 2/2] rds: convert to
getsockopt_iter" since both rewrite the same unpin in the out: block ofrds_info_getsockopt().Easiest on everyone is to just keep it folded into the net-next series as a three-patch set, rather than splitting the fix out to net.
I got from the maintainers that they want to continue to split the fixes into net and non fixes (features) into net-next.
"So just prepare for net with Fixes tags and we'll route the patches accordingly." -- Jakub
https://lore.kernel.org/all/[email protected]/
Thanks for the review,
--breno
Allison Henderson
maintainerQuoted 28 lines · Breno Leitao
Quoted 16 lines · Allison Henderson
Quoted 7 lines · Breno Leitao
rds_info_getsockopt()pins the destination user pages withFOLL_WRITEand the RDS_INFO_* producers memcpy the snapshot into them throughkmap_atomic(). Because that copy goes through the kernel direct map, the dirty bit on the user PTE is never set, sounpin_user_pages()releases the pages without marking them dirty. A file-backed destination page can then be reclaimed without writeback, silently discarding the copied data.Quoted 5 lines
Use
unpin_user_pages_dirty_lock()with make_dirty=true so the modified pages are marked dirty before they are unpinned.Fixes a8c879a7ee98 ("RDS: Info and stats")Signed-off-by Breno Leitao <[email protected]>Hi Breno,
Quoted 7 lines
Thanks for adding the Fixes tag. One thing though: now that this is standalone, it collides with "[PATCH net-next v3 2/2] rds: convert to
getsockopt_iter" since both rewrite the same unpin in the out: block ofrds_info_getsockopt().Easiest on everyone is to just keep it folded into the net-next series as a three-patch set, rather than splitting the fix out to net.
I got from the maintainers that they want to continue to split the fixes into net and non fixes (features) into net-next.
Quoted 7 lines
"So just prepare for net with Fixes tags and we'll route the patches accordingly." -- Jakub
https://lore.kernel.org/all/[email protected]/
Thanks for the review,
--breno
I see, ok it's fine to apply my rvb then.
Thanks for working on this,
Allison
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 Mon, 08 Jun 2026 02:32:05 -0700 you wrote:
rds_info_getsockopt()pins the destination user pages withFOLL_WRITEand the RDS_INFO_* producers memcpy the snapshot into them throughkmap_atomic(). Because that copy goes through the kernel direct map, the dirty bit on the user PTE is never set, sounpin_user_pages()releases the pages without marking them dirty. A file-backed destination page can then be reclaimed without writeback, silently discarding the copied data.[...]
Here is the summary with links:
- [net] rds: mark snapshot pages dirty in rds_info_getsockopt()
https://git.kernel.org/netdev/net/c/512db8267b73
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html