scm: fix a typo in put_cmsg()
authorEric Dumazet <edumazet@google.com>
Fri, 16 Apr 2021 18:35:38 +0000 (11:35 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Apr 2021 18:41:07 +0000 (11:41 -0700)
We need to store cmlen instead of len in cm->cmsg_len.

Fixes: 38ebcf5096a8 ("scm: optimize put_cmsg()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/scm.c

index bd96c92..ae3085d 100644 (file)
@@ -232,7 +232,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
                if (!user_write_access_begin(cm, cmlen))
                        goto efault;
 
-               unsafe_put_user(len, &cm->cmsg_len, efault_end);
+               unsafe_put_user(cmlen, &cm->cmsg_len, efault_end);
                unsafe_put_user(level, &cm->cmsg_level, efault_end);
                unsafe_put_user(type, &cm->cmsg_type, efault_end);
                unsafe_copy_to_user(CMSG_USER_DATA(cm), data,