public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/2] add_key05: Avoid race with key garbage collection
Date: Wed, 08 Apr 2020 15:36:07 +0200	[thread overview]
Message-ID: <87v9mahzgf.fsf@our.domain.is.not.set> (raw)
In-Reply-To: <87k12qyzmq.fsf@our.domain.is.not.set>

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.

-- 
Thank you,
Richard.

  reply	other threads:[~2020-04-08 13:36 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 [this message]
2020-04-09 11:32             ` Jan Stancek
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=87v9mahzgf.fsf@our.domain.is.not.set \
    --to=rpalethorpe@suse.de \
    --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