| Summary: | [patch] panic when geom_uncompress tastes large filesystems | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | Keith White <ksw.childe> | ||||||||
| Component: | kern | Assignee: | Andrey V. Elsukov <ae> | ||||||||
| Status: | Closed FIXED | ||||||||||
| Severity: | Affects Only Me | CC: | ae | ||||||||
| Priority: | --- | Keywords: | patch | ||||||||
| Version: | CURRENT | ||||||||||
| Hardware: | Any | ||||||||||
| OS: | Any | ||||||||||
| Attachments: |
|
||||||||||
Created attachment 156873 [details]
Proposed patch
Can you test this patch instead?
Created attachment 156876 [details]
Proposed patch
Tested. The proposed patch avoids the panic. Thanks! A commit references this bug: Author: ae Date: Tue May 19 09:28:52 UTC 2015 New revision: 283104 URL: https://svnweb.freebsd.org/changeset/base/283104 Log: Read GEOM_UNCOMPRESS metadata using several requests that fit into MAXPHYS. For large compressed images the metadata size can be bigger than MAXPHYS and this triggers KASSERT in g_read_data(). Also use g_free() to free memory allocated by g_read_data(). PR: 199476 MFC after: 2 weeks Changes: head/sys/geom/uncompress/g_uncompress.c A commit references this bug: Author: ae Date: Tue Jun 2 02:05:32 UTC 2015 New revision: 283900 URL: https://svnweb.freebsd.org/changeset/base/283900 Log: MFC r283104: Read GEOM_UNCOMPRESS metadata using several requests that fit into MAXPHYS. For large compressed images the metadata size can be bigger than MAXPHYS and this triggers KASSERT in g_read_data(). Also use g_free() to free memory allocated by g_read_data(). PR: 199476 Changes: _U stable/10/ stable/10/sys/geom/uncompress/g_uncompress.c |
Created attachment 155638 [details] patch to fix panic when tasting large compressed filesystems geom_uncompress reads the header and all block offsets with a single g_read_data() request. This will fail (panic) if the total data requested is greater then MAXPHYS. i.e. when the total number of block offsets approaches MAXPHYS / sizeof(uint64). The attached patch changes the method of getting the block offsets to be the same as that used by geom_uzip: sector by sector. Patch attached. Typical panic (please excuse transcription errors): # kldload geom_uncompress md0.uncompress: GEOM_UZIP image found panic: g_read_data(): invalid length 290816 cpuid = 1 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe00932a59c0 vpanic() at vpanic+0x189/frame 0xfffffe00932a5a40 kassert_panic() at kassert_panic+0x132/frame 0xffffe00932a5ab0 g_read_data() at g_read_data+0x45/frame 0xffffe00932a5af0 g_uncompress_taste() at g_uncompress_taste_0x30d/frame 0xfffffe00932a5b40 g_load_class() at g_load_class+0x1cc/frame 0xfffffe00932a5b70 g_run_events() at g_run_events_0x1a7/frame 0xfffffe00932a5bb0 fork_exit() at fork_exit+0x84/frame 0xfffffe00932a5bf0 fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe00932a5bf0 --- trap 0, rip = 0, rsp = 0xfffffe00932a5cb0, rbp = 0 --- KDB: enter: panic [ thread pid 13 tid 100013 ] Stopped at kdb_enter+0x3e: movq $0,kdb_why db>