From: ebiederm@xmission.com (Eric W. Biederman)
To: peterz@infradead.org
Cc: syzbot <syzbot+db9cdf3dd1f64252c6ef@syzkaller.appspotmail.com>,
adobriyan@gmail.com, akpm@linux-foundation.org, avagin@gmail.com,
christian@brauner.io, gladkov.alexey@gmail.com,
keescook@chromium.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com,
walken@google.com, Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Miklos Szeredi <miklos@szeredi.hu>,
jannh@google.com
Subject: Re: possible deadlock in proc_pid_syscall (2)
Date: Mon, 31 Aug 2020 08:52:16 -0500 [thread overview]
Message-ID: <87eenmgbxr.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <20200831074328.GN1362448@hirez.programming.kicks-ass.net> (peterz's message of "Mon, 31 Aug 2020 09:43:28 +0200")
peterz@infradead.org writes:
> On Sun, Aug 30, 2020 at 07:31:39AM -0500, Eric W. Biederman wrote:
>
>> I am thinking that for cases where we want to do significant work it
>> might be better to ask the process to pause at someplace safe (probably
>> get_signal) and then do all of the work when we know nothing is changing
>> in the process.
>>
>> I don't really like the idea of checking and then checking again. We
>> might have to do it but it feels like the model is wrong somewhere.
>>
>> Given that this is tricky to hit in practice, and given that I am
>> already working the general problem of how to sort out the locking I am
>> going to work this with the rest of the thorny issues of in exec. This
>> feels like a case where the proper solution is that we simply need
>> something better than a mutex.
>
> One possible alternative would be something RCU-like, surround the thing
> with get_task_cred() / put_cred() and then have commit_creds() wait for
> the usage of the old creds to drop to 0 before continuing.
>
> (Also, get_cred_rcu() is disgusting for casting away const)
>
> But this could be complete garbage, I'm not much familiar with any of
> thise code.
This looks like an area of code that will take a couple of passes to get
100% right.
Usually changing creds happens atomically, and separately from
everything else so we simply don't care if there a race, Either the old
creds or the new creds are valid.
With exec the situation is trickier as several things in addition to the
cred are changing at the same time. So a lock is needed.
Now that it is separated from the cred_guard_mutex, probably the easiest
solution is to make exec_update_mutex a sleeping reader writer lock.
There are fewer cases that matter as such a lock would only block on
exec (the writer).
I don't understand perf well enough to do much without carefully
studying the code.
Eric
next prev parent reply other threads:[~2020-08-31 13:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-28 4:57 possible deadlock in proc_pid_syscall (2) syzbot
2020-08-28 12:01 ` Eric W. Biederman
2020-08-28 12:37 ` peterz
2020-08-30 12:31 ` Eric W. Biederman
2020-08-31 7:43 ` peterz
2020-08-31 13:52 ` Eric W. Biederman [this message]
2020-09-02 9:57 ` peterz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eenmgbxr.fsf@x220.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=acme@kernel.org \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=avagin@gmail.com \
--cc=christian@brauner.io \
--cc=gladkov.alexey@gmail.com \
--cc=jannh@google.com \
--cc=jolsa@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=miklos@szeredi.hu \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=syzbot+db9cdf3dd1f64252c6ef@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=walken@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox