Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 597792 - PAX: size overflow detected in function ipv6_frag_rcv net/ipv6/reassembly.c:223
Summary: PAX: size overflow detected in function ipv6_frag_rcv net/ipv6/reassembly.c:223
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: The Gentoo Linux Hardened Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-22 15:13 UTC by Alexander Wetzel
Modified: 2022-05-28 07:53 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Kernel panic captured on serial (panic-serial,2.05 KB, text/plain)
2016-10-22 15:13 UTC, Alexander Wetzel
Details
hack.diff (hack.diff,1.13 KB, patch)
2016-10-23 12:39 UTC, Alexander Wetzel
Details | Diff
panic4-suspect2-capture (panic4-suspect2-capture,5.98 KB, text/plain)
2016-10-23 12:41 UTC, Alexander Wetzel
Details
suspect_2.pcap.gz (suspect_2.pcap.gz,2.75 KB, application/x-gzip)
2016-10-23 12:41 UTC, Alexander Wetzel
Details
Proposed/Tested patch by Pax team (pax-overflow2.patch,514 bytes, patch)
2016-10-23 16:46 UTC, Alexander Wetzel
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Wetzel 2016-10-22 15:13:53 UTC
Created attachment 451036 [details]
Kernel panic captured on serial

sys-kernel/hardened-sources-4.7.6 and sys-kernel/hardened-sources-4.7.9 panic, probably on some specific ipv6 packets. (The system is running within libvirt/kvm.)

I only have a full crash logs for sys-kernel/hardened-sources-4.7.9, since the crashes did not fit on the screen. (They looked basically the same, only most of the backtrace was visible there.)

The system crashed mutliple times today after updating to 4.7.*, normally in the first minute, but so far I have not found out which packet(s) is triggering the crash.

I captured one the crash via the serial console and another in the logs after setting pax_size_overflow_report_only.

I'm plan to find out more and provide more details here.

Speculation:
I had also crashes for another VM running on the same host when using 4.7.7-hardened. Reverting back to 4.7.6-hardened fixed the issue there.
Comment 1 Alexander Wetzel 2016-10-23 12:38:21 UTC
I have captured the packets triggering the pax overflow panic. (I have captured two different occurrences but I'll stick to the later one here.)

panic4-suspect2-capture shows the log messages and suspect_2.pcap.gz has the packets triggering those messages (frame 16+17).

The logfile also prints out the values of the variables used in the calculation.
See the uploaded diff (hack.diff) how the printk was constructed. 
For these log only the first printk line from the diff was added to the kernel, the other changes in the patch were not yet present. (The calculation was not touched at all.)

With the full changes in the patch pax no longer detects a overrun, but I suspect the patch is wrong and will sometimes calculate wrong values for temp. (I'm now removed the line "temp &= 0xff;" and suspect that will also fix the issue.)

With the full patch I no longer get the Pax Overruns, but here the debug output of the added printk line for today:

Oct 23 09:33:01 gandalf kernel: DDD ip6_frag_queue  offset=0; payload_len=4d8; fhdr1=cf35ac7e; ipv6_hdr=cf35ac76
Oct 23 09:33:01 gandalf kernel: DDD ip6_frag_queue2 end=4d0
Oct 23 09:33:01 gandalf kernel: DDD ip6_frag_queue  offset=4d0; payload_len=e4; fhdr1=cf35aa7e; ipv6_hdr=cf35aa76
Oct 23 09:33:01 gandalf kernel: DDD ip6_frag_queue2 end=5ac
Oct 23 10:02:34 gandalf kernel: DDD ip6_frag_queue  offset=0; payload_len=4d8; fhdr1=ccf8ea7e; ipv6_hdr=ccf8ea76
Oct 23 10:02:34 gandalf kernel: DDD ip6_frag_queue2 end=4d0
Oct 23 10:02:34 gandalf kernel: DDD ip6_frag_queue  offset=4d0; payload_len=8e; fhdr1=ccf8e87e; ipv6_hdr=ccf8e876
Oct 23 10:02:34 gandalf kernel: DDD ip6_frag_queue2 end=556
Oct 23 11:33:00 gandalf kernel: DDD ip6_frag_queue  offset=0; payload_len=4d8; fhdr1=b7cf87e; ipv6_hdr=b7cf876
Oct 23 11:33:00 gandalf kernel: DDD ip6_frag_queue2 end=4d0
Oct 23 11:33:00 gandalf kernel: DDD ip6_frag_queue  offset=4d0; payload_len=e4; fhdr1=b7cf67e; ipv6_hdr=b7cf676
Oct 23 11:33:00 gandalf kernel: DDD ip6_frag_queue2 end=5ac
Oct 23 13:14:12 gandalf kernel: DDD ip6_frag_queue  offset=0; payload_len=4d8; fhdr1=bd115e7e; ipv6_hdr=bd115e76
Oct 23 13:14:12 gandalf kernel: DDD ip6_frag_queue2 end=4d0
Oct 23 13:14:12 gandalf kernel: DDD ip6_frag_queue  offset=4d0; payload_len=199; fhdr1=bd115c7e; ipv6_hdr=bd115c76
Oct 23 13:14:12 gandalf kernel: DDD ip6_frag_queue2 end=661
Oct 23 13:21:59 gandalf kernel: DDD ip6_frag_queue  offset=0; payload_len=4d8; fhdr1=bde3887e; ipv6_hdr=bde38876
Oct 23 13:21:59 gandalf kernel: DDD ip6_frag_queue2 end=4d0
Oct 23 13:21:59 gandalf kernel: DDD ip6_frag_queue  offset=4d0; payload_len=e4; fhdr1=bde3867e; ipv6_hdr=bde38676
Oct 23 13:21:59 gandalf kernel: DDD ip6_frag_queue2 end=5ac
Oct 23 14:33:02 gandalf kernel: DDD ip6_frag_queue  offset=0; payload_len=4d8; fhdr1=b0ffa47e; ipv6_hdr=b0ffa476
Oct 23 14:33:02 gandalf kernel: DDD ip6_frag_queue2 end=4d0
Oct 23 14:33:02 gandalf kernel: DDD ip6_frag_queue  offset=4d0; payload_len=e4; fhdr1=b0ffa27e; ipv6_hdr=b0ffa276
Oct 23 14:33:02 gandalf kernel: DDD ip6_frag_queue2 end=5ac
Comment 2 Alexander Wetzel 2016-10-23 12:39:37 UTC
Created attachment 451094 [details, diff]
hack.diff
Comment 3 Alexander Wetzel 2016-10-23 12:41:23 UTC
Created attachment 451096 [details]
panic4-suspect2-capture
Comment 4 Alexander Wetzel 2016-10-23 12:41:57 UTC
Created attachment 451098 [details]
suspect_2.pcap.gz
Comment 5 Alexander Wetzel 2016-10-23 13:56:59 UTC
Asked for support from the PAX team:
https://forums.grsecurity.net/viewtopic.php?f=3&t=4594
Comment 6 Anthony Basile gentoo-dev 2016-10-23 14:30:23 UTC
I'm passing this upstream.  Unfortunately I'm going to have to stabilize 4.7.9 for CVE-2016-5195
Comment 7 Alexander Wetzel 2016-10-23 16:46:01 UTC
Created attachment 451160 [details, diff]
Proposed/Tested patch by Pax team

The patch proposed on the PAX mailing list works for me.

Guess it's too late to get that added to sys-kernel/hardened-sources-4.7.9 prior to stabilizing it? 

Without this patch sys-kernel/hardened-sources-4.7.6 and 
sys-kernel/hardened-sources-4.7.9 are just waiting to crash if they have an ipv6 connection...
Comment 8 PaX Team 2016-10-23 17:28:04 UTC
(In reply to alexander.wetzel from comment #7)
> Without this patch sys-kernel/hardened-sources-4.7.6 and 
> sys-kernel/hardened-sources-4.7.9 are just waiting to crash if they have an
> ipv6 connection...
only if they enable PAX_SIZE_OVERFLOW_EXTRA.