Skip to content

Commit

Permalink
rds: rds_msg_zcopy should return error of null rm->data.op_mmp_znotifier
Browse files Browse the repository at this point in the history
if either or both of MSG_ZEROCOPY and SOCK_ZEROCOPY have not been
specified, the rm->data.op_mmp_znotifier allocation will be skipped.
In this case, it is invalid ot pass down a cmsghdr with
RDS_CMSG_ZCOPY_COOKIE, so return EINVAL from rds_msg_zcopy for this
case.

Reported-by: syzbot+f893ae7bb2f6456dfbc3@syzkaller.appspotmail.com
Fixes: 0cebacc ("rds: zerocopy Tx support.")
Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sowmini Varadhan authored and David S. Miller committed Feb 23, 2018
1 parent 9dbe789 commit 79a5b97
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/rds/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,8 @@ static int rds_cmsg_zcopy(struct rds_sock *rs, struct rds_message *rm,
{
u32 *cookie;

if (cmsg->cmsg_len < CMSG_LEN(sizeof(*cookie)))
if (cmsg->cmsg_len < CMSG_LEN(sizeof(*cookie)) ||
!rm->data.op_mmp_znotifier)
return -EINVAL;
cookie = CMSG_DATA(cmsg);
rm->data.op_mmp_znotifier->z_cookie = *cookie;
Expand Down

0 comments on commit 79a5b97

Please sign in to comment.