Skip to content

Commit

Permalink
rds: Prevent kernel-infoleak in rds_notify_queue_get()
Browse files Browse the repository at this point in the history
rds_notify_queue_get() is potentially copying uninitialized kernel stack
memory to userspace since the compiler may leave a 4-byte hole at the end
of `cmsg`.

In 2016 we tried to fix this issue by doing `= { 0 };` on `cmsg`, which
unfortunately does not always initialize that 4-byte hole. Fix it by using
memset() instead.

Cc: [email protected]
Fixes: f037590 ("rds: fix a leak of kernel memory")
Fixes: bdbe6fb ("RDS: recv.c")
Suggested-by: Dan Carpenter <[email protected]>
Signed-off-by: Peilin Ye <[email protected]>
Acked-by: Santosh Shilimkar <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
peilin-ye authored and davem330 committed Jul 31, 2020
1 parent dc09628 commit bbc8a99
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/rds/recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,13 @@ static int rds_still_queued(struct rds_sock *rs, struct rds_incoming *inc,
int rds_notify_queue_get(struct rds_sock *rs, struct msghdr *msghdr)
{
struct rds_notifier *notifier;
struct rds_rdma_notify cmsg = { 0 }; /* fill holes with zero */
struct rds_rdma_notify cmsg;
unsigned int count = 0, max_messages = ~0U;
unsigned long flags;
LIST_HEAD(copy);
int err = 0;

memset(&cmsg, 0, sizeof(cmsg)); /* fill holes with zero */

/* put_cmsg copies to user space and thus may sleep. We can't do this
* with rs_lock held, so first grab as many notifications as we can stuff
Expand Down

0 comments on commit bbc8a99

Please sign in to comment.