Bug 295623 - Wrong type used for pipebuf in login.conf/cap_mkdb/login_class
Summary: Wrong type used for pipebuf in login.conf/cap_mkdb/login_class
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 15.0-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: Dag-Erling Smørgrav
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-05-26 19:31 UTC by Ivan Rozhuk
Modified: 2026-06-08 23:02 UTC (History)
2 users (show)

See Also:
des: mfc-stable15+
des: mfc-stable14+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Rozhuk 2026-05-26 19:31:19 UTC
According to man login.conf pipebuf have SIZE type, but it is interpreted as NUMBER by cap_mkdb and ulimits -a.

So login.conf with:
	:memorylocked=64K:\
	:pipebuf=128M:\
will silently fail to make correct db.

login.conf with:
	:memorylocked=64K:\
	:pipebuf=134217728:\
make correct db.


Please:
1. Set correct type for pipebuf to SIZE in parsers.
2. Fix cap_mkdb to return warnings in case type parse error instead silently set zero.
Comment 1 Ivan Rozhuk 2026-05-26 19:37:02 UTC
ulimit -a show incorrect value:
pipebuf                         (-y)  65536
while it is in kilobytes (:pipebuf=67108864: in login.conf)
Comment 2 Ivan Rozhuk 2026-05-26 19:47:27 UTC
/usr/src/lib/libutil/login_class.c

    { "kqueues",         login_getcapsize, RLIMIT_KQUEUES },
    { "umtxp",           login_getcapnum,  RLIMIT_UMTXP   },
    { "pipebuf",         login_getcapnum,  RLIMIT_PIPEBUF },

kqueues probably should be login_getcapnum since it is FD, and openfiles is NUMBER type.
Comment 3 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2026-05-29 16:06:40 UTC
https://reviews.freebsd.org/D57333

getrlimit(2) describes RLIMIT_PIPEBUF as a size, but it looks like it's actually implemented as a count.
Comment 4 commit-hook freebsd_committer freebsd_triage 2026-05-29 22:07:12 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=b5dce0ae4f78251f56ffcb6c6a58b9e6c20380e0

commit b5dce0ae4f78251f56ffcb6c6a58b9e6c20380e0
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-05-29 22:06:44 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-05-29 22:06:44 +0000

    login_class: Fix kqueues, pipebuf resource types

    * kqueues is a count but is listed as a size

    * pipebuf is a size but is listed as a count

    PR:             295623
    MFC after:      1 week
    Fixes:          a4c04958f526 ("libutil: support RLIMIT_PIPEBUF")
    Fixes:          85a0ddfd0b26 ("Add a resource limit for the total...")
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D57333

 lib/libutil/login_class.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 5 Ivan Rozhuk 2026-05-29 22:14:19 UTC
usr.bin/limits/limits.c also need to be fixed.
Probably some comments need to be added to usr.bin/limits/limits.c and lib/libutil/login_class.c to keep it sync.
Comment 6 commit-hook freebsd_committer freebsd_triage 2026-06-04 14:41:04 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2a0e9a9b5934ced31c90ff5c3231e1599b3b1e75

commit 2a0e9a9b5934ced31c90ff5c3231e1599b3b1e75
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-05-29 22:06:44 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-06-04 14:40:17 +0000

    login_class: Fix kqueues, pipebuf resource types

    * kqueues is a count but is listed as a size

    * pipebuf is a size but is listed as a count

    PR:             295623
    MFC after:      1 week
    Fixes:          a4c04958f526 ("libutil: support RLIMIT_PIPEBUF")
    Fixes:          85a0ddfd0b26 ("Add a resource limit for the total...")
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D57333

    (cherry picked from commit b5dce0ae4f78251f56ffcb6c6a58b9e6c20380e0)

 lib/libutil/login_class.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2026-06-04 14:41:06 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=34fc5ccbc5534290dd874ea4bb50fac428621193

commit 34fc5ccbc5534290dd874ea4bb50fac428621193
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-05-29 22:06:44 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-06-04 14:40:29 +0000

    login_class: Fix kqueues, pipebuf resource types

    * kqueues is a count but is listed as a size

    * pipebuf is a size but is listed as a count

    PR:             295623
    MFC after:      1 week
    Fixes:          a4c04958f526 ("libutil: support RLIMIT_PIPEBUF")
    Fixes:          85a0ddfd0b26 ("Add a resource limit for the total...")
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D57333

    (cherry picked from commit b5dce0ae4f78251f56ffcb6c6a58b9e6c20380e0)

 lib/libutil/login_class.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 8 Ivan Rozhuk 2026-06-04 18:58:38 UTC
Thanks!

Do not miss https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295623#c5
usr.bin/limits/limits.c - requires same changes to be in sync.
Comment 9 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2026-06-04 21:06:09 UTC
Reopen since limits(1) also miscategorizes pipebuf as a count
Comment 10 commit-hook freebsd_committer freebsd_triage 2026-06-04 22:42:15 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=ad524568f9fb77e270a22744d81b9cea0a2ab0eb

commit ad524568f9fb77e270a22744d81b9cea0a2ab0eb
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-06-04 22:41:41 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-06-04 22:41:41 +0000

    limits: Fix pipebuf resource type

    * pipebuf is a size but is listed as a count

    PR:             295623
    MFC after:      1 week
    Fixes:          f54f41403d14 ("usr.bin/limits: support RLIMIT_PIPEBUF")
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D57456

 usr.bin/limits/limits.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 11 commit-hook freebsd_committer freebsd_triage 2026-06-08 23:01:54 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f4744e76333deba32bd381549169f2e8b92b163d

commit f4744e76333deba32bd381549169f2e8b92b163d
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-06-04 22:41:41 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-06-08 23:00:42 +0000

    limits: Fix pipebuf resource type

    * pipebuf is a size but is listed as a count

    PR:             295623
    MFC after:      1 week
    Fixes:          f54f41403d14 ("usr.bin/limits: support RLIMIT_PIPEBUF")
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D57456

    (cherry picked from commit ad524568f9fb77e270a22744d81b9cea0a2ab0eb)

 usr.bin/limits/limits.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 12 commit-hook freebsd_committer freebsd_triage 2026-06-08 23:01:56 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d6800be31a1e1e51f8fa34dfb0654402f323d109

commit d6800be31a1e1e51f8fa34dfb0654402f323d109
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-06-04 22:41:41 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-06-08 23:00:53 +0000

    limits: Fix pipebuf resource type

    * pipebuf is a size but is listed as a count

    PR:             295623
    MFC after:      1 week
    Fixes:          f54f41403d14 ("usr.bin/limits: support RLIMIT_PIPEBUF")
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D57456

    (cherry picked from commit ad524568f9fb77e270a22744d81b9cea0a2ab0eb)

 usr.bin/limits/limits.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)