From nobody Sun Apr 26 17:57:36 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4g3ZD56YXHz6ZhMZ for ; Sun, 26 Apr 2026 17:57:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g3ZD55fyKz3LXm for ; Sun, 26 Apr 2026 17:57:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777226261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0uNDqO8uBCV+JQgSDA6sKuJnyPcSl4FBZy6RTnX/PfI=; b=EsnjZOMmkIp111dlmr3LiqGQ+ijTdlKZdNrePTD9FQiLGZLOMIKjfma/a9jpOqPg6GtgKo cHflL4X96eS8qZXLG8UDSuwkctwH1J0BZA0SebUZHpqii1kMVN7WvrCaYd1e0g8JPyYOs1 oWpjJ2CObKsRF/VbJ6/LVwlDSB4F3b6yKHTZA8vGOteiTEC4B9/oFE4skMVPKKbPlDBaTW QuJ/3mO5o0dcL4EDgicYvTV+hyFdhDCbonz4heHZFTQyritQHR0mcrYBbAQJ4MkeK/Idkl udP0Qw249tdvIXD3TWVux4/1ed2Ys20j/5jzLK6CBor5G7zmtaPFoYGR0cUdKA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1777226261; a=rsa-sha256; cv=none; b=nrV4+pT2RuUa/OqsjkppHNJ9gZCz4ynIEEgyZBJZMqawqXvUIw+UtkYnQERyPdfX8fhcHA 5abnJGFkpuSpYWaMs8YmIIGKF45Kl8yeyMJ6q/IpwMw08oPq7hZmsFiJHr9Rc8JAIFChw0 qcik/G05odxbDv0NfGEYTzYKm0boIA12a+i8IrmbaphoMR0hKhHbS72Ak7E9PY8T65TZ6W ebgojM/ZD4V55+VYkUDCqBPmJbtndBfp2h0BE5P8RRra7SoMoPv5TuseaTHJpKEMrhKaKq gyskheNLlPJacrujEAgsUMSSwUP6NSjNVn0b+tnvzYRiFCYqr+gm2i2m1fJiVg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777226261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0uNDqO8uBCV+JQgSDA6sKuJnyPcSl4FBZy6RTnX/PfI=; b=vvKPvHU6qmO5j4BkHX04c/NlpgV2XVNifjY70dLZPBSK99aQWytcLa1BbR50cg4nplRTIu VIZljZmwpFpaaDqvdntksDJwob3rPlBVvby9CDQ6kAGhFU1Mz8fFXKWX9W4oQxwQzr9SL6 lTp6xYQtZ+D+fIyWYD+YzFn0IrClmb7OLDkSXUIKE5ug+qi9ZwEDYfRb38zCK4QBCuQtqG 2iWLHcSZnPi0kMlogT+IfqDCJ8d7+2b2gwJjBxBFvfmEtZoLoOEe2xAkB3clRTu/8CbHx5 i5xSJKwi6cw+EGuGTq8APUNHX/PUkY+lgPBr+q5eidvzgkkwwiP9bpEribIlAg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g3ZD54ZNHzVsM for ; Sun, 26 Apr 2026 17:57:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1e24a by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 26 Apr 2026 17:57:36 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Ricardo Branco From: Pouria Mousavizadeh Tehrani Subject: git: 4f9f09d95103 - main - compat/linprocfs: Add some entries to /proc/sys/fs and /proc/sys/kernel List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pouria X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4f9f09d95103e1db6b7c75fce7cf3e8c448321e9 Auto-Submitted: auto-generated Date: Sun, 26 Apr 2026 17:57:36 +0000 Message-Id: <69ee5210.1e24a.744ed8ba@gitrepo.freebsd.org> The branch main has been updated by pouria: URL: https://cgit.FreeBSD.org/src/commit/?id=4f9f09d95103e1db6b7c75fce7cf3e8c448321e9 commit 4f9f09d95103e1db6b7c75fce7cf3e8c448321e9 Author: Ricardo Branco AuthorDate: 2026-04-22 20:19:29 +0000 Commit: Pouria Mousavizadeh Tehrani CommitDate: 2026-04-26 17:53:23 +0000 compat/linprocfs: Add some entries to /proc/sys/fs and /proc/sys/kernel Add following sys/fs entries to linprocfs(4): * proc/sys/fs/file-max * proc/sys/fs/file-nr * proc/sys/fs/nr_open * proc/sys/fs/overflowuid * proc/sys/fs/overflowgid * proc/sys/fs/suid_dumpable * proc/sys/fs/protected_hardlinks Also, add /proc/sys/kernel/threads-max Signed-off-by: Ricardo Branco PR: 294713 Reviewed by: markj, pouria Pull-Request: https://github.com/freebsd/freebsd-src/pull/2159 --- sys/compat/linprocfs/linprocfs.c | 150 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 786a486b9143..a0deea73d19c 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -1736,6 +1736,23 @@ linprocfs_dotainted(PFS_FILL_ARGS) return (0); } +/* + * Filler function for proc/sys/kernel/threads-max + */ +static int +linprocfs_dothreads_max(PFS_FILL_ARGS) +{ + int res, error; + size_t size = sizeof(res); + + error = kernel_sysctlbyname(curthread, "kern.maxproc", + &res, &size, NULL, 0, 0, 0); + if (error != 0) + return (error); + sbuf_printf(sb, "%d\n", res); + return (0); +} + /* * Filler function for proc/sys/vm/min_free_kbytes * @@ -2215,6 +2232,122 @@ linprocfs_dosysvipc_shm(PFS_FILL_ARGS) return (0); } +/* + * Filler function for proc/sys/fs/file-max + */ +static int +linprocfs_dofile_max(PFS_FILL_ARGS) +{ + int res, error; + size_t size = sizeof(res); + + error = kernel_sysctlbyname(curthread, "kern.maxfiles", + &res, &size, NULL, 0, 0, 0); + if (error != 0) + return (error); + sbuf_printf(sb, "%d\n", res); + return (0); +} + +/* + * Filler function for proc/sys/fs/file-nr + */ +static int +linprocfs_dofile_nr(PFS_FILL_ARGS) +{ + int openfiles, maxfiles, error; + size_t size; + + size = sizeof(openfiles); + error = kernel_sysctlbyname(curthread, "kern.openfiles", + &openfiles, &size, NULL, 0, 0, 0); + if (error != 0) + return (error); + size = sizeof(maxfiles); + error = kernel_sysctlbyname(curthread, "kern.maxfiles", + &maxfiles, &size, NULL, 0, 0, 0); + if (error != 0) + return (error); + /* + * From Linux's proc_sys_fs(5): + * the "free file handles" value is always zero. + */ + sbuf_printf(sb, "%d\t0\t%d\n", openfiles, maxfiles); + return (0); +} + +/* + * Filler function for proc/sys/fs/nr_open + */ +static int +linprocfs_donr_open(PFS_FILL_ARGS) +{ + int res, error; + size_t size = sizeof(res); + + error = kernel_sysctlbyname(curthread, "kern.maxfilesperproc", + &res, &size, NULL, 0, 0, 0); + if (error != 0) + return (error); + sbuf_printf(sb, "%d\n", res); + return (0); +} + +/* + * Filler function for proc/sys/fs/overflowuid + */ +static int +linprocfs_dooverflowuid(PFS_FILL_ARGS) +{ + sbuf_printf(sb, "%u\n", UID_NOBODY); + return (0); +} + +/* + * Filler function for proc/sys/fs/overflowgid + */ +static int +linprocfs_dooverflowgid(PFS_FILL_ARGS) +{ + sbuf_printf(sb, "%u\n", GID_NOGROUP); + return (0); +} + +/* + * Filler function for proc/sys/fs/suid_dumpable + */ +static int +linprocfs_dosuid_dumpable(PFS_FILL_ARGS) +{ + int res, error; + size_t size = sizeof(res); + + error = kernel_sysctlbyname(curthread, "kern.sugid_coredump", + &res, &size, NULL, 0, 0, 0); + if (error != 0) + return (error); + sbuf_printf(sb, "%d\n", res ? 1 : 0); + return (0); +} + +/* + * Filler function for proc/sys/fs/protected_hardlinks + */ +static int +linprocfs_doprotected_hardlinks(PFS_FILL_ARGS) +{ + int res, error; + size_t size = sizeof(res); + + error = kernel_sysctlbyname(curthread, + "security.bsd.hardlink_check_uid", + &res, &size, NULL, 0, 0, 0); + if (error != 0) + return (error); + sbuf_printf(sb, "%d\n", res ? 1 : 0); + return (0); +} + static int linprocfs_doinotify(const char *sysctl, PFS_FILL_ARGS) { @@ -2499,6 +2632,8 @@ linprocfs_init(PFS_INIT_ARGS) NULL, PFS_RD); pfs_create_file(dir, NULL, "tainted", &linprocfs_dotainted, NULL, NULL, NULL, PFS_RD); + pfs_create_file(dir, NULL, "threads-max", &linprocfs_dothreads_max, + NULL, NULL, NULL, PFS_RD); /* /proc/sys/kernel/random/... */ pfs_create_dir(dir, &dir, "random", NULL, NULL, NULL, 0); @@ -2526,6 +2661,21 @@ linprocfs_init(PFS_INIT_ARGS) /* /proc/sys/fs/... */ pfs_create_dir(sys, &fs, "fs", NULL, NULL, NULL, 0); + pfs_create_file(fs, NULL, "file-nr", &linprocfs_dofile_nr, + NULL, NULL, NULL, PFS_RD); + pfs_create_file(fs, NULL, "file-max", &linprocfs_dofile_max, + NULL, NULL, NULL, PFS_RD); + pfs_create_file(fs, NULL, "nr_open", &linprocfs_donr_open, + NULL, NULL, NULL, PFS_RD); + pfs_create_file(fs, NULL, "overflowgid", &linprocfs_dooverflowgid, + NULL, NULL, NULL, PFS_RD); + pfs_create_file(fs, NULL, "overflowuid", &linprocfs_dooverflowuid, + NULL, NULL, NULL, PFS_RD); + pfs_create_file(fs, NULL, "protected_hardlinks", + &linprocfs_doprotected_hardlinks, NULL, NULL, NULL, PFS_RD); + pfs_create_file(fs, NULL, "suid_dumpable", &linprocfs_dosuid_dumpable, + NULL, NULL, NULL, PFS_RD); + pfs_create_dir(fs, &dir, "inotify", NULL, NULL, NULL, 0); pfs_create_file(dir, NULL, "max_queued_events", &linprocfs_doinotify_max_queued_events, NULL, NULL, NULL, PFS_RDWR);