Skip to content

Commit f9b8314

Browse files
herbertxgregkh
authored andcommitted
UPSTREAM: ipv6: raw: Deduct extension header length in rawv6_push_pending_frames
commit cb3e9864cdbe35ff6378966660edbcbac955fe17 upstream. The total cork length created by ip6_append_data includes extension headers, so we must exclude them when comparing them against the IPV6_CHECKSUM offset which does not include extension headers. Reported-by: Kyle Zeng <[email protected]> Fixes: 357b40a ("[IPV6]: IPV6_CHECKSUM socket option can corrupt kernel memory") Change-Id: I73cf556998cab122229e1a361d186925775aad61 Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 35ed8ba485544a31a4ab9b92a1c68e406ab66a47) Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1b1e3a2 commit f9b8314

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/ipv6/raw.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ static int rawv6_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
539539
static int rawv6_push_pending_frames(struct sock *sk, struct flowi6 *fl6,
540540
struct raw6_sock *rp)
541541
{
542+
struct ipv6_txoptions *opt;
542543
struct sk_buff *skb;
543544
int err = 0;
544545
int offset;
@@ -556,6 +557,9 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi6 *fl6,
556557

557558
offset = rp->offset;
558559
total_len = inet_sk(sk)->cork.base.length;
560+
opt = inet6_sk(sk)->cork.opt;
561+
total_len -= opt ? opt->opt_flen : 0;
562+
559563
if (offset >= total_len - 1) {
560564
err = -EINVAL;
561565
ip6_flush_pending_frames(sk);

0 commit comments

Comments
 (0)