kldxref: Be more conservative about what we reject.

kldxref anything whose name doesn't end in .ko or that has no dots (eg
the kernel).

Sponsored by:		Netflix
Reviewed by:		jrtc27, jhb
Differential Revision:	https://reviews.freebsd.org/D43507
This commit is contained in:
Warner Losh 2024-01-28 21:45:03 -07:00
parent 34f0a01b6b
commit 2b92b754f1
2 changed files with 10 additions and 11 deletions

View file

@ -50,14 +50,12 @@ file is created, and the preexisting hint file (if there was one in
that directory) is removed.
.Pp
.Nm
ignores files with at least two "."s in the filename, such as
.Pa foo.ko.debug
or
.Pa bar.ko.pkgsave .
Note that this means that modules cannot have names such as
.Pa foo.bar.ko .
This limitation however, has been lived practice since the beginning of
FreeBSD's kernel modules.
only processes files that either have no dots in their name like
.Pa kernel
or that end in
.Dq .ko
like
.Pa foo.ko .
.Pp
The following options are available:
.Bl -tag -width indent

View file

@ -842,10 +842,11 @@ main(int argc, char *argv[])
continue;
/*
* Skip files that generate errors like .debug, .symbol and .pkgsave
* by generally skipping all files with 2 dots.
* by generally skipping all files not ending with ".ko" or that have
* no dots in the name (like kernel).
*/
dot = strchr(p->fts_name, '.');
if (dot && strchr(dot + 1, '.') != NULL)
dot = strrchr(p->fts_name, '.');
if (dot != NULL && strcmp(dot, ".ko") != 0)
continue;
read_kld(p->fts_path, p->fts_name);
}