Skip to content

Commit

Permalink
net/rds: Avoid potential use after free in rds_send_remove_from_sock
Browse files Browse the repository at this point in the history
In case of rs failure in rds_send_remove_from_sock(), the 'rm' resource
is freed and later under spinlock, causing potential use-after-free.
Set the free pointer to NULL to avoid undefined behavior.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Aditya Pakki authored and davem330 committed Apr 7, 2021
1 parent 5219d60 commit 0c85a7e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions net/rds/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ void rds_message_put(struct rds_message *rm)
rds_message_purge(rm);

kfree(rm);
rm = NULL;
}
}
EXPORT_SYMBOL_GPL(rds_message_put);
Expand Down
2 changes: 1 addition & 1 deletion net/rds/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ static void rds_send_remove_from_sock(struct list_head *messages, int status)
unlock_and_drop:
spin_unlock_irqrestore(&rm->m_rs_lock, flags);
rds_message_put(rm);
if (was_on_sock)
if (was_on_sock && rm)
rds_message_put(rm);
}

Expand Down

0 comments on commit 0c85a7e

Please sign in to comment.