Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2710037imm; Fri, 24 Aug 2018 04:07:58 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb2CBPCtOqRpBuKfJ/7116DdOjCqWWlDpTF9l+Cr8CCK26HI6BK7/eZXCL9K8Ono+9dPNcH X-Received: by 2002:a63:9712:: with SMTP id n18-v6mr1266068pge.292.1535108878233; Fri, 24 Aug 2018 04:07:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535108878; cv=none; d=google.com; s=arc-20160816; b=FpnFJNyOPT7hE6LgTDN+IiV1tHNiQbE4I3rkxjkNcQE6y890Kgk2RmS5O5MFjiMrTA eruYTIU+onZZzYxr93uswPohvEOCV0GmiPFHGNytILb1MaT/0xHiXLJvTWrHCI4geuGt rr2jgbIE6a/T9cW/PWOcnN3hVX2D6XYj8kBHBWz486UeIfkVrNP5NTAzVD1wTIKESk/S 4nov1eNiV2JXzpkhSooOPssEuBFVK4NeHGtyGRLg6WMr/Mi04nc/penCkcMl0bDGga4I UOV+nPB1uIQNlfNNAThZoqddfq9R2jg8GUir6VOn1OVTDCcuLlvo635sKVtr4ZM95b5U X/LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=Q7FLyK/tjCFIH5kU+Sn+dBtO7APf7oom/jOvn9ScMts=; b=Q98Mlx9TewYBFnX2SoMtRTn7KjaPkWJ2+UanUIrSnsxRpLcEg/Jqi8JZa9IBgaToyZ B/aSgLszZjTT5WV4kOfPMEEkdRtOZEFi+gFLKOPALRumVEPPH8KK4YztaPWeQAz9oCf4 j8V0dj6TbRe7Ich1Sjbm0qvl7n/7fT6keK7ZqN0m0vBAuJvFXBCjdekItrwfifOd8X5x /QJsY5xspZPdxNHbPIyOAgt6Gw5cnPmIOFAn5NoltefoUI980GsQi67f+Z2GEwkRysgp CuB9sZG8Ntt+WwU2VJMSdJmjiKTfBnXYHPYwFH9mrX2pm4oHD0Wi+upIptE7jhbtgsm0 8QDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q3-v6si4233373plb.102.2018.08.24.04.07.42; Fri, 24 Aug 2018 04:07:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727027AbeHXOkp (ORCPT + 99 others); Fri, 24 Aug 2018 10:40:45 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60752 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726522AbeHXOkp (ORCPT ); Fri, 24 Aug 2018 10:40:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A16B402211D; Fri, 24 Aug 2018 11:06:35 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 85746B27BA; Fri, 24 Aug 2018 11:06:33 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id w7OB6XVs028128; Fri, 24 Aug 2018 07:06:33 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w7OB6WVT028124; Fri, 24 Aug 2018 07:06:33 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Fri, 24 Aug 2018 07:06:32 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Herbert Xu cc: "David S. Miller" , linux-crypto@vger.kernel.org, Mike Snitzer , dm-devel@redhat.com, linux-kernel@vger.kernel.org Subject: Re: Deadlock when using crypto API for block devices In-Reply-To: <20180824021010.hfar7gasp34ddrib@gondor.apana.org.au> Message-ID: References: <20180824021010.hfar7gasp34ddrib@gondor.apana.org.au> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 24 Aug 2018 11:06:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 24 Aug 2018 11:06:35 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mpatocka@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 24 Aug 2018, Herbert Xu wrote: > On Thu, Aug 23, 2018 at 04:39:23PM -0400, Mikulas Patocka wrote: > > > > 1. don't set CRYPTO_TFM_REQ_MAY_SLEEP in dm-crypt > > ================================================= > > If we don't set it, dm-crypt will use GFP_ATOMIC and GFP_ATOMIC may fail. > > The function init_crypt in xts.c handles the failure gracefully - but the > > question is - does the whole crypto code handle allocation failures > > gracefully? If not and if it returns -ENOMEM somewhere, it would result in > > I/O errors and data corruption. > > It is safe to use GFP_ATOMIC. First of the allocation is really > small (less than a page) so it will only fail when the system is > almost completely out of memory. GFP_ATOMIC is used by networking code. If the system is in a situation when packets arrive faster than the swapper is able to swap, it will happen. It does happen during netwoking surge and corrupting the filesystem in tris situation is not acceptable. > Even when it does fail the crypto > operation will still succeed, albeit it will process things at a > smaller granularity so the performance will degrade. A quick search through the crypto code shows that ahash_save_req and seqiv_aead_encrypt return -ENOMEM. Will you fix them? > The sleeping part of that flag is also not an issue because it > only kicks in once per page. As this is going to be less than > or equal to a page it shouldn't matter. > > > 3. introduce new flag CRYPTO_TFM_REQ_MAY_SLEEP_NOIO > > =================================================== > > Would you like to introduce it? > > For now I don't think this is necessary given that this allocation > and similar ones in lrw and other places in the crypto API are just > performance enhancements and unlikely to fail except in very dire > situations. > > But if new problems arise I'm certainly not opposed to this. > > Thanks, > -- > Email: Herbert Xu > Home Page: http://gondor.apana.org.au/~herbert/ > PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt Mikulas