[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87lfk3w458.fsf@x220.int.ebiederm.org>
Date: Wed, 01 Jul 2020 12:12:35 -0500
From: ebiederm@...ssion.com (Eric W. Biederman)
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: linux-kernel@...r.kernel.org, David Miller <davem@...emloft.net>,
Greg Kroah-Hartman <greg@...ah.com>,
Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
Kees Cook <keescook@...omium.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Alexei Starovoitov <ast@...nel.org>,
Al Viro <viro@...iv.linux.org.uk>, bpf <bpf@...r.kernel.org>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jakub Kicinski <kuba@...nel.org>,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Gary Lin <GLin@...e.com>, Bruno Meneguele <bmeneg@...hat.com>,
LSM List <linux-security-module@...r.kernel.org>,
Casey Schaufler <casey@...aufler-ca.com>,
Luis Chamberlain <mcgrof@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH v2 00/15] Make the user mode driver code a better citizen
Alexei Starovoitov <alexei.starovoitov@...il.com> writes:
> On Tue, Jun 30, 2020 at 07:29:34AM -0500, Eric W. Biederman wrote:
>>
>> diff --git a/net/bpfilter/bpfilter_kern.c b/net/bpfilter/bpfilter_kern.c
>> index 91474884ddb7..3e1874030daa 100644
>> --- a/net/bpfilter/bpfilter_kern.c
>> +++ b/net/bpfilter/bpfilter_kern.c
>> @@ -19,8 +19,8 @@ static void shutdown_umh(void)
>> struct pid *tgid = info->tgid;
>>
>> if (tgid) {
>> - kill_pid_info(SIGKILL, SEND_SIG_PRIV, tgid);
>> - wait_event(tgid->wait_pidfd, !pid_task(tgid, PIDTYPE_TGID));
>> + kill_pid(tgid, SIGKILL, 1);
>> + wait_event(tgid->wait_pidfd, !pid_has_task(tgid, PIDTYPE_TGID));
>> bpfilter_umh_cleanup(info);
>> }
>> }
>>
>> > And then did:
>> > while true; do iptables -L;rmmod bpfilter; done
>> >
>> > Unfortunately sometimes 'rmmod bpfilter' hangs in wait_event().
>>
>> Hmm. The wake up happens just of tgid->wait_pidfd happens just before
>> release_task is called so there is a race. As it is possible to wake
>> up and then go back to sleep before pid_has_task becomes false.
>>
>> So I think I need a friendly helper that does:
>>
>> bool task_has_exited(struct pid *tgid)
>> {
>> bool exited = false;
>>
>> rcu_read_lock();
>> tsk = pid_task(tgid, PIDTYPE_TGID);
>> exited = !!tsk;
>> if (tsk) {
>> exited = !!tsk->exit_state;
>> out:
>> rcu_unlock();
>> return exited;
>> }
>
> All makes sense to me.
> If I understood the race condition such helper should indeed solve it.
> Are you going to add such patch to your series?
> I'll proceed with my work on top of your series and will ignore this
> race for now, but I think it should be fixed before we land this set
> into multiple trees.
Yes. I am just finishing it up now.
Eric
Powered by blists - more mailing lists