Commit db1f0002 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Andrei Vagin

kdat: Add check for inotify() INOTIFY_IOC_SETNEXTWD cmd

This is a new ioctl, which allows to request next descriptor
allocated by inotify_add_watch().

https://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs.git/commit/?h=for_next&id=e1603b6effe177210701d3d7132d1b68e7bd2c93

The patch checks this cmd is supported by kernel.
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
parent 6dd7eacc
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
#define KERNEL_FS_EVENT_ON_CHILD 0x08000000 #define KERNEL_FS_EVENT_ON_CHILD 0x08000000
#ifndef INOTIFY_IOC_SETNEXTWD
#define INOTIFY_IOC_SETNEXTWD _IOW('I', 0, __s32)
#endif
extern int is_inotify_link(char *link); extern int is_inotify_link(char *link);
extern int is_fanotify_link(char *link); extern int is_fanotify_link(char *link);
extern const struct fdtype_ops inotify_dump_ops; extern const struct fdtype_ops inotify_dump_ops;
......
...@@ -71,6 +71,7 @@ struct kerndat_s { ...@@ -71,6 +71,7 @@ struct kerndat_s {
unsigned int sysctl_nr_open; unsigned int sysctl_nr_open;
unsigned long files_stat_max_files; unsigned long files_stat_max_files;
bool x86_has_ptrace_fpu_xsave_bug; bool x86_has_ptrace_fpu_xsave_bug;
bool has_inotify_setnextwd;
}; };
extern struct kerndat_s kdat; extern struct kerndat_s kdat;
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */ #include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */
#include <sys/prctl.h> #include <sys/prctl.h>
#include <sys/inotify.h>
#include "common/config.h" #include "common/config.h"
#include "int.h" #include "int.h"
...@@ -33,6 +35,7 @@ ...@@ -33,6 +35,7 @@
#include <compel/plugins/std/syscall-codes.h> #include <compel/plugins/std/syscall-codes.h>
#include <compel/compel.h> #include <compel/compel.h>
#include "netfilter.h" #include "netfilter.h"
#include "fsnotify.h"
#include "linux/userfaultfd.h" #include "linux/userfaultfd.h"
#include "prctl.h" #include "prctl.h"
#include "uffd.h" #include "uffd.h"
...@@ -738,6 +741,29 @@ err: ...@@ -738,6 +741,29 @@ err:
return ret; return ret;
} }
int kerndat_has_inotify_setnextwd(void)
{
int ret = 0;
int fd;
fd = inotify_init();
if (fd < 0) {
pr_perror("Can't create inotify");
return -1;
}
if (ioctl(fd, INOTIFY_IOC_SETNEXTWD, 0x10)) {
if (errno != ENOTTY) {
pr_perror("Can't call ioctl");
ret = -1;
}
} else
kdat.has_inotify_setnextwd = true;
close(fd);
return ret;
}
int __attribute__((weak)) kdat_x86_has_ptrace_fpu_xsave_bug(void) int __attribute__((weak)) kdat_x86_has_ptrace_fpu_xsave_bug(void)
{ {
return 0; return 0;
...@@ -1001,6 +1027,8 @@ int kerndat_init(void) ...@@ -1001,6 +1027,8 @@ int kerndat_init(void)
ret = kerndat_nsid(); ret = kerndat_nsid();
if (!ret) if (!ret)
ret = kerndat_x86_has_ptrace_fpu_xsave_bug(); ret = kerndat_x86_has_ptrace_fpu_xsave_bug();
if (!ret)
ret = kerndat_has_inotify_setnextwd();
kerndat_lsm(); kerndat_lsm();
kerndat_mmap_min_addr(); kerndat_mmap_min_addr();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment