* [PATCH v2] net/rds: Fix a use after free in rds_message_map_pages
@ 2021-03-31 1:59 Lv Yunlong
2021-03-31 18:26 ` Haakon Bugge
2021-03-31 21:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Lv Yunlong @ 2021-03-31 1:59 UTC (permalink / raw)
To: santosh.shilimkar, davem, kuba
Cc: netdev, linux-rdma, rds-devel, linux-kernel, Lv Yunlong
In rds_message_map_pages, the rm is freed by rds_message_put(rm).
But rm is still used by rm->data.op_sg in return value.
My patch assigns ERR_CAST(rm->data.op_sg) to err before the rm is
freed to avoid the uaf.
Fixes: 7dba92037baf3 ("net/rds: Use ERR_PTR for rds_message_alloc_sgs()")
Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
---
net/rds/message.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/rds/message.c b/net/rds/message.c
index 071a261fdaab..799034e0f513 100644
--- a/net/rds/message.c
+++ b/net/rds/message.c
@@ -347,8 +347,9 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned in
rm->data.op_nents = DIV_ROUND_UP(total_len, PAGE_SIZE);
rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs);
if (IS_ERR(rm->data.op_sg)) {
+ void *err = ERR_CAST(rm->data.op_sg);
rds_message_put(rm);
- return ERR_CAST(rm->data.op_sg);
+ return err;
}
for (i = 0; i < rm->data.op_nents; ++i) {
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net/rds: Fix a use after free in rds_message_map_pages
2021-03-31 1:59 [PATCH v2] net/rds: Fix a use after free in rds_message_map_pages Lv Yunlong
@ 2021-03-31 18:26 ` Haakon Bugge
2021-03-31 21:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Haakon Bugge @ 2021-03-31 18:26 UTC (permalink / raw)
To: Lv Yunlong
Cc: Santosh Shilimkar, davem, kuba, netdev, OFED mailing list,
rds-devel, linux-kernel
> On 31 Mar 2021, at 03:59, Lv Yunlong <lyl2019@mail.ustc.edu.cn> wrote:
>
> In rds_message_map_pages, the rm is freed by rds_message_put(rm).
> But rm is still used by rm->data.op_sg in return value.
>
> My patch assigns ERR_CAST(rm->data.op_sg) to err before the rm is
> freed to avoid the uaf.
>
> Fixes: 7dba92037baf3 ("net/rds: Use ERR_PTR for rds_message_alloc_sgs()")
> Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>
Thanks for fixing this:-)
Håkon
> ---
> net/rds/message.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/rds/message.c b/net/rds/message.c
> index 071a261fdaab..799034e0f513 100644
> --- a/net/rds/message.c
> +++ b/net/rds/message.c
> @@ -347,8 +347,9 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned in
> rm->data.op_nents = DIV_ROUND_UP(total_len, PAGE_SIZE);
> rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs);
> if (IS_ERR(rm->data.op_sg)) {
> + void *err = ERR_CAST(rm->data.op_sg);
> rds_message_put(rm);
> - return ERR_CAST(rm->data.op_sg);
> + return err;
> }
>
> for (i = 0; i < rm->data.op_nents; ++i) {
> --
> 2.25.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net/rds: Fix a use after free in rds_message_map_pages
2021-03-31 1:59 [PATCH v2] net/rds: Fix a use after free in rds_message_map_pages Lv Yunlong
2021-03-31 18:26 ` Haakon Bugge
@ 2021-03-31 21:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-31 21:30 UTC (permalink / raw)
To: Lv Yunlong
Cc: santosh.shilimkar, davem, kuba, netdev, linux-rdma, rds-devel,
linux-kernel
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
On Tue, 30 Mar 2021 18:59:59 -0700 you wrote:
> In rds_message_map_pages, the rm is freed by rds_message_put(rm).
> But rm is still used by rm->data.op_sg in return value.
>
> My patch assigns ERR_CAST(rm->data.op_sg) to err before the rm is
> freed to avoid the uaf.
>
> Fixes: 7dba92037baf3 ("net/rds: Use ERR_PTR for rds_message_alloc_sgs()")
> Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
>
> [...]
Here is the summary with links:
- [v2] net/rds: Fix a use after free in rds_message_map_pages
https://git.kernel.org/netdev/net/c/bdc2ab5c61a5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-31 21:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 1:59 [PATCH v2] net/rds: Fix a use after free in rds_message_map_pages Lv Yunlong
2021-03-31 18:26 ` Haakon Bugge
2021-03-31 21:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).