From: Eric Dumazet <eric.dumazet@gmail.com>
To: Tuong Lien <tuong.t.lien@dektech.com.au>,
davem@davemloft.net, jmaloy@redhat.com, maloy@donjonn.com,
ying.xue@windriver.com, netdev@vger.kernel.org
Cc: tipc-discussion@lists.sourceforge.net
Subject: Re: [net] tipc: fix using smp_processor_id() in preemptible
Date: Mon, 31 Aug 2020 10:14:50 +0200 [thread overview]
Message-ID: <f81eafce-e1d1-bb18-cb70-cfdf45bb2ed0@gmail.com> (raw)
In-Reply-To: <20200829193755.9429-1-tuong.t.lien@dektech.com.au>
On 8/29/20 12:37 PM, Tuong Lien wrote:
> The 'this_cpu_ptr()' is used to obtain the AEAD key' TFM on the current
> CPU for encryption, however the execution can be preemptible since it's
> actually user-space context, so the 'using smp_processor_id() in
> preemptible' has been observed.
>
> We fix the issue by using the 'get/put_cpu_ptr()' API which consists of
> a 'preempt_disable()' instead.
>
> Fixes: fc1b6d6de220 ("tipc: introduce TIPC encryption & authentication")
Have you forgotten ' Reported-by: syzbot+263f8c0d007dc09b2dda@syzkaller.appspotmail.com' ?
> Acked-by: Jon Maloy <jmaloy@redhat.com>
> Signed-off-by: Tuong Lien <tuong.t.lien@dektech.com.au>
> ---
> net/tipc/crypto.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c
> index c38babaa4e57..7c523dc81575 100644
> --- a/net/tipc/crypto.c
> +++ b/net/tipc/crypto.c
> @@ -326,7 +326,8 @@ static void tipc_aead_free(struct rcu_head *rp)
> if (aead->cloned) {
> tipc_aead_put(aead->cloned);
> } else {
> - head = *this_cpu_ptr(aead->tfm_entry);
> + head = *get_cpu_ptr(aead->tfm_entry);
> + put_cpu_ptr(aead->tfm_entry);
Why is this safe ?
I think that this very unusual construct needs a comment, because this is not obvious.
This really looks like an attempt to silence syzbot to me.
> list_for_each_entry_safe(tfm_entry, tmp, &head->list, list) {
> crypto_free_aead(tfm_entry->tfm);
> list_del(&tfm_entry->list);
> @@ -399,10 +400,15 @@ static void tipc_aead_users_set(struct tipc_aead __rcu *aead, int val)
> */
> static struct crypto_aead *tipc_aead_tfm_next(struct tipc_aead *aead)
> {
> - struct tipc_tfm **tfm_entry = this_cpu_ptr(aead->tfm_entry);
> + struct tipc_tfm **tfm_entry;
> + struct crypto_aead *tfm;
>
> + tfm_entry = get_cpu_ptr(aead->tfm_entry);
> *tfm_entry = list_next_entry(*tfm_entry, list);
> - return (*tfm_entry)->tfm;
> + tfm = (*tfm_entry)->tfm;
> + put_cpu_ptr(tfm_entry);
Again, this looks suspicious to me. I can not explain why this would be safe.
> +
> + return tfm;
> }
>
> /**
>
next prev parent reply other threads:[~2020-08-31 8:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-29 19:37 [net] tipc: fix using smp_processor_id() in preemptible Tuong Lien
2020-08-31 2:14 ` David Miller
2020-08-31 8:14 ` Eric Dumazet [this message]
2020-08-31 8:33 ` Tuong Tong Lien
2020-08-31 9:47 ` Eric Dumazet
2020-08-31 10:05 ` Tuong Tong Lien
2020-08-31 12:48 ` Eric Dumazet
2020-09-01 12:18 ` Tuong Tong Lien
2020-09-01 13:15 ` Eric Dumazet
2020-09-01 17:52 ` Tuong Tong Lien
2020-09-02 7:10 ` Eric Dumazet
2020-09-15 10:54 ` Tuong Tong Lien
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=f81eafce-e1d1-bb18-cb70-cfdf45bb2ed0@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=jmaloy@redhat.com \
--cc=maloy@donjonn.com \
--cc=netdev@vger.kernel.org \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=tuong.t.lien@dektech.com.au \
--cc=ying.xue@windriver.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