Page MenuHomeFreeBSD

proc: Use more appropriate types for KERN_PROC_VM_LAYOUT
AcceptedPublic

Authored by markj on Jan 20 2022, 4:16 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 2 2024, 4:15 PM
Unknown Object (File)
Dec 23 2023, 1:32 AM
Unknown Object (File)
Dec 12 2023, 6:49 AM
Unknown Object (File)
Nov 23 2023, 7:44 AM
Unknown Object (File)
Nov 14 2023, 8:18 AM
Unknown Object (File)
Aug 29 2023, 1:57 PM
Unknown Object (File)
Jul 8 2023, 7:11 AM
Unknown Object (File)
May 15 2023, 1:32 PM

Details

Reviewers
kib
brooks
jhb
Summary
  • Use kvaddr_t instead of uintptr_t for addresses.
  • Use ksize_t instead of size_t for address range sizes.
  • Widen the map flags field to 64 bits to eliminate implicit padding, and to make it less likely that we'll ever have to add a second flags field.
  • Eliminate 32-bit compat handling, since the above makes it unnecessary.

Reported by: brooks
Fixes: 3ce04aca49e9 ("proc: Add a sysctl to fetch virtual address space layout info")

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 44019
Build 40907: arc lint + arc unit

Event Timeline

markj requested review of this revision.Jan 20 2022, 4:16 PM

Why? I do not get it.
AFAIR when introduced, kvaddr_t was declared as the kernel-side addresses passed to userspace as tokens.
There, the types are anything but kernel addresses.

In D33964#768025, @kib wrote:

Why? I do not get it.

Two reasons from my PoV:

  • no special 32-bit compat support is needed when using fixed-width types
  • the purpose of the sysctl is to export addresses, not pointers, so kvaddr_t is conceptually closer

AFAIR when introduced, kvaddr_t was declared as the kernel-side addresses passed to userspace as tokens.

Hmm, that's indeed mostly how it's used today, but the comment above the kvaddr_t definition claims to be more general than that.

There, the types are anything but kernel addresses.

I don't follow, they are exactly (kernel) addresses.

The k in kvaddr_t is like the k in kinfo.

The intent was to provide an ABI neutral way to export addresses from the kernel avoiding the need for translation. It also ensures that informational addresses returned by the kernel are integers, not potentially provenance-carrying uintptr_t's.

This revision is now accepted and ready to land.Jan 20 2022, 6:51 PM
arichardson added inline comments.
sys/sys/user.h
609

Isn't this also an address, i.e. kvaddr_t?

This revision now requires review to proceed.Jan 20 2022, 9:46 PM
In D33964#768025, @kib wrote:

There, the types are anything but kernel addresses.

I don't follow, they are exactly (kernel) addresses.

They are not kernel addresses, they are user mode addresses.

In D33964#768222, @kib wrote:

I don't follow, they are exactly (kernel) addresses.

They are not kernel addresses, they are user mode addresses.

I understand now, but see Brooks' comment.

In D33964#768222, @kib wrote:

I don't follow, they are exactly (kernel) addresses.

They are not kernel addresses, they are user mode addresses.

I understand now, but see Brooks' comment.

That comment also talks about 'exporting kernel addresses to userspace'. IMO kvaddr_t is a wrong type.

This revision is now accepted and ready to land.Feb 3 2022, 11:52 PM