Skip to content

Commit bbc8a99

Browse files
peilin-yedavem330
authored andcommitted
rds: Prevent kernel-infoleak in rds_notify_queue_get()
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]>
1 parent dc09628 commit bbc8a99

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/rds/recv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,13 @@ static int rds_still_queued(struct rds_sock *rs, struct rds_incoming *inc,
450450
int rds_notify_queue_get(struct rds_sock *rs, struct msghdr *msghdr)
451451
{
452452
struct rds_notifier *notifier;
453-
struct rds_rdma_notify cmsg = { 0 }; /* fill holes with zero */
453+
struct rds_rdma_notify cmsg;
454454
unsigned int count = 0, max_messages = ~0U;
455455
unsigned long flags;
456456
LIST_HEAD(copy);
457457
int err = 0;
458458

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

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

0 commit comments

Comments
 (0)