mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-06 13:16:22 +00:00
net: llc: fix use after free in llc_ui_recvmsg
[ Upstream commit4d231b76ee
] While commit30a584d944
fixes datagram interface in LLC, a use after free bug has been introduced for SOCK_STREAM sockets that do not make use of MSG_PEEK. The flow is as follow ... if (!(flags & MSG_PEEK)) { ... sk_eat_skb(sk, skb, false); ... } ... if (used + offset < skb->len) continue; ... where sk_eat_skb() calls __kfree_skb(). Therefore, cache original length and work on skb_len to check partial reads. Fixes:30a584d944
("[LLX]: SOCK_DGRAM interface fixes") Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Cc: Stephen Hemminger <stephen@networkplumber.org> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Willy Tarreau <w@1wt.eu>
This commit is contained in:
parent
db091f2ff4
commit
6a6c028da0
@ -669,7 +669,7 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
|
|||||||
struct llc_sock *llc = llc_sk(sk);
|
struct llc_sock *llc = llc_sk(sk);
|
||||||
size_t copied = 0;
|
size_t copied = 0;
|
||||||
u32 peek_seq = 0;
|
u32 peek_seq = 0;
|
||||||
u32 *seq;
|
u32 *seq, skb_len;
|
||||||
unsigned long used;
|
unsigned long used;
|
||||||
int target; /* Read at least this many bytes */
|
int target; /* Read at least this many bytes */
|
||||||
long timeo;
|
long timeo;
|
||||||
@ -767,6 +767,7 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
found_ok_skb:
|
found_ok_skb:
|
||||||
|
skb_len = skb->len;
|
||||||
/* Ok so how much can we use? */
|
/* Ok so how much can we use? */
|
||||||
used = skb->len - offset;
|
used = skb->len - offset;
|
||||||
if (len < used)
|
if (len < used)
|
||||||
@ -797,7 +798,7 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
|
|||||||
goto copy_uaddr;
|
goto copy_uaddr;
|
||||||
|
|
||||||
/* Partial read */
|
/* Partial read */
|
||||||
if (used + offset < skb->len)
|
if (used + offset < skb_len)
|
||||||
continue;
|
continue;
|
||||||
} while (len > 0);
|
} while (len > 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user