History log of /netbsd/sys/kern/kern_ksyms.c (Results 1 – 25 of 108)
Revision Date Author Comments
# 50cde1ed 21-Feb-2023 riastradh <riastradh@NetBSD.org>

ksyms(4): Reject negative offsets earlier in lseek.

Avoid arithmetic overflow.

XXX pullup-10


# 08c7045c 15-Jul-2022 mrg <mrg@NetBSD.org>

convert "ksyms: checking <symbol>" into KSYMS_DEBUG over normal DEBUG.


# 813ac315 06-Jul-2022 riastradh <riastradh@NetBSD.org>

uvm(9): fo_mmap caller guarantees positive size.

No functional change intended, just sprinkling assertions to make it
clearer.


# 90f60f29 22-Sep-2021 rin <rin@NetBSD.org>

ksymsmmap: Add missing uao_reference(9) call for ks->ks_uobj.

Fix failure for savecore(8) and subsequent kernel panic, introduced to
kern_ksyms.c rev 1.03, at least for sh3 and alpha.

For sh3 and a

ksymsmmap: Add missing uao_reference(9) call for ks->ks_uobj.

Fix failure for savecore(8) and subsequent kernel panic, introduced to
kern_ksyms.c rev 1.03, at least for sh3 and alpha.

For sh3 and alpha, savecore(8) supports coff and ecoff, respectively, via
libkvm via nlist(3). nlist(3) routines for coff and ecoff use mmap(2) and
munmap(2) for /dev/ksyms.

This munmap(2) decrements reference count for ks->ks_uobj. Unless it is
incremented in ksymsmmap(), ks->ks_uobj will be freed unexpectedly.

show more ...


# cfaa3dc0 11-Sep-2021 riastradh <riastradh@NetBSD.org>

ksyms: Use pserialize(9) for kernel access to ksyms.

This makes it available in interrupt context, e.g. for printing
messages with kernel symbol names for return addresses as drm wants
to do.


# 4f761efa 11-Sep-2021 riastradh <riastradh@NetBSD.org>

ksyms(4): Take a complete snapshot on each open.

- Snapshots are stored in pageable anonymous uvm objects.
- Snapshots are reference-counted so they can be reused across opens.
- Opening /dev/ksyms

ksyms(4): Take a complete snapshot on each open.

- Snapshots are stored in pageable anonymous uvm objects.
- Snapshots are reference-counted so they can be reused across opens.
- Opening /dev/ksyms blocks module unload until snapshot is taken.
- Merely holding /dev/ksyms open does not block module unload.
- /dev/ksyms is now mmappable.

This slightly changes the behaviour of fstat(2) on /dev/ksyms -- it
is a little more useful now! In particular, st_size is the size of
the symbol table. Some other fields which were not very useful to
begin with -- st_dev, st_ino, st_mode, st_nlink, st_*time,
st_blksize, st_blocks -- are now different, and independent of the
file system on which the device node resides.

Discussed in

https://mail-index.netbsd.org/source-changes-d/2021/08/17/msg013425.html

This is option (3), adapted to make the ksyms snapshots pageable,
after options (1) and (2) posed practical problems.

show more ...


# b38c62ba 07-Sep-2021 riastradh <riastradh@NetBSD.org>

Revert "ksyms(4): Simply block unload until last /dev/ksyms close."

This appears to break t_execsnoop -- presumably something goes wrong
with how libdtrace uses ksyms. To investigate.


# 02a044c4 07-Sep-2021 riastradh <riastradh@NetBSD.org>

Revert "ksyms: Use pserialize(9) for kernel access to ksyms."


# 97868cbf 07-Sep-2021 riastradh <riastradh@NetBSD.org>

ksyms: Use pserialize(9) for kernel access to ksyms.

This makes it available in interrupt context, e.g. for printing
messages with kernel symbol names for return addresses as drm wants
to do.


# b815266f 07-Sep-2021 riastradh <riastradh@NetBSD.org>

ksyms(4): Simply block unload until last /dev/ksyms close.

Otherwise, readers may get a garbled snapshot of ksyms (or a crash on
an assertion failure because of the garbled snapshot) if modules are

ksyms(4): Simply block unload until last /dev/ksyms close.

Otherwise, readers may get a garbled snapshot of ksyms (or a crash on
an assertion failure because of the garbled snapshot) if modules are
unloaded while they read.

https://mail-index.netbsd.org/source-changes-d/2021/08/17/msg013425.html

show more ...


# 5714c6e7 18-Jul-2021 mlelstv <mlelstv@NetBSD.org>

skip symbol tables that were unloaded again to avoid EFAULT when reading
ksyms.

also restore TAILQ_FOREACH idiom.


# bcd5f47b 03-Jun-2021 riastradh <riastradh@NetBSD.org>

ksyms(4): Allow multiple concurrent opens of /dev/ksyms.

First one takes a snapshot; others all agree with the snapshot.

Previously this code path was just broken (could fail horribly if
modules we

ksyms(4): Allow multiple concurrent opens of /dev/ksyms.

First one takes a snapshot; others all agree with the snapshot.

Previously this code path was just broken (could fail horribly if
modules were unloaded after one of the opens is closed), so I just
blocked it off in an earlier commit, but that broke crash(8). So
let's continue allowing multiple opens seeing the same snapshot, but
without the horrible bugs.

show more ...


# c11bb998 03-Jun-2021 riastradh <riastradh@NetBSD.org>

ksyms(4): Don't skip symbol tables that are soon to be freed, take 2.

They will not actually be freed until /dev/ksyms is closed, so
continued access to them remains kosher.

The previous change was

ksyms(4): Don't skip symbol tables that are soon to be freed, take 2.

They will not actually be freed until /dev/ksyms is closed, so
continued access to them remains kosher.

The previous change was busted because of an off-by-one error in a
previous previous change's iteration over the symtabs; that error has
since been corrected.

show more ...


# 36fe3549 03-Jun-2021 riastradh <riastradh@NetBSD.org>

ksyms(4): Fix race in ksymsread iteration.

TAILQ_NEXT(ksyms_last_snapshot) might change while we are iterating,
but ksyms_last_snapshot itself cannot, so invert the loop structure.

Discussed with r

ksyms(4): Fix race in ksymsread iteration.

TAILQ_NEXT(ksyms_last_snapshot) might change while we are iterating,
but ksyms_last_snapshot itself cannot, so invert the loop structure.

Discussed with rin@.

show more ...


# df5a4457 02-Jun-2021 rin <rin@NetBSD.org>

Fix regression introduced in rev 1.90:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_ksyms.c#rev1.90

in which the last element of ksyms_symtabs is skipped by mistake.


# 6368673b 02-Jun-2021 riastradh <riastradh@NetBSD.org>

Revert "ksyms(4): Don't skip symbol tables that are soon to be freed."

Apparently the equality kassert this restored doesn't work; to be
analyzed.


# c676e165 01-Jun-2021 riastradh <riastradh@NetBSD.org>

ksyms(4): Don't skip symbol tables that are soon to be freed.

They will not actually be freed until /dev/ksyms is closed, so
continued access to them remains kosher.


# 041ba06f 01-Jun-2021 riastradh <riastradh@NetBSD.org>

ksyms(4): Modify ksyms_symtabs only at IPL_HIGH.

This limits the opportunities for ddb to witness an inconsistent
state of the symbol table list.


# cd2053bc 01-Jun-2021 riastradh <riastradh@NetBSD.org>

ksyms(4): Fix ksymsread synchronization.

Fixes crash on concurrent update and read of /dev/ksyms.

XXX Unclear why we have to skip sd_gone entries here -- it seems like
they should be preserved unti

ksyms(4): Fix ksymsread synchronization.

Fixes crash on concurrent update and read of /dev/ksyms.

XXX Unclear why we have to skip sd_gone entries here -- it seems like
they should be preserved until ksymsclose.

show more ...


# 876ab2bd 23-Sep-2020 simonb <simonb@NetBSD.org>

The current MIPS DDB stacktrace code doesn't work if no symbols are
available, so fall back to old-fashioned unwind code if no symbols.


# e31e1ba6 05-Jan-2020 pgoyette <pgoyette@NetBSD.org>

When reading from /dev/ksyms we need to skip over entries that have
been marked as sd_gone. Otherwise we might try to uiomove() data from
memory that has been unmapped, resulting in EFAULT.

XXX Thi

When reading from /dev/ksyms we need to skip over entries that have
been marked as sd_gone. Otherwise we might try to uiomove() data from
memory that has been unmapped, resulting in EFAULT.

XXX This (along with other pre-existing checks st->sd_gone) is still
racy, but it's an improvement over current code. Ideally we would
make a complete copy of the symbol table when we open /dev/ksyms so
we could ignore any changes that occur.

ad@ says "good enough for now"

XXX Pullup to -9 and -8

show more ...


# 67414f5d 04-Nov-2017 christos <christos@NetBSD.org>

use Elf_Sym ** instead of casting.


# 62592c33 03-Nov-2017 maxv <maxv@NetBSD.org>

Handle absolute relocations coming from the kernel: preserve SHN_ABS in
the kernel and module symbols, and when relocating a symbol that has
SHN_ABS, take its value as-is and don't return an error if

Handle absolute relocations coming from the kernel: preserve SHN_ABS in
the kernel and module symbols, and when relocating a symbol that has
SHN_ABS, take its value as-is and don't return an error if it equals zero.

Sent on tech-kern@.

show more ...


# d91b306d 14-Jun-2017 chs <chs@NetBSD.org>

create an nmap table for module symtabs too.
needed by dtrace.


# 575a7585 07-Jul-2016 msaitoh <msaitoh@NetBSD.org>

KNF. Remove extra spaces. No functional change.


12345