Date: Sun, 15 Jul 2018 05:29:40 +0000 (UTC) From: Warner Losh <imp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336302 - head/usr.sbin/kldxref Message-ID: <201807150529.w6F5Te51019341@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: imp Date: Sun Jul 15 05:29:39 2018 New Revision: 336302 URL: https://svnweb.freebsd.org/changeset/base/336302 Log: Use EF_SEG_READ_STRING instead of EF_SEG_READ when reading strings. Normally, we can get away with just reading the 1k buffer for the string, since the placement of the data is generally no where near the end of the file. However, it's possible that the string is within the last 1k of the file, in which case the read will fail, and we'll not produce the proper records needed for devmatch to work. By reading using EF_SEG_READ_STRING, we automatically work around these problems while still retaining safety. This fix a problem with devmatch where we wouldn't load certain modules (like ums). This didn't always happen (my tree didn't exhibit it, while nathan's did because his optimization options were more agressive). Reported by: nathanw@ Modified: head/usr.sbin/kldxref/kldxref.c Modified: head/usr.sbin/kldxref/kldxref.c ============================================================================== --- head/usr.sbin/kldxref/kldxref.c Sun Jul 15 00:47:06 2018 (r336301) +++ head/usr.sbin/kldxref/kldxref.c Sun Jul 15 05:29:39 2018 (r336302) @@ -420,7 +420,7 @@ parse_entry(struct mod_metadata *md, const char *cval, break; case MDT_PNP_INFO: check(EF_SEG_READ_REL(ef, data, sizeof(pnp), &pnp)); - check(EF_SEG_READ(ef, (Elf_Off)pnp.descr, sizeof(descr), descr)); + check(EF_SEG_READ_STRING(ef, (Elf_Off)pnp.descr, sizeof(descr), descr)); descr[sizeof(descr) - 1] = '\0'; if (dflag) { printf(" pnp info for bus %s format %s %d entries of %d bytes\n", @@ -510,7 +510,7 @@ parse_entry(struct mod_metadata *md, const char *cval, ptr = *(char **)(walker + elt->pe_offset); buffer[0] = '\0'; if (ptr != NULL) { - EF_SEG_READ(ef, (Elf_Off)ptr, + EF_SEG_READ_STRING(ef, (Elf_Off)ptr, sizeof(buffer), buffer); buffer[sizeof(buffer) - 1] = '\0'; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807150529.w6F5Te51019341>