Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2315012imm; Thu, 23 Aug 2018 19:11:37 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzyiATn4hWuflmKXKOkFp62BoEBLXdq1jRRXmA6TtuJp4n51HCNeY49WXMPcGio5dhn613h X-Received: by 2002:a17:902:32f:: with SMTP id 44-v6mr18897274pld.15.1535076697256; Thu, 23 Aug 2018 19:11:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535076697; cv=none; d=google.com; s=arc-20160816; b=bgYS3sLAyEhHjQ/UK85hRNXIr73YOjJ7qVt2AcF/Ac2qmE2tAHP23tXytgUM3rIjB/ glPP4FNANNOD8zHihLCtttjohFDYjr5zsr3jU+dtX0Uwr9M77n81WLZqkrmGI3hsOqHf sYL+X3wowhEZVJ/9oEMyvmujfQUyfCVos0I2Ysi3eQ+NOctzfOIrHSWbQIHMeyFLA01Y PBhniaZkvCrjCJchxNA/fYG91L2oTksIGTWYsJRrbik6f0hFyaMiFhbEbLI/4Jo0ODmr easjoxT3kSxre13RK8eIRrHQ/dfRt8YNY855F2T7hzU0j9GFTdBZPwxegNzWjqBzTirt DNTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=ZMKdpZaBkDYbMBmoVsUTXJYOLPVaOWnk8p/1Wn6g7OY=; b=EYcCWIXqTS5DeqXRbOrAuxXowXi6bz+HkFBadbhrx3GZO1txMp3sNBs8e2bnG/g71i SjKYUBiOhOMdqVFYjixw06Bz8eZO/6DrUh68JmyzqmHxAqMn2+RZPH9Ny09pFAyWkuYu HottPSVte+iUgoxesbV70m3zB31YweKFbF0NOUoFOQGwlr12jA89nKu1MRv0Bih5Uwlv 43vFsmgQY6bApgR+Ei8Ae+WzDQzDMi5RnB+Hs7E26uGpvZ0xMc3ixq8FLDqnjN+fZIT9 5VijtT2SV8PXzbq1btkear5vLPknT7mkI+lNNj7uTJm6q72YTCpqO+9DM4RkC8ntKw2k drqA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 142-v6si6410510pfy.182.2018.08.23.19.11.21; Thu, 23 Aug 2018 19:11:37 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726752AbeHXFml (ORCPT + 99 others); Fri, 24 Aug 2018 01:42:41 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:45258 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725735AbeHXFml (ORCPT ); Fri, 24 Aug 2018 01:42:41 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1ft1YD-0006Jr-0H; Fri, 24 Aug 2018 10:10:13 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1ft1YA-0000nA-E6; Fri, 24 Aug 2018 10:10:10 +0800 Date: Fri, 24 Aug 2018 10:10:10 +0800 From: Herbert Xu To: Mikulas Patocka 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 Message-ID: <20180824021010.hfar7gasp34ddrib@gondor.apana.org.au> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. 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