-
Notifications
You must be signed in to change notification settings - Fork 61
rtld: Tweak handling of mismatched dynamic tags for PLTs #2366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
This fixes an issue exposed by the test program with per-function compartments. |
What's the actual problem that occurs here though? |
If it's that a binary with .iplt but no .plt has a .got.plt that isn't big enough (i.e. it omits the real .got.plt but includes the IPLT's .got.plt), that exists as an upstream LLVM bug already (though that's using the system LLVM 14 so I guess could be fixed). I'd rather just see LLVM be fixed to not do broken things like that. |
I have compartments that have a PLT with only an IPLT. The IPLT entries were for cross-compartment calls to static functions (in this case each function is in its own compartment including static functions). rtld assumed that there would be the requisite GOT entries at the start for use by PLT0, but without an actual PLT these weren't present and rtld ended up stomping on some of the IGOTPLT entries instead when it tried to write out these initial entries. The other thing I've found that I'm fixing on the lld side is that I didn't need per-compartment rela.iplt sections in the first place, they really should just be part of rela.dyn. Because of one mistake I made, they ended up in the per-compartment rela.plt, but once I fixed the logic I had wrong there, I ended up with per-compartment rela.dyn that weren't covered by any DT_* tag, so then I reverted to a global relaIplt (that is merged into rela.dyn) and things are much simpler. Hmm, and with that fixed, I also no longer have these empty PLTRELSZ entries anymore in my test case (or at least, now you can only get them for the default compartment if it has no real PLT entries, only IPLT entries). I do think the way I'm handling the counting mismatches for the PLT-related DT_* tags is better this way, and it's still true that Morello lld had a bug in older versions that would omit an empty PLTREL that this handles. |
But it's true I might need to rewrite the commit message at least. |
Detect mismatched PLT tags sooner and return false from digest_dynamic1() for a mismatch and remove sanity checks on PLTs from digest_dynamic2(). While here, fix rtld to die if either digest_dynamic call fails for rtld itself.
Ok, this is now just a cosmetic cleanup and is no longer a required "fix" for anything. My aforementioned changes to collapse relaIplt down into the global rela.dyn has been the real fix for the issue I was seeing originally. |
Libarchive 3.7.7 Security fixes: CTSRD-CHERI#2158 rpm: calculate huge header sizes correctly CTSRD-CHERI#2160 util: fix out of boundary access in mktemp functions CTSRD-CHERI#2168 uu: stop processing if lines are too long CTSRD-CHERI#2174 lzop: prevent integer overflow CTSRD-CHERI#2172 rar4: protect copy_from_lzss_window_to_unp() (CVE-2024-20696) CTSRD-CHERI#2175 unzip: unify EOF handling CTSRD-CHERI#2179 rar4: fix out of boundary access with large files CTSRD-CHERI#2203 rar4: fix OOB access with unicode filenames CTSRD-CHERI#2210 rar4: add boundary checks to rgb filter CTSRD-CHERI#2248 rar4: fix OOB in delta filter CTSRD-CHERI#2249 rar4: fix OOB in audio filter CTSRD-CHERI#2256 fix multiple vulnerabilities identified by SAST CTSRD-CHERI#2258 cpio: ignore out-of-range gid/uid/size/ino and harden AFIO parsing CTSRD-CHERI#2265 rar5: clear 'data ready' cache on window buffer reallocs CTSRD-CHERI#2269 rar4: fix CVE-2024-26256 (CVE-2024-26256) CTSRD-CHERI#2330 iso: be more cautious about parsing ISO-9660 timestamps CTSRD-CHERI#2343 tar: clean up linkpath between entries CTSRD-CHERI#2364 tar: don't crash on truncated tar archives CTSRD-CHERI#2366 gzip: prevent a hang when processing a malformed gzip inside a gzip CTSRD-CHERI#2377 tar: fix two leaks in tar header parsing Important bugfixes: CTSRD-CHERI#2096 rar5: report encrypted entries CTSRD-CHERI#2150 xar: fix another infinite loop and expat error handling CTSRD-CHERI#2173 shar: check strdup return value CTSRD-CHERI#2161 lha: fix integer truncation on 32-bit systems CTSRD-CHERI#2338 tar: fix memory leaks when processing symlinks or parsing pax headers CTSRD-CHERI#2245 7zip: fix issue when skipping first file in 7zip archive that is a multiple of 65536 bytes CTSRD-CHERI#2252 7-zip: read/write symlink paths as UTF-8 CTSRD-CHERI#2259 rar5: don't try to read rediculously long names CTSRD-CHERI#2290 ar: fix archive entries having no type CTSRD-CHERI#2360 tar: fix truncation of entry pathnames in specific archives CVE: CVE-2024-20696, CVE-2024-26256 PR: 282047 (exp-run) MFC after: 1 week
Libarchive 3.7.7 Security fixes: CTSRD-CHERI#2158 rpm: calculate huge header sizes correctly CTSRD-CHERI#2160 util: fix out of boundary access in mktemp functions CTSRD-CHERI#2168 uu: stop processing if lines are too long CTSRD-CHERI#2174 lzop: prevent integer overflow CTSRD-CHERI#2172 rar4: protect copy_from_lzss_window_to_unp() (CVE-2024-20696) CTSRD-CHERI#2175 unzip: unify EOF handling CTSRD-CHERI#2179 rar4: fix out of boundary access with large files CTSRD-CHERI#2203 rar4: fix OOB access with unicode filenames CTSRD-CHERI#2210 rar4: add boundary checks to rgb filter CTSRD-CHERI#2248 rar4: fix OOB in delta filter CTSRD-CHERI#2249 rar4: fix OOB in audio filter CTSRD-CHERI#2256 fix multiple vulnerabilities identified by SAST CTSRD-CHERI#2258 cpio: ignore out-of-range gid/uid/size/ino and harden AFIO parsing CTSRD-CHERI#2265 rar5: clear 'data ready' cache on window buffer reallocs CTSRD-CHERI#2269 rar4: fix CVE-2024-26256 (CVE-2024-26256) CTSRD-CHERI#2330 iso: be more cautious about parsing ISO-9660 timestamps CTSRD-CHERI#2343 tar: clean up linkpath between entries CTSRD-CHERI#2364 tar: don't crash on truncated tar archives CTSRD-CHERI#2366 gzip: prevent a hang when processing a malformed gzip inside a gzip CTSRD-CHERI#2377 tar: fix two leaks in tar header parsing Important bugfixes: CTSRD-CHERI#2096 rar5: report encrypted entries CTSRD-CHERI#2150 xar: fix another infinite loop and expat error handling CTSRD-CHERI#2173 shar: check strdup return value CTSRD-CHERI#2161 lha: fix integer truncation on 32-bit systems CTSRD-CHERI#2338 tar: fix memory leaks when processing symlinks or parsing pax headers CTSRD-CHERI#2245 7zip: fix issue when skipping first file in 7zip archive that is a multiple of 65536 bytes CTSRD-CHERI#2252 7-zip: read/write symlink paths as UTF-8 CTSRD-CHERI#2259 rar5: don't try to read rediculously long names CTSRD-CHERI#2290 ar: fix archive entries having no type CTSRD-CHERI#2360 tar: fix truncation of entry pathnames in specific archives CVE: CVE-2024-20696, CVE-2024-26256 PR: 282047 (exp-run) MFC after: 1 week
With compartmentalized binaries, a compartment might contain a PLT
that only has IPLT stubs. lld still emits DT_ tags for such a PLT,
but the DT_PLTRELSZ tag is zero. To handle these, scan the Plt_Entry
structures after scanning .dynamic and drop entries with zero size.
This also handles the aarch64 special case for a Morello LLD bug.
While here, rework some of the multi-plt handling. Detect mismatched
PLT tags sooner and return false from digest_dynamic1() for a mismatch
and remove sanity checks on PLTs from digest_dynamic2().
While here, fix rtld to die if either digest_dynamic call fails for
rtld itself.