summaryrefslogtreecommitdiff
path: root/net/ipv4/bpfilter
diff options
context:
space:
mode:
authorTaehee Yoo <ap420073@gmail.com>2019-01-08 20:24:34 +0300
committerDavid S. Miller <davem@davemloft.net>2019-01-12 05:05:41 +0300
commit5b4cb650e569db2e6a09d2fa0ef8eb789a0ac5d8 (patch)
tree7ef7c653d79db14d7eec7b445c178255a01e13d8 /net/ipv4/bpfilter
parent73ab1cb2de9e3efe7f818d5453de271e5371df1d (diff)
downloadlinux-5b4cb650e569db2e6a09d2fa0ef8eb789a0ac5d8.tar.xz
net: bpfilter: use cleanup callback to release umh_info
Now, UMH process is killed, do_exit() calls the umh_info->cleanup callback to release members of the umh_info. This patch makes bpfilter_umh's cleanup routine to use the umh_info->cleanup callback. Signed-off-by: Taehee Yoo <ap420073@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/bpfilter')
-rw-r--r--net/ipv4/bpfilter/sockopt.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/net/ipv4/bpfilter/sockopt.c b/net/ipv4/bpfilter/sockopt.c
index 5e04ed25bc0e..c326cfbc0f62 100644
--- a/net/ipv4/bpfilter/sockopt.c
+++ b/net/ipv4/bpfilter/sockopt.c
@@ -1,28 +1,37 @@
// SPDX-License-Identifier: GPL-2.0
+#include <linux/init.h>
+#include <linux/module.h>
#include <linux/uaccess.h>
#include <linux/bpfilter.h>
#include <uapi/linux/bpf.h>
#include <linux/wait.h>
#include <linux/kmod.h>
+#include <linux/fs.h>
+#include <linux/file.h>
-int (*bpfilter_process_sockopt)(struct sock *sk, int optname,
- char __user *optval,
- unsigned int optlen, bool is_set);
-EXPORT_SYMBOL_GPL(bpfilter_process_sockopt);
+struct bpfilter_umh_ops bpfilter_ops;
+EXPORT_SYMBOL_GPL(bpfilter_ops);
+
+static void bpfilter_umh_cleanup(struct umh_info *info)
+{
+ fput(info->pipe_to_umh);
+ fput(info->pipe_from_umh);
+ info->pid = 0;
+}
static int bpfilter_mbox_request(struct sock *sk, int optname,
char __user *optval,
unsigned int optlen, bool is_set)
{
- if (!bpfilter_process_sockopt) {
+ if (!bpfilter_ops.sockopt) {
int err = request_module("bpfilter");
if (err)
return err;
- if (!bpfilter_process_sockopt)
+ if (!bpfilter_ops.sockopt)
return -ECHILD;
}
- return bpfilter_process_sockopt(sk, optname, optval, optlen, is_set);
+ return bpfilter_ops.sockopt(sk, optname, optval, optlen, is_set);
}
int bpfilter_ip_set_sockopt(struct sock *sk, int optname, char __user *optval,
@@ -41,3 +50,13 @@ int bpfilter_ip_get_sockopt(struct sock *sk, int optname, char __user *optval,
return bpfilter_mbox_request(sk, optname, optval, len, false);
}
+
+static int __init bpfilter_sockopt_init(void)
+{
+ bpfilter_ops.info.cmdline = "bpfilter_umh";
+ bpfilter_ops.info.cleanup = &bpfilter_umh_cleanup;
+
+ return 0;
+}
+
+module_init(bpfilter_sockopt_init);