Closed Bug 1663983 Opened 4 years ago Closed 1 year ago

Identify / disambiguate crashes caused by guard page accesses

Categories

(Core :: Memory Allocator, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
Tracking Status
firefox82 --- affected

People

(Reporter: gcp, Assigned: afranchuk)

References

Details

Attachments

(1 file)

We currently have trailing guard pages on normal and large jemalloc allocations (see e.g. https://bugzilla.mozilla.org/show_bug.cgi?id=1446040).

This means that any crash where we have a read/write at a 1M-4K to 1M offset inside the heap is something hitting the guard pages. Such crashes identify potential security bugs.

We should probably find out a way to find and dig them out of Socorro data - currently we don't do anything with this.

One complexity is that large allocations (>=1M) don't have a guard page in the middle, so just going by offset might include other bugs.

David Major explained me that PHC identifies PHC violations by hooking the crash reporter and querying whether a crash is in a PHC page. I don't see why we wouldn't be able to do the same with jemalloc and check if it was a guard page.

glandium, njn, can you comment on whether what I'm saying sounds sensible enough?

Flags: needinfo?(n.nethercote)
Flags: needinfo?(mh+mozilla)

The idea seems reasonable. Here is the crash reporter hooking code. Here is another relevant location for Linux; other platforms are similar. From those two locations you can follow the plumbing around to get the idea.

Flags: needinfo?(n.nethercote)
Flags: needinfo?(mh+mozilla)

Implementation-wise, I'd go with adding an enum value for guard pages to PtrInfoTag in mozjemalloc_types.h and make jemalloc_ptr_info be able to handle them. It would be nice to make the PHC part rely on jemalloc_ptr_info too, but that be a lot of extra work (and would require a lot more thought to make it fit in the replace-malloc scheme).

It seems like this functionality can be integrated into rust-minidump infrastructure fairly easily. We can just look at the memory maps to determine likely guard pages (1 page in size, no permissions). While this wouldn't be getting explicit information from the memory allocator, it's likely to be fairly accurate as no-permission pages are often used for this purpose alone. This also has the benefit of being a more general solution that could flag other buffer overruns which use guard pages as a safety measure.

In minidump-processor, we already have all the memory map information available, so finding likely guard pages and adding a flag for cases where an invalid memory access was in a guard page is a small effort, likely no more than 8 hours of work.

:gcp, this is merged in minidump-processor and exposed in the JSON output. We may want to keep this bug open to cover Socorro changes, or we may want to open a new, more specific one. Let me know what you'd like.

Flags: needinfo?(gpascutto)

I think it's best to open a new bug in the right product.

Flags: needinfo?(gpascutto)
See Also: → 1830954

Bug 1830954 covers the Socorro implementation.

Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: