linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steffen Klassert <steffen.klassert@secunet.com>
To: Eric Biggers <ebiggers3@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>,
	syzbot
	<bot+56c7151cad94eec37c521f0e47d2eee53f9361c4@syzkaller.appspotmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	<syzkaller-bugs@googlegroups.com>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	David Miller <davem@davemloft.net>,
	<linux-crypto@vger.kernel.org>
Subject: Re: INFO: task hung in aead_recvmsg
Date: Sat, 30 Dec 2017 09:37:44 +0100	[thread overview]
Message-ID: <20171230083744.vuclnbs677tj7pi2@gauss3.secunet.de> (raw)
In-Reply-To: <20171223202942.GB10162@zzz.localdomain>

On Sat, Dec 23, 2017 at 02:29:42PM -0600, Eric Biggers wrote:
> [+Cc Steffen Klassert <steffen.klassert@secunet.com>]
> 
> 
> I was able to reproduce this by trying to use 'pcrypt' recursively.  I am not
> 100% sure it is the exact same bug, but it probably is.  Here is a C reproducer:
> 
> 	#include <linux/if_alg.h>
> 	#include <sys/socket.h>
> 	#include <unistd.h>
> 
> 	int main()
> 	{
> 		struct sockaddr_alg addr = {
> 			.salg_type = "aead",
> 			.salg_name = "pcrypt(pcrypt(rfc4106-gcm-aesni))",
> 		};
> 		int algfd, reqfd;
> 		char buf[32] = { 0 };
> 
> 		algfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
> 		bind(algfd, (void *)&addr, sizeof(addr));
> 		setsockopt(algfd, SOL_ALG, ALG_SET_KEY, buf, 20);
> 
> 		reqfd = accept(algfd, 0, 0);
> 		write(reqfd, buf, 32);
> 		read(reqfd, buf, 16);
> 	}
> 
> It seems the problem is that all 'pcrypt' instances use the same
> 'padata_instance', which completes works in the order they are submitted.  But
> with nested use, the outer work is submitted before the inner work, so the inner
> work isn't allowed to complete until the outer work does, which deadlocks
> because actually the inner work needs to complete first.
> 
> What a mess.  Maybe there should be a separate 'padata_instance' per pcrypt
> instance?  Or maybe there should be a way for an algorithm to declare that it
> can only appear in the stack one time?  

Having two nested pcrypt templates in one algorithm instance
does not make so much sense in the first place. I thought
that the crypto layer would refuse to build an instance
with two nested templates of the same type.

At least for pcrypt, refusing such instantiations would
be the correct behaviour. Are there any other templates
where a nested use would make sense?

  reply	other threads:[~2017-12-30  8:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <001a1140b8307b0439055ffc7872@google.com>
2017-12-12 16:46 ` INFO: task hung in aead_recvmsg Dmitry Vyukov
2017-12-23 20:29   ` Eric Biggers
2017-12-30  8:37     ` Steffen Klassert [this message]
2018-01-05 21:35       ` Eric Biggers
     [not found]       ` <20180310232231.19191-1-ebiggers3@gmail.com>
     [not found]         ` <20180323002152.GA30497@gondor.apana.org.au>
     [not found]           ` <20180408225528.GH685@sol.localdomain>
     [not found]             ` <20180409085807.2cwvr5cocz6gfbmv@gauss3.secunet.de>
     [not found]               ` <20180409190739.GC203367@gmail.com>
     [not found]                 ` <20180418053533.wuo6bj2okqdu2hrf@gauss3.secunet.de>
2019-02-20  4:06                   ` [RFC PATCH] crypto: pcrypt - forbid recursive instantiation Herbert Xu
2019-02-20 11:42                     ` Steffen Klassert
2019-03-01  3:38                       ` Herbert Xu
2018-07-21 12:37 ` INFO: task hung in aead_recvmsg syzbot
2019-12-01  7:58 ` syzbot
2019-12-01 17:58   ` Stephan Müller
2019-12-01 19:22     ` Eric Biggers

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=20171230083744.vuclnbs677tj7pi2@gauss3.secunet.de \
    --to=steffen.klassert@secunet.com \
    --cc=bot+56c7151cad94eec37c521f0e47d2eee53f9361c4@syzkaller.appspotmail.com \
    --cc=davem@davemloft.net \
    --cc=dvyukov@google.com \
    --cc=ebiggers3@gmail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=syzkaller-bugs@googlegroups.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;
as well as URLs for NNTP newsgroup(s).