diff options
author | Christoph Hellwig <hch@lst.de> | 2020-05-11 13:59:11 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-05-11 16:59:16 -0700 |
commit | 0462b6bdb6445b887b8896f28be92e0d94c92e7b (patch) | |
tree | 9d4b3f468d481aa66b31e5cdb6ad532458889c4d /net/core/scm.c | |
parent | 3242956bd610af40e884b530b6c6f76f5bf85f3b (diff) | |
download | linux-0462b6bdb6445b887b8896f28be92e0d94c92e7b.tar.gz linux-0462b6bdb6445b887b8896f28be92e0d94c92e7b.tar.bz2 linux-0462b6bdb6445b887b8896f28be92e0d94c92e7b.zip |
net: add a CMSG_USER_DATA macro
Add a variant of CMSG_DATA that operates on user pointer to avoid
sparse warnings about casting to/from user pointers. Also fix up
CMSG_DATA to rely on the gcc extension that allows void pointer
arithmetics to cut down on the amount of casts.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/scm.c')
-rw-r--r-- | net/core/scm.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/core/scm.c b/net/core/scm.c index dc6fed1f221c..abfdc85a64c1 100644 --- a/net/core/scm.c +++ b/net/core/scm.c @@ -236,7 +236,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data) err = -EFAULT; if (copy_to_user(cm, &cmhdr, sizeof cmhdr)) goto out; - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr))) + if (copy_to_user(CMSG_USER_DATA(cm), data, cmlen - sizeof(*cm))) goto out; cmlen = CMSG_SPACE(len); if (msg->msg_controllen < cmlen) @@ -300,7 +300,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm) if (fdnum < fdmax) fdmax = fdnum; - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax; + for (i=0, cmfptr =(int __user *)CMSG_USER_DATA(cm); i<fdmax; i++, cmfptr++) { struct socket *sock; |