How to find out whether CONFIG_FANOTIFY_ACCESS_PERMISSIONS is enabled?

本小妞迷上赌 提交于 2021-02-07 20:16:53

问题


I want to make use of fanotify(7) and the problem I run into is that on some kernels CONFIG_FANOTIFY_ACCESS_PERMISSIONS does not work, although CONFIG_FANOTIFY is configured.

At the very least I'd like to report this condition.

Now on Debian and Ubuntu I could use the equivalent of grep CONFIG_FANOTIFY_ACCESS_PERMISSIONS /boot/config-$(uname -r) to verify that the feature is available. On some other systems I could use the equivalent of zgrep CONFIG_FANOTIFY_ACCESS_PERMISSIONS /proc/config.gz, but there are probably some more systems that are not covered by these two methods.

Is there a way to figure out in any of the fanotify(7) functions whether or not fanotify permission handling is available on the kernel currently running?

I was thinking of a method similar to the returned ENOSYS when fanotify_mark() is not implemented (fanotify_mark(2)), but could not find anything like that in the documentation.


回答1:


It seems that fanotify_mark() returns EINVAL when FAN_ALL_PERM_EVENTS is passed but CONFIG_FANOTIFY_ACCESS_PERMISSIONS is disabled.

See fs/notify/fanotify/fanotify_user.c in kernel sources:

SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,
                              __u64, mask, int, dfd,
                              const char  __user *, pathname)
{
...

#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
        if (mask & ~(FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_EVENT_ON_CHILD))
#else
        if (mask & ~(FAN_ALL_EVENTS | FAN_EVENT_ON_CHILD))
#endif
                return -EINVAL;


来源:https://stackoverflow.com/questions/34766479/how-to-find-out-whether-config-fanotify-access-permissions-is-enabled

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!