public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/2] add_key05: Avoid race with key garbage collection
Date: Thu, 9 Apr 2020 07:32:06 -0400 (EDT)	[thread overview]
Message-ID: <2007623874.7795838.1586431926226.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <87v9mahzgf.fsf@our.domain.is.not.set>


----- Original Message -----
> Hello,
> 
> Richard Palethorpe <rpalethorpe@suse.de> writes:
> 
> >>> I'm assuming the keys are 'deleted' when the thread keyring is destroyed
> >>> when the child process exits. However they are not freed until later by
> >>> garbage collection (maybe I am confusing deferred freeing with 'garbage
> >>> collection'?).
> >>
> >> Do you know how large is the race window?
> >>
> >> Default /proc/sys/kernel/keys/gc_delay is 300, so if it's tied to this
> >> garbage collect, I'd expect it to fail almost all the time.
> >
> > It doesn't appear to be tied to that.
> >
> >>
> >>> 
> >>> We could explicitly delete/revoke the individual keys, but AFAICT there
> >>> would still be a race because freeing is still asynchronous. Ofcourse
> >>> there might be a reliable way to force freeing?
> >>
> >> gc_delay is only one I recall.
> >>
> >> If it's tied to process being around, I can try similar approach from
> >> e747d0456adc ("syscalls/tgkill03: wait for defunct tid to get detached")
> >> where we wait for /proc/<pid>/task/<tid> to disappear.
> >
> >
> > This might work as the work is scheduled to be done in process context,
> > so the task may remain until the keys have been freed.
> 
> This doesn't seem to work.

We should probably go with your approach for now: create 2 users ahead,
so at least default case works.

I have difficulty reproducing failure on demand.


  reply	other threads:[~2020-04-09 11:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-08  9:06 [LTP] [PATCH 1/2] add_key05: Avoid race with key garbage collection Richard Palethorpe
2020-04-08  9:06 ` [LTP] [PATCH 2/2] add_key05: Correct formatting Richard Palethorpe
2020-04-08  9:19   ` Yang Xu
2020-04-08  9:51 ` [LTP] [PATCH 1/2] add_key05: Avoid race with key garbage collection Yang Xu
2020-04-08 10:19   ` Jan Stancek
2020-04-08 11:01     ` Richard Palethorpe
2020-04-08 11:18       ` Jan Stancek
2020-04-08 11:40         ` Richard Palethorpe
2020-04-08 13:36           ` Richard Palethorpe
2020-04-09 11:32             ` Jan Stancek [this message]
2020-04-08 10:54   ` Richard Palethorpe

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=2007623874.7795838.1586431926226.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.com \
    --cc=ltp@lists.linux.it \
    /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