Bug 228432 - [PATCH] sysctl `KERN_PROC_CWD` should return `ENOMEM` when the output buffer isn't big enough
Summary: [PATCH] sysctl `KERN_PROC_CWD` should return `ENOMEM` when the output buffer ...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
Keywords: patch
Depends on:
Reported: 2018-05-23 04:04 UTC by Brennan Vincent
Modified: 2019-08-08 21:19 UTC (History)
2 users (show)

See Also:

patch fixing the issue (401 bytes, patch)
2018-05-23 04:04 UTC, Brennan Vincent
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brennan Vincent 2018-05-23 04:04:53 UTC
Created attachment 193626 [details]
patch fixing the issue

`man 3 sysctl` states: "If the amount of data available is greater than the size of the buffer supplied, the call supplies as much data as fits in the buffer provided and returns with the error code ENOMEM."

This is not true in the case of `KERN_PROC_CWD`, in which case `sysctl` returns 0, indicating success.
Comment 1 Mark Johnston freebsd_committer 2018-05-23 15:27:20 UTC
I think this change is right. Note that export_kinfo_to_sb() is used in other contexts, but in most of them the return value isn't checked anyway.
Comment 2 Mark Johnston freebsd_committer 2018-05-23 15:31:27 UTC
I also meant to point out that we don't seem to have any applications relying on the current behaviour, which seems to have been introduced relatively recently: r249487.
Comment 3 Brennan Vincent 2018-05-23 17:02:54 UTC
This is my first patch to FreeBSD so forgive my ignorance -- what are the next steps? Can you land the change for me Mark? Or do I need to find someone else to review it, and if so who?
Comment 4 Mark Johnston freebsd_committer 2018-05-23 17:08:00 UTC
(In reply to Brennan Vincent from comment #3)
I'll take care of getting it reviewed and committed.
Comment 5 Mark Johnston freebsd_committer 2018-05-29 19:51:21 UTC
Comment 6 Brennan Vincent 2019-07-28 21:11:40 UTC
Ping: Mark, is there any good reason your fix in D15607 never landed?
Comment 7 Mark Johnston freebsd_committer 2019-08-08 21:19:25 UTC
(In reply to Brennan Vincent from comment #6)
I thought I had found some problem with the patch, but didn't have time to revisit it and it slipped from my todo list.  I'll revisit it shortly, apologies for the delay.