From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/keyctl02: wait for last key to be garbage collected
Date: Wed, 17 Oct 2018 14:50:47 +0200 [thread overview]
Message-ID: <20181017125047.GA31018@rei> (raw)
In-Reply-To: <8c5e9f341253ee647314805639d3133617283edd.1539779861.git.jstancek@redhat.com>
Hi!
> + /*
> + * Kernel should start garbage collect when last reference to key
> + * is removed (see key_put()). Since we are adding keys with identical
> + * description and type, each replacement should schedule a gc run,
> + * see comment at __key_link().
> + *
> + * We create extra key here, to remove reference to last revoked key.
> + */
> + key_inv = add_key("user", "ltptestkey", "foo", 3,
> + KEY_SPEC_PROCESS_KEYRING);
> + if (key_inv == -1)
> + tst_brk(TBROK | TERRNO, "Failed to add key");
> +#ifdef KEYCTL_INVALIDATE
> + /*
> + * If we have invalidate, we can drop extra key immediately as well,
> + * which also schedules gc.
> + */
> + if (keyctl(KEYCTL_INVALIDATE, key_inv))
> + tst_brk(TBROK | TERRNO, "Failed to invalidate key");
We should probably handle the situation where someone compiles this code
on newer userspace and runs it on older kernel than 3.5, I suppose that
we will get -1 with EINVAL or EOPNOTSUPP here.
And if that is handled we can also drop the ifdef in favor of fallback
definition.
Otherwise this looks good.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2018-10-17 12:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-17 12:40 [LTP] [PATCH] syscalls/keyctl02: wait for last key to be garbage collected Jan Stancek
2018-10-17 12:50 ` Cyril Hrubis [this message]
2018-10-17 13:01 ` Jan Stancek
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=20181017125047.GA31018@rei \
--to=chrubis@suse.cz \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.