diff options
author | yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn> | 2017-01-03 07:42:17 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-01-04 13:04:37 -0500 |
commit | 1ff8cebf49ed9e9ca2ae44b5c4176aef9c21af9c (patch) | |
tree | 0f0a0657be00abd5c252ebe5ce59a4dca04a3345 /net/compat.c | |
parent | ec2507d2a3060a970fa314556891828cfd60093e (diff) |
scm: remove use CMSG{_COMPAT}_ALIGN(sizeof(struct {compat_}cmsghdr))
sizeof(struct cmsghdr) and sizeof(struct compat_cmsghdr) already aligned.
remove use CMSG_ALIGN(sizeof(struct cmsghdr)) and
CMSG_COMPAT_ALIGN(sizeof(struct compat_cmsghdr)) keep code consistent.
Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/compat.c')
-rw-r--r-- | net/compat.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/net/compat.c b/net/compat.c index 96c544b05b15..4e27dd1cd3a6 100644 --- a/net/compat.c +++ b/net/compat.c | |||
@@ -90,11 +90,11 @@ int get_compat_msghdr(struct msghdr *kmsg, | |||
90 | #define CMSG_COMPAT_ALIGN(len) ALIGN((len), sizeof(s32)) | 90 | #define CMSG_COMPAT_ALIGN(len) ALIGN((len), sizeof(s32)) |
91 | 91 | ||
92 | #define CMSG_COMPAT_DATA(cmsg) \ | 92 | #define CMSG_COMPAT_DATA(cmsg) \ |
93 | ((void __user *)((char __user *)(cmsg) + CMSG_COMPAT_ALIGN(sizeof(struct compat_cmsghdr)))) | 93 | ((void __user *)((char __user *)(cmsg) + sizeof(struct compat_cmsghdr))) |
94 | #define CMSG_COMPAT_SPACE(len) \ | 94 | #define CMSG_COMPAT_SPACE(len) \ |
95 | (CMSG_COMPAT_ALIGN(sizeof(struct compat_cmsghdr)) + CMSG_COMPAT_ALIGN(len)) | 95 | (sizeof(struct compat_cmsghdr) + CMSG_COMPAT_ALIGN(len)) |
96 | #define CMSG_COMPAT_LEN(len) \ | 96 | #define CMSG_COMPAT_LEN(len) \ |
97 | (CMSG_COMPAT_ALIGN(sizeof(struct compat_cmsghdr)) + (len)) | 97 | (sizeof(struct compat_cmsghdr) + (len)) |
98 | 98 | ||
99 | #define CMSG_COMPAT_FIRSTHDR(msg) \ | 99 | #define CMSG_COMPAT_FIRSTHDR(msg) \ |
100 | (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \ | 100 | (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \ |
@@ -141,8 +141,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk, | |||
141 | if (!CMSG_COMPAT_OK(ucmlen, ucmsg, kmsg)) | 141 | if (!CMSG_COMPAT_OK(ucmlen, ucmsg, kmsg)) |
142 | return -EINVAL; | 142 | return -EINVAL; |
143 | 143 | ||
144 | tmp = ((ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))) + | 144 | tmp = ((ucmlen - sizeof(*ucmsg)) + sizeof(struct cmsghdr)); |
145 | CMSG_ALIGN(sizeof(struct cmsghdr))); | ||
146 | tmp = CMSG_ALIGN(tmp); | 145 | tmp = CMSG_ALIGN(tmp); |
147 | kcmlen += tmp; | 146 | kcmlen += tmp; |
148 | ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen); | 147 | ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen); |
@@ -168,8 +167,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk, | |||
168 | goto Efault; | 167 | goto Efault; |
169 | if (!CMSG_COMPAT_OK(ucmlen, ucmsg, kmsg)) | 168 | if (!CMSG_COMPAT_OK(ucmlen, ucmsg, kmsg)) |
170 | goto Einval; | 169 | goto Einval; |
171 | tmp = ((ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))) + | 170 | tmp = ((ucmlen - sizeof(*ucmsg)) + sizeof(struct cmsghdr)); |
172 | CMSG_ALIGN(sizeof(struct cmsghdr))); | ||
173 | if ((char *)kcmsg_base + kcmlen - (char *)kcmsg < CMSG_ALIGN(tmp)) | 171 | if ((char *)kcmsg_base + kcmlen - (char *)kcmsg < CMSG_ALIGN(tmp)) |
174 | goto Einval; | 172 | goto Einval; |
175 | kcmsg->cmsg_len = tmp; | 173 | kcmsg->cmsg_len = tmp; |
@@ -178,7 +176,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk, | |||
178 | __get_user(kcmsg->cmsg_type, &ucmsg->cmsg_type) || | 176 | __get_user(kcmsg->cmsg_type, &ucmsg->cmsg_type) || |
179 | copy_from_user(CMSG_DATA(kcmsg), | 177 | copy_from_user(CMSG_DATA(kcmsg), |
180 | CMSG_COMPAT_DATA(ucmsg), | 178 | CMSG_COMPAT_DATA(ucmsg), |
181 | (ucmlen - CMSG_COMPAT_ALIGN(sizeof(*ucmsg))))) | 179 | (ucmlen - sizeof(*ucmsg)))) |
182 | goto Efault; | 180 | goto Efault; |
183 | 181 | ||
184 | /* Advance. */ | 182 | /* Advance. */ |