[PATCH] Fix dl-addr to ensure the address falls in one of the loaded segments

suzuki suzuki@in.ibm.com
Thu Mar 1 18:57:00 GMT 2007


Hi,


We encountered a problem with dl-addr which would return incorrect 
results for an address lookup.

The problem occurs when a library (say libA) is mapped (by glibc) in the 
space between two loaded segments of an already mapped library ( we have 
seen this library is most of the time ld-linux.so). In this case we have,

LD.SO.l_map_start < LIBA.l_map_start < LIBA.l_map_end < LD.SO.l_map_end


So while looking up an address in LIBA, we get the result as LD.SO which 
confuses the caller.

This is due to the following bug in the dl-addr logic:

1) We find a link_map whose [l_map_start,l_map_end) encloses the address.

2) We consult only the *LAST* loaded segment of the lib to check if the 
address lies beyond the segment's end address.

So, if the ld.so is consulted before libA, we end up in returning ld.so 
as the result.

The proper fix here would be to make sure that the address *falls in* 
_any_ of the segments of the library.

Attached here is a patch which we have tested and verified to work.

Please let us know your thoughts about the patch.

If it looks good, please apply.


Thanks

Suzuki K P
Linux Technology Center
IBM





-------------- next part --------------
A non-text attachment was scrubbed...
Name: libc-fix-dl-addr.diff
Type: text/x-patch
Size: 1850 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20070301/15809e6e/attachment.bin>


More information about the Libc-alpha mailing list