-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libunwind] Fix wrong end argument passed to decodeEHHdr() #68813
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
Conversation
@llvm/pr-subscribers-libunwind Author: Alexander Richardson (arichardson) ChangesIt previously took a start+end pint_t, but all but one callsite were actually passing start+length arguments. This should not have any functional change since the end argument is almost always ignored. I noticed this while debugging some incorrect error messages being printed while running the testsuite baremetal (using binaries that did not have a valid eh_frame_hdr section): the tests print Full diff: https://github.com/llvm/llvm-project/pull/68813.diff 1 Files Affected:
diff --git a/libunwind/src/EHHeaderParser.hpp b/libunwind/src/EHHeaderParser.hpp
index ed4317c89055c9e..2162178e10bb2fb 100644
--- a/libunwind/src/EHHeaderParser.hpp
+++ b/libunwind/src/EHHeaderParser.hpp
@@ -35,7 +35,7 @@ template <typename A> class EHHeaderParser {
uint8_t table_enc;
};
- static bool decodeEHHdr(A &addressSpace, pint_t ehHdrStart, pint_t ehHdrEnd,
+ static bool decodeEHHdr(A &addressSpace, pint_t ehHdrStart, size_t ehHdrSize,
EHHeaderInfo &ehHdrInfo);
static bool findFDE(A &addressSpace, pint_t pc, pint_t ehHdrStart,
uint32_t sectionLength,
@@ -53,8 +53,9 @@ template <typename A> class EHHeaderParser {
template <typename A>
bool EHHeaderParser<A>::decodeEHHdr(A &addressSpace, pint_t ehHdrStart,
- pint_t ehHdrEnd, EHHeaderInfo &ehHdrInfo) {
+ size_t ehHdrSize, EHHeaderInfo &ehHdrInfo) {
pint_t p = ehHdrStart;
+ pint_t ehHdrEnd = ehHdrStart + ehHdrSize;
uint8_t version = addressSpace.get8(p++);
if (version != 1) {
_LIBUNWIND_LOG("unsupported .eh_frame_hdr version: %" PRIu8 " at %" PRIx64,
@@ -106,7 +107,7 @@ bool EHHeaderParser<A>::findFDE(A &addressSpace, pint_t pc, pint_t ehHdrStart,
pint_t ehHdrEnd = ehHdrStart + sectionLength;
EHHeaderParser<A>::EHHeaderInfo hdrInfo;
- if (!EHHeaderParser<A>::decodeEHHdr(addressSpace, ehHdrStart, ehHdrEnd,
+ if (!EHHeaderParser<A>::decodeEHHdr(addressSpace, ehHdrStart, sectionLength,
hdrInfo))
return false;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we merge this into #68815 please?
All but one callsite were actually passing start+length arguments. This should not have any functional change since the end argument is almost always ignored. I noticed this while debugging some incorrect error messages being printed while running the testsuite baremetal (using binaries that did not have a valid eh_frame_hdr section): the tests print `libunwind: unsupported .eh_frame_hdr version: 20 at 8000d308` because libunwind is reading nonsense data for .eh_frame_hdr.
f5b7f1f
to
ff360ee
Compare
I'd like to keep the two commits separate since they are addressing different bugs. |
This would be a lot easier if I could chose rebase+merge in the PR flow. |
All but one callsite were actually passing start+length arguments.
This should not have any functional change since the end argument is
almost always ignored.
I noticed this while debugging some incorrect error messages being
printed while running the testsuite baremetal (using binaries that did
not have a valid eh_frame_hdr section): the tests print
libunwind: unsupported .eh_frame_hdr version: 20 at https://github.com/arichardson/upstream-llvm-project/commit/8000d308146ebf49cb364cb600e28a0a42e22c83
becauselibunwind is reading nonsense data for .eh_frame_hdr.