Skip to content

Add a flag to disable kernel module check/load #42

Description

@MarinBernard

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions