Skip to content

Commit 5f1eb1f

Browse files
edumazetdavem330
authored andcommitted
scm: add user copy checks to put_cmsg()
This is a followup of commit 2558b80 ("net: use a bounce buffer for copying skb->mark") x86 and powerpc define user_access_begin, meaning that they are not able to perform user copy checks when using user_write_access_begin() / unsafe_copy_to_user() and friends [1] Instead of waiting bugs to trigger on other arches, add a check_object_size() in put_cmsg() to make sure that new code tested on x86 with CONFIG_HARDENED_USERCOPY=y will perform more security checks. [1] We can not generically call check_object_size() from unsafe_copy_to_user() because UACCESS is enabled at this point. Signed-off-by: Eric Dumazet <[email protected]> Cc: Kees Cook <[email protected]> Acked-by: Kees Cook <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fce1028 commit 5f1eb1f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/core/scm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
229229
if (msg->msg_control_is_user) {
230230
struct cmsghdr __user *cm = msg->msg_control_user;
231231

232+
check_object_size(data, cmlen - sizeof(*cm), true);
233+
232234
if (!user_write_access_begin(cm, cmlen))
233235
goto efault;
234236

0 commit comments

Comments
 (0)