aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/bpfilter/bpfilter_kern.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/net/bpfilter/bpfilter_kern.c b/net/bpfilter/bpfilter_kern.c
index b13d058f8c34..09522573f611 100644
--- a/net/bpfilter/bpfilter_kern.c
+++ b/net/bpfilter/bpfilter_kern.c
@@ -24,17 +24,19 @@ static void shutdown_umh(struct umh_info *info)
24{ 24{
25 struct task_struct *tsk; 25 struct task_struct *tsk;
26 26
27 if (!info->pid)
28 return;
27 tsk = pid_task(find_vpid(info->pid), PIDTYPE_PID); 29 tsk = pid_task(find_vpid(info->pid), PIDTYPE_PID);
28 if (tsk) 30 if (tsk)
29 force_sig(SIGKILL, tsk); 31 force_sig(SIGKILL, tsk);
30 fput(info->pipe_to_umh); 32 fput(info->pipe_to_umh);
31 fput(info->pipe_from_umh); 33 fput(info->pipe_from_umh);
34 info->pid = 0;
32} 35}
33 36
34static void __stop_umh(void) 37static void __stop_umh(void)
35{ 38{
36 if (IS_ENABLED(CONFIG_INET) && 39 if (IS_ENABLED(CONFIG_INET)) {
37 bpfilter_process_sockopt) {
38 bpfilter_process_sockopt = NULL; 40 bpfilter_process_sockopt = NULL;
39 shutdown_umh(&info); 41 shutdown_umh(&info);
40 } 42 }
@@ -55,7 +57,7 @@ static int __bpfilter_process_sockopt(struct sock *sk, int optname,
55 struct mbox_reply reply; 57 struct mbox_reply reply;
56 loff_t pos; 58 loff_t pos;
57 ssize_t n; 59 ssize_t n;
58 int ret; 60 int ret = -EFAULT;
59 61
60 req.is_set = is_set; 62 req.is_set = is_set;
61 req.pid = current->pid; 63 req.pid = current->pid;
@@ -63,6 +65,8 @@ static int __bpfilter_process_sockopt(struct sock *sk, int optname,
63 req.addr = (long)optval; 65 req.addr = (long)optval;
64 req.len = optlen; 66 req.len = optlen;
65 mutex_lock(&bpfilter_lock); 67 mutex_lock(&bpfilter_lock);
68 if (!info.pid)
69 goto out;
66 n = __kernel_write(info.pipe_to_umh, &req, sizeof(req), &pos); 70 n = __kernel_write(info.pipe_to_umh, &req, sizeof(req), &pos);
67 if (n != sizeof(req)) { 71 if (n != sizeof(req)) {
68 pr_err("write fail %zd\n", n); 72 pr_err("write fail %zd\n", n);