[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210330101602.22505-1-lyl2019@mail.ustc.edu.cn>
Date: Tue, 30 Mar 2021 03:16:02 -0700
From: Lv Yunlong <lyl2019@...l.ustc.edu.cn>
To: santosh.shilimkar@...cle.com, davem@...emloft.net, kuba@...nel.org
Cc: netdev@...r.kernel.org, linux-rdma@...r.kernel.org,
rds-devel@....oracle.com, linux-kernel@...r.kernel.org,
Lv Yunlong <lyl2019@...l.ustc.edu.cn>
Subject: [PATCH] net/rds: Fix a use after free in rds_message_map_pages
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 replaces ERR_CAST(rm->data.op_sg) to ERR_PTR(-ENOMEM) to avoid
the uaf.
Fixes: 7dba92037baf3 ("net/rds: Use ERR_PTR for rds_message_alloc_sgs()")
Signed-off-by: Lv Yunlong <lyl2019@...l.ustc.edu.cn>
---
net/rds/message.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/rds/message.c b/net/rds/message.c
index 071a261fdaab..cecd968c9b25 100644
--- a/net/rds/message.c
+++ b/net/rds/message.c
@@ -348,7 +348,7 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned in
rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs);
if (IS_ERR(rm->data.op_sg)) {
rds_message_put(rm);
- return ERR_CAST(rm->data.op_sg);
+ return ERR_PTR(-ENOMEM);
}
for (i = 0; i < rm->data.op_nents; ++i) {
--
2.25.1
Powered by blists - more mailing lists