MAC: mac_biba, mac_lomac: Fix setting loader tunables

A string loader tunable requires setting the len parameter to a nonzero
value, typically the size of the string, to have the flag CTLFLAG_TUN
work correctly [1] [2].

Without this fix security.mac.{biba,lomac}.trusted_interfaces would
have no effect at all.

[1] 3da1cf1e88f8 Extend the meaning of the CTLFLAG_TUN flag to automatically ...
[2] 6a3287f889b0 Fix regression issue after r267961. Handle special string case ...

Reviewed by:	olce, kib
Fixes:		af3b2549c4ba Pull in r267961 and r267973 again ...
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D48898

(cherry picked from commit 7d4c0fac8c7db9c5741ba98a8b3ce3c43feb1cf4)
This commit is contained in:
Zhenlei Huang 2025-02-09 23:53:29 +08:00 committed by Franco Fichtner
parent 52acf9788a
commit b425fdbd66
2 changed files with 4 additions and 2 deletions

View File

@ -112,7 +112,8 @@ SYSCTL_INT(_security_mac_biba, OID_AUTO, trust_all_interfaces, CTLFLAG_RDTUN,
static char trusted_interfaces[128];
SYSCTL_STRING(_security_mac_biba, OID_AUTO, trusted_interfaces, CTLFLAG_RDTUN,
trusted_interfaces, 0, "Interfaces considered 'trusted' by MAC/Biba");
trusted_interfaces, sizeof(trusted_interfaces),
"Interfaces considered 'trusted' by MAC/Biba");
static int max_compartments = MAC_BIBA_MAX_COMPARTMENTS;
SYSCTL_INT(_security_mac_biba, OID_AUTO, max_compartments, CTLFLAG_RD,

View File

@ -113,7 +113,8 @@ SYSCTL_INT(_security_mac_lomac, OID_AUTO, trust_all_interfaces, CTLFLAG_RDTUN,
static char trusted_interfaces[128];
SYSCTL_STRING(_security_mac_lomac, OID_AUTO, trusted_interfaces, CTLFLAG_RDTUN,
trusted_interfaces, 0, "Interfaces considered 'trusted' by MAC/LOMAC");
trusted_interfaces, sizeof(trusted_interfaces),
"Interfaces considered 'trusted' by MAC/LOMAC");
static int ptys_equal = 0;
SYSCTL_INT(_security_mac_lomac, OID_AUTO, ptys_equal, CTLFLAG_RWTUN,