mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Jiri Slaby <jslaby@suse.cz>
Cc: linux-kernel@vger.kernel.org, Matt Mackall <mpm@selenic.com>,
	linux-crypto@vger.kernel.org
Subject: Re: [PATCH v2] hw_random: core, sleep interruptible in read
Date: Fri, 4 Dec 2015 22:40:48 +0800	[thread overview]
Message-ID: <20151204144048.GA17703@gondor.apana.org.au> (raw)
In-Reply-To: <1448639443-21760-1-git-send-email-jslaby@suse.cz>

On Fri, Nov 27, 2015 at 04:50:43PM +0100, Jiri Slaby wrote:
> hwrng kthread can be waiting via hwrng_fillfn for some data from a rng
> like virtio-rng:
> hwrng           D ffff880093e17798     0   382      2 0x00000000
> ...
> Call Trace:
>  [<ffffffff817339c6>] wait_for_completion_killable+0x96/0x210
>  [<ffffffffa00aa1b7>] virtio_read+0x57/0xf0 [virtio_rng]
>  [<ffffffff814f4a35>] hwrng_fillfn+0x75/0x130
>  [<ffffffff810aa243>] kthread+0xf3/0x110
> 
> And when some user program tries to read the /dev node in this state,
> we get:
> rngd            D ffff880093e17798     0   762      1 0x00000004
> ...
> Call Trace:
>  [<ffffffff817351ac>] mutex_lock_nested+0x15c/0x3e0
>  [<ffffffff814f478e>] rng_dev_read+0x6e/0x240
>  [<ffffffff81231958>] __vfs_read+0x28/0xe0
>  [<ffffffff81232393>] vfs_read+0x83/0x130
> 
> And this is indeed unkillable. So use mutex_lock_interruptible
> instead of mutex_lock in rng_dev_read and exit immediatelly when
> interrupted. And possibly return already read data, if any (as POSIX
> allows).
> 
> v2: use ERESTARTSYS instead of EINTR
> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Matt Mackall <mpm@selenic.com>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Cc: <linux-crypto@vger.kernel.org>

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      reply	other threads:[~2015-12-04 14:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-26 19:56 [PATCH] " Jiri Slaby
2015-11-27 13:06 ` Herbert Xu
2015-11-27 15:40   ` Jiri Slaby
2015-11-27 15:50   ` [PATCH v2] " Jiri Slaby
2015-12-04 14:40     ` Herbert Xu [this message]

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=20151204144048.GA17703@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=jslaby@suse.cz \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.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

all inboxes | Powered by JetHome®