|
@@ -8,6 +8,7 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/module.h>
|
|
|
|
+#include <linux/syscalls.h>
|
|
#include <linux/skbuff.h>
|
|
#include <linux/skbuff.h>
|
|
#include <linux/filter.h>
|
|
#include <linux/filter.h>
|
|
#include <linux/bpf.h>
|
|
#include <linux/bpf.h>
|
|
@@ -49,6 +50,22 @@ static int __bpf_mt_check_fd(int fd, struct bpf_prog **ret)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int __bpf_mt_check_path(const char *path, struct bpf_prog **ret)
|
|
|
|
+{
|
|
|
|
+ mm_segment_t oldfs = get_fs();
|
|
|
|
+ int retval, fd;
|
|
|
|
+
|
|
|
|
+ set_fs(KERNEL_DS);
|
|
|
|
+ fd = bpf_obj_get_user(path);
|
|
|
|
+ set_fs(oldfs);
|
|
|
|
+ if (fd < 0)
|
|
|
|
+ return fd;
|
|
|
|
+
|
|
|
|
+ retval = __bpf_mt_check_fd(fd, ret);
|
|
|
|
+ sys_close(fd);
|
|
|
|
+ return retval;
|
|
|
|
+}
|
|
|
|
+
|
|
static int bpf_mt_check(const struct xt_mtchk_param *par)
|
|
static int bpf_mt_check(const struct xt_mtchk_param *par)
|
|
{
|
|
{
|
|
struct xt_bpf_info *info = par->matchinfo;
|
|
struct xt_bpf_info *info = par->matchinfo;
|
|
@@ -66,9 +83,10 @@ static int bpf_mt_check_v1(const struct xt_mtchk_param *par)
|
|
return __bpf_mt_check_bytecode(info->bpf_program,
|
|
return __bpf_mt_check_bytecode(info->bpf_program,
|
|
info->bpf_program_num_elem,
|
|
info->bpf_program_num_elem,
|
|
&info->filter);
|
|
&info->filter);
|
|
- else if (info->mode == XT_BPF_MODE_FD_PINNED ||
|
|
|
|
- info->mode == XT_BPF_MODE_FD_ELF)
|
|
|
|
|
|
+ else if (info->mode == XT_BPF_MODE_FD_ELF)
|
|
return __bpf_mt_check_fd(info->fd, &info->filter);
|
|
return __bpf_mt_check_fd(info->fd, &info->filter);
|
|
|
|
+ else if (info->mode == XT_BPF_MODE_PATH_PINNED)
|
|
|
|
+ return __bpf_mt_check_path(info->path, &info->filter);
|
|
else
|
|
else
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|