Page MenuHomeFreeBSD

virtual_oss(8): Fix cuse.ko check
Needs ReviewPublic

Authored by fernape on Sat, Sep 12, 6:34 PM.
Tags
None
Referenced Files
F171790880: D59621.id.diff
Sun, Sep 13, 1:28 PM
F171713708: D59621.id186534.diff
Sat, Sep 12, 11:04 PM
F171709745: D59621.diff
Sat, Sep 12, 10:18 PM
Subscribers

Details

Reviewers
obiwac
christos
Group Reviewers
audio
Summary

virtual_oss(8) checks if cuse(3) is loaded. However, kldload(2) ends up calling
kern_kldload that checks permissions first. It is only later on in
linker_load_module that -EEXIST is returned if the module is already loaded.

That means that users that can't load modules, always get a -EPERM error even if
cuse.ko is already loaded and ready to use.

$ kldstat | grep cuse
 2    1 0xffffffff8233a000     c148 cuse.ko
$ virtual_oss
 virtual_oss: Failed to load cuse kernel module: Operation not permitted
$

Change it to check if the kernel module is already loaded and try load it if it
isn't.

In addition move the program's arguments parsing early on because otherwise, a
user can't even access the program's help if cuse.ko is not loaded and the
user doesn't have permissions to do it.

Test Plan

As a regular user with no permissions to load modules run:

virtual_oss -h

An Operation not permitted is shown.

Load cuse(3) as root:

sudo kldload cuse

Run:
virtual_oss
virtual_oss: Failed to load cuse kernel module: Operation not permitted

But the module is loaded and should be used.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 76806
Build 73689: arc lint + arc unit