Page MenuHomeFreeBSD

struct kinfo_file changes needed for lsof to work using only usermode APIs
ClosedPublic

Authored by damjan.jov_gmail.com on Feb 6 2022, 12:03 PM.
Referenced Files
Unknown Object (File)
Wed, Apr 24, 8:04 PM
Unknown Object (File)
Mon, Apr 22, 5:15 AM
Unknown Object (File)
Mon, Apr 15, 9:05 PM
Unknown Object (File)
Feb 1 2024, 5:55 PM
Unknown Object (File)
Jan 27 2024, 4:23 AM
Unknown Object (File)
Jan 14 2024, 8:28 AM
Unknown Object (File)
Jan 13 2024, 6:49 AM
Unknown Object (File)
Jan 10 2024, 3:53 AM

Details

Summary

This is just the kinfo_file related changes from https://reviews.freebsd.org/D34090

  • Add kf_pipe_buffer_[in/out/size] fields to kf_pipe, and populate them.
  • Add a kf_kqueue struct to the kf_un union, to allow querying kqueue state, and populate it.
  • Populate the kf_sock_rcv_sb_state and kf_sock_snd_sb_state fields in kf_sock for INET/INET6 sockets, and populate all other fields for all transport layer protocols, not just TCP.

Bump __FreeBSD_version to 1400052.

Test Plan

Build lsof from https://github.com/lsof-org/lsof/pull/184 and verify output before and after. Especially compare kqueue info, pipes and sockets.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Also:

  • Add a kf_eventfd_addr field to kf_eventfd and populate it.
This revision is now accepted and ready to land.Apr 13 2022, 5:14 PM

Is this still relevant?
D34756 added a more general way to retrieve advisory lock info.

NVM wrong page.

Regardless of the notes I put above, please mail me the git patch with the correct 'Author' metadata.

sys/kern/kern_event.c
2330

What is the point of exporting kqueue kernel address? Do we ever provide this address in any other informational call to userspace?

sys/kern/sys_eventfd.c
344

Same question about the address of eventfd.

se added a subscriber: se.

The patch applied cleanly except for the version update in param.h and the kernel built with this patch and D34323 applied provides the required functionality for ZFS support in lsof-4.85.0.

I still want the answer about use of the kernel addresses for kqueue/eventfd. Generally we try to not introduce new interfaces that directly expose KVA, whatever silly the idea of KASLR is.

In D34184#804474, @kib wrote:

I still want the answer about use of the kernel addresses for kqueue/eventfd. Generally we try to not introduce new interfaces that directly expose KVA, whatever silly the idea of KASLR is.

lsof wants that address and prints it out for many kernel objects. Presumably it acts as a unique identifier, a way to tell when multiple processes have the same kqueue open, and a starting point for further debugging (eg. conditional breakpoint in a kernel debugger).

We already provide such addresses everywhere, xf_file and xf_vnode in xfile, kf_sock_pcb and kf_pipe_addr in kinfo_file, etc.

I will try to handle this.