Re: [PATCH 4/4] add ksm kernel shared memory driver.

Anthony Liguori
2009-03-31T14:37:38Z

Andrea Arcangeli wrote:

>> the ability to disable KSM. That seems like a security concern to me since
>> registering a memory region ought to be an unprivileged action whereas
>> enabling/disabling KSM ought to be a privileged action.
>>
>
> sysfs files would then only be writeable by admin, so if we want to
> allow only admin to start/stop/tune ksm it'd be enough to plug an
> admin capability check in the ioctl to provide equivalent permissions.
>

Caps are not very granular unless you introduce a new capability.
Furthermore, it's a bit more difficult to associate a capability with a
user/group.

With sysfs, you use file based permissions to control the API. It also
fits into things like selinux a lot better.

In the very least, if you insist on not using sysfs, you should have a
separate character device that's used for control (like /dev/ksmctl).

Regards,

Anthony Liguori

> I could imagine converting the enable/pages_to_scan/sleep_time to
> module params and tweaking them through /sys/module/ksm/parameters,
> but for "enable" to work that way, we'd need to intercept the write so
> we can at least weakup the kksmd daemon, which doesn't seem possible
> with /sys/module/ksm/parameters, so in the end if we stick to the
> ioctl for registering regions, it seems simpler to use it for
> start/stop/tune too.
>