Page MenuHomeFreeBSD

ngctl: Check hook name length
ClosedPublic

Authored by des on Feb 12 2026, 12:36 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 13, 10:02 AM
Unknown Object (File)
Mon, Feb 23, 10:50 AM
Unknown Object (File)
Sun, Feb 22, 9:08 PM
Unknown Object (File)
Sat, Feb 21, 12:27 PM
Unknown Object (File)
Sat, Feb 14, 6:27 PM
Unknown Object (File)
Feb 13 2026, 2:38 AM
Unknown Object (File)
Feb 13 2026, 2:05 AM
Unknown Object (File)
Feb 13 2026, 2:05 AM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 70648
Build 67531: arc lint + arc unit

Event Timeline

des requested review of this revision.Feb 12 2026, 12:36 AM
markj added inline comments.
usr.sbin/ngctl/write.c
76

Better would be to write sizeof(sag->sg_data) instead of NG_HOOKSIZ IMO.

78

Might as well explain why it's invalid.

This revision is now accepted and ready to land.Feb 12 2026, 2:36 PM
des marked 2 inline comments as done.Feb 12 2026, 3:52 PM
des added inline comments.
usr.sbin/ngctl/write.c
76

No, because sag->sg_data has the wrong size.

des marked an inline comment as done.

better error message

This revision now requires review to proceed.Feb 12 2026, 3:53 PM
usr.sbin/ngctl/write.c
76

sag->sg_data is defined as char sg_data[32] and NG_HOOKSIZ is 32 as well. What am I missing?

des marked an inline comment as done.Feb 12 2026, 7:00 PM
des added inline comments.
usr.sbin/ngctl/write.c
76

That's a recent change which can't be MFCed. It's also a parallel construction: a hardcoded literal which has been chosen to match to the current value of NG_NODESIZ, but deliberately not NG_NODESIZ itself. And last but not least, I don't feel comfortable assuming that NG_HOOKSIZ is equal to NG_NODESIZ.

des marked an inline comment as done.Feb 12 2026, 7:01 PM
markj added inline comments.
usr.sbin/ngctl/write.c
76

Then you might consider adding something like _Static_assert(NG_HOOKSIZ <= sizeof(sag->sg_data)) or _Static_assert(NG_HOOKSIZ <= sizeof(sagbuf)).

This revision is now accepted and ready to land.Feb 13 2026, 3:25 PM
This revision was automatically updated to reflect the committed changes.