Skip to content

Commit bdc2ab5

Browse files
Yunlongsdavem330
authored andcommitted
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 assigns ERR_CAST(rm->data.op_sg) to err before the rm is freed to avoid the uaf. Fixes: 7dba920 ("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> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d47ec7a commit bdc2ab5

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎net/rds/message.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,9 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned in
347347
rm->data.op_nents = DIV_ROUND_UP(total_len, PAGE_SIZE);
348348
rm->data.op_sg = rds_message_alloc_sgs(rm, num_sgs);
349349
if (IS_ERR(rm->data.op_sg)) {
350+
void *err = ERR_CAST(rm->data.op_sg);
350351
rds_message_put(rm);
351-
return ERR_CAST(rm->data.op_sg);
352+
return err;
352353
}
353354

354355
for (i = 0; i < rm->data.op_nents; ++i) {

0 commit comments

Comments
 (0)