Page MenuHomeFreeBSD

Fix kldxref failing for modules with a short mc_cval
ClosedPublic

Authored by mhorne063_gmail.com on Jan 15 2018, 7:21 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 20, 7:20 PM
Unknown Object (File)
Fri, Apr 18, 7:45 AM
Unknown Object (File)
Sun, Apr 13, 12:11 PM
Unknown Object (File)
Sun, Apr 13, 1:08 AM
Unknown Object (File)
Mon, Apr 7, 1:22 PM
Unknown Object (File)
Mon, Apr 7, 7:31 AM
Unknown Object (File)
Mar 1 2025, 4:38 AM
Unknown Object (File)
Feb 28 2025, 6:09 AM
Subscribers

Details

Summary

Attempting to retrieve an md_cval string from a kernel module with
kldxref would throw a offset error for modules created using lld, since
this value would be placed at the end of all allocated sections.

Add an ef_read_seg_string method to the ef interface, to allow reading
strings of varying size without attempting to read beyond the segment's
bounds.

Bugzilla

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

mhorne063_gmail.com edited the summary of this revision. (Show Details)
mhorne063_gmail.com edited the summary of this revision. (Show Details)

Upload diff correctly with tabs and full context

cem added inline comments.
usr.sbin/kldxref/ef.c
516

why would ofs be -1? Other methods don't seem to check for this condition.

517

Why lseek+read instead of ef_read or pread?

527

inconsistent return style -- probably just remove parens

usr.sbin/kldxref/ef_obj.c
312

same as above (s.a.)

316

is this a tab?

usr.sbin/kldxref/ef.c
516

ef_read uses (Elf_Off)-1 to mean "no seek", this keeps the same interface

527

kldxref is already quite inconsistent; I count 47 return ( and 66 return [^(]. IMO it makes sense to follow style(9) when there's this much existing inconsistency.

usr.sbin/kldxref/ef.c
527

That's an ok theory I can get behind, but this patch isn't internally consistent either. See the two returns directly above (0).

usr.sbin/kldxref/ef.c
527

Fair enough, the patch should at least be self-consistent.

usr.sbin/kldxref/ef.c
517

ef_read expects to read a certain length and returns an error if it comes up short, which is what we are working around here. On the other hand, pread seems slightly cleaner for this purpose so I will update it to use that.

usr.sbin/kldxref/ef.c
517

Note that in the earlier patch we accepted (Elf_Off)-1 as "no seek", and that precluded using pread. But we don't need this for strings so Mitchell dropped it.

kib added inline comments.
usr.sbin/kldxref/ef.c
104

I t is tempting to use the chance and switch to designated initializers.

506

No initialization in declarations.

Wny u_long ?

518

Why not return errno there ?

537

Again, why not return (errno) ?

A lot of these comments address issues/inconsistencies already present in the source. I will create a subsequent cleanup patch to address these but follow what is there at the moment for this patch, since @emaste wants this merged to fix the lld build process.

This revision is now accepted and ready to land.Jan 16 2018, 5:59 PM
cem added inline comments.
usr.sbin/kldxref/ef.c
506

Matches existing style of file -- ok for now, IMO.

This revision was automatically updated to reflect the committed changes.