Hi,
The pefs userland control program defines the following function to check whether the pefs kernel module is loaded, and load it if needed. In sbin/pefs/pefs_ctl.c:
static void
pefs_kld_load(void)
{
if (modfind(PEFS_KLD) < 0)
if (kld_load(PEFS_KLD) < 0 || modfind(PEFS_KLD) < 0)
errx(PEFS_ERR_SYS,
"cannot find or load \"%s\" kernel module",
PEFS_KLD);
}
This function is called automatically at each invocation of the pefs binary.
I open this issue because this behaviour makes pefs unusable on HardenedBSD systems, whose default kernels are built with the PAX_HARDENING option, which prevents unprivileged users to use the kld(4) interface:
In the HardenedBSD version of sys/kern/priv.c:
int
priv_check_cred(struct ucred *cred, int priv, int flags)
{
/* (...) */
#if !defined(PAX_HARDENING)
/*
* Inspecting kernel module information should be root-only
* when PAX_HARDENING is set.
*/
if (priv == PRIV_KLD_STAT) {
error = 0;
goto out;
}
#endif
/* (...) */
}
As a consequence, regular users can't even use modfind(2) or kldstat(8) to assert module presence, and the pefs command always fails, even if the kernel module was loaded before the invocation.
Making the call to pefs_kld_load() optional would fix this issue and make pefs usable again on HardenedBSD. Would you agree to do this ?
Hi,
The
pefsuserland control program defines the following function to check whether the pefs kernel module is loaded, and load it if needed. Insbin/pefs/pefs_ctl.c:This function is called automatically at each invocation of the
pefsbinary.I open this issue because this behaviour makes
pefsunusable on HardenedBSD systems, whose default kernels are built with the PAX_HARDENING option, which prevents unprivileged users to use thekld(4)interface:In the HardenedBSD version of sys/kern/priv.c:
As a consequence, regular users can't even use
modfind(2)orkldstat(8)to assert module presence, and thepefscommand always fails, even if the kernel module was loaded before the invocation.Making the call to
pefs_kld_load()optional would fix this issue and makepefsusable again on HardenedBSD. Would you agree to do this ?