relibc: replace 2 panic-site unimplemented!() in dynamic linker with proper errors
Two catch-all branches in the dynamic linker panicked the process if
an executable used a relocation type not handled by the explicit match
arms. Both functions are Result-returning, but the catch-all used
unimplemented!() which expands to panic!() — silently killing the
process instead of returning Err.
* ld_so/dso.rs:1129 (static_relocate): the
_ => unimplemented!("relocation type {:?}", reloc.kind)
arm panics for any relocation not in the match. Now returns
Err(format!("unsupported relocation type {:?}", reloc.kind)).
Process startup with an unfamiliar relocation type now fails
gracefully at dlopen time instead of aborting.
* ld_so/dso.rs:1203 (lazy_relocate): same pattern in the
(reloc.kind, resolve) match. Now returns
Err(format!("unsupported relocation type {:?} with resolve {:?}",
reloc.kind, resolve)).
This is the third round of relibc panic-site fixes (after RTLD_NOLOAD|
RTLD_NOW and readdir_r). Found by the Round 10 audit
(local/docs/3D-DESKTOP-COMPREHENSIVE-PLAN.md §10).
This commit is contained in:
+6
-4
@@ -1126,7 +1126,9 @@ impl DSO {
|
||||
RelocationKind::TLSDESC => {
|
||||
self.do_tlsdesc_reloc(reloc, ptr.cast::<usize>(), global_scope)
|
||||
}
|
||||
_ => unimplemented!("relocation type {:?}", reloc.kind),
|
||||
_ => {
|
||||
return Err(format!("unsupported relocation type {:?}", reloc.kind));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1200,11 +1202,11 @@ impl DSO {
|
||||
}
|
||||
|
||||
_ => {
|
||||
unimplemented!(
|
||||
"relocation type {:?} with resolve {:?}",
|
||||
return Err(format!(
|
||||
"unsupported relocation type {:?} with resolve {:?}",
|
||||
reloc.kind,
|
||||
resolve
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user