diff options
-rw-r--r-- | net/compat.c | 2 | ||||
-rw-r--r-- | net/core/scm.c | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/net/compat.c b/net/compat.c index d74d82155d78..377e560ab5c9 100644 --- a/net/compat.c +++ b/net/compat.c | |||
@@ -254,6 +254,8 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat | |||
254 | if (copy_to_user(CMSG_COMPAT_DATA(cm), data, cmlen - sizeof(struct compat_cmsghdr))) | 254 | if (copy_to_user(CMSG_COMPAT_DATA(cm), data, cmlen - sizeof(struct compat_cmsghdr))) |
255 | return -EFAULT; | 255 | return -EFAULT; |
256 | cmlen = CMSG_COMPAT_SPACE(len); | 256 | cmlen = CMSG_COMPAT_SPACE(len); |
257 | if (kmsg->msg_controllen < cmlen) | ||
258 | cmlen = kmsg->msg_controllen; | ||
257 | kmsg->msg_control += cmlen; | 259 | kmsg->msg_control += cmlen; |
258 | kmsg->msg_controllen -= cmlen; | 260 | kmsg->msg_controllen -= cmlen; |
259 | return 0; | 261 | return 0; |
diff --git a/net/core/scm.c b/net/core/scm.c index 100ba6d9d478..10f5c65f6a47 100644 --- a/net/core/scm.c +++ b/net/core/scm.c | |||
@@ -196,6 +196,8 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data) | |||
196 | if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr))) | 196 | if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr))) |
197 | goto out; | 197 | goto out; |
198 | cmlen = CMSG_SPACE(len); | 198 | cmlen = CMSG_SPACE(len); |
199 | if (msg->msg_controllen < cmlen) | ||
200 | cmlen = msg->msg_controllen; | ||
199 | msg->msg_control += cmlen; | 201 | msg->msg_control += cmlen; |
200 | msg->msg_controllen -= cmlen; | 202 | msg->msg_controllen -= cmlen; |
201 | err = 0; | 203 | err = 0; |