Skip to content

Commit 239af19

Browse files
Ilia Gavrilovdavem330
authored andcommitted
llc: fix data loss when reading from a socket in llc_ui_recvmsg()
For SOCK_STREAM sockets, if user buffer size (len) is less than skb size (skb->len), the remaining data from skb will be lost after calling kfree_skb(). To fix this, move the statement for partial reading above skb deletion. Found by InfoTeCS on behalf of Linux Verification Center (linuxtesting.org) Fixes: 30a584d ("[LLX]: SOCK_DGRAM interface fixes") Cc: [email protected] Signed-off-by: Ilia Gavrilov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c46286f commit 239af19

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/llc/af_llc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -887,15 +887,15 @@ static int llc_ui_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
887887
if (sk->sk_type != SOCK_STREAM)
888888
goto copy_uaddr;
889889

890+
/* Partial read */
891+
if (used + offset < skb_len)
892+
continue;
893+
890894
if (!(flags & MSG_PEEK)) {
891895
skb_unlink(skb, &sk->sk_receive_queue);
892896
kfree_skb(skb);
893897
*seq = 0;
894898
}
895-
896-
/* Partial read */
897-
if (used + offset < skb_len)
898-
continue;
899899
} while (len > 0);
900900

901901
out:

0 commit comments

Comments
 (0)