Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp499330ybz; Wed, 22 Apr 2020 02:23:48 -0700 (PDT) X-Google-Smtp-Source: APiQypLKeiHGsQHurPvGHy++tR69qIiFeO5ZlqdHUmIbb7SCZe6F7UYaUSsgdJ/n5ZoLkdCM3/yV X-Received: by 2002:a50:8d4a:: with SMTP id t10mr175821edt.63.1587547428164; Wed, 22 Apr 2020 02:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587547428; cv=none; d=google.com; s=arc-20160816; b=gqH2zn7UQUtS/nC7ye2NCKTe8THKviLWTa/gEpUKY7xDR2V9oy4ZlpurIAIFh+JORf u4BTJZwJXiKA5Ju4AEI7jipVFL8wmzPGbMygULI7PQ8GSOenOVtUnmVh40FnDc3G85h2 YbefSDdUyL4jioAKiBN8sWXu0Mue3F2uHbv/fQTPywnarMRAQRZn1tDvVGn4PNKezMEO CFoCCntG7Klxfu3dszQseqlrHkq3cIQctrY4FbHwM+wAhV+0MPeA2yvfQNebuz/9ErTK R41O3XZxwSsu00ELqtqEtU6WnZXZxaRs4VcznQjVdxpIFDjDg3PPI7eFYmFN35IVeJqY jPug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=LJwNwAXsE+S8zNNlabn/hmZ+oktxf4w2TKCPbz3Xd7Y=; b=nE2PAOCYMZDCb9R8hw0+hbDc4qeAvh3A7kNjRWC5wvLy2IlFKWEQ2LtDK4793K4JuP O/s8589LoYFu6vK8qd4TG8EYeMGR/9KntNipyqdKAuvOyabJUUhOMG3XLVpKkylyqmey ftwjed8RIEwiiQ8HfjwHWuE4Gb1AJQC36lheFg0kSf5aKN2wUu1UgcK81MetmVZ3X0LT jghZyF5jiecZOsMq8//iDx63cDmK256fewfj3jhrhA87ibEigZIO4LMeD2vORa0m5OkR xU3hHgHAEwn+OcZhkKT5PamKIc/SMmjJ8O2O978ujD9224pdSxWNFSlyH6NS3Cf30PsI hnqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FSRMb7oj; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m9si3084228eja.420.2020.04.22.02.23.18; Wed, 22 Apr 2020 02:23:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=FSRMb7oj; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726112AbgDVJWz (ORCPT + 99 others); Wed, 22 Apr 2020 05:22:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725924AbgDVJWz (ORCPT ); Wed, 22 Apr 2020 05:22:55 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6A91C03C1A8; Wed, 22 Apr 2020 02:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=LJwNwAXsE+S8zNNlabn/hmZ+oktxf4w2TKCPbz3Xd7Y=; b=FSRMb7ojsDy+kjVHZOZLeU26Hf 9MCf1WYrctgxy1tuPfJMalhsl6zhO/V1ks4bbCVNwwHNLlr2jh6msWOiiWacT1kQsPEYAu/6kGWMb mMxQ8Zu4i1PrJBW9vFNyMWTpN5Lre4ufCpTj3uRHqN0wC2JGN3FonwPzsLmpEd9Tor932GVd0f33N rktqnNf+kW3RdvUgMu8GryUSirp+X5+Kwz3b2uQLGpT8DPabJ2LUrNxxSYFLzws1vD5KwGPX6T2RG VZJzk7YamFtFdSj9Y/sWS0kGIoyQLjwpuZmX+BuTl3PCVg67Sxts9J/5yjryJJPwe2kEvUDKf+T0o PdTaVhrQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jRBak-0006ab-6i; Wed, 22 Apr 2020 09:22:50 +0000 Date: Wed, 22 Apr 2020 02:22:50 -0700 From: Christoph Hellwig To: Satya Tangirala Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, Barani Muthukumaran , Kuohong Wang , Kim Boojin , Eric Biggers Subject: Re: [PATCH v10 02/12] block: Keyslot Manager for Inline Encryption Message-ID: <20200422092250.GA12290@infradead.org> References: <20200408035654.247908-1-satyat@google.com> <20200408035654.247908-3-satyat@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200408035654.247908-3-satyat@google.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org > +bool blk_ksm_crypto_cfg_supported(struct blk_keyslot_manager *ksm, > + const struct blk_crypto_config *cfg) > +{ > + if (!ksm) > + return false; > + return (ksm->crypto_modes_supported[cfg->crypto_mode] & > + cfg->data_unit_size) && > + (ksm->max_dun_bytes_supported >= cfg->dun_bytes); Nit: why not expand this a bit to be more readable: if (!(ksm->crypto_modes_supported[cfg->crypto_mode] & cfg->data_unit_size)) return false; if (ksm->max_dun_bytes_supported < cfg->dun_bytes) return false; return true; > +int blk_ksm_evict_key(struct blk_keyslot_manager *ksm, > + const struct blk_crypto_key *key) > +{ > + struct blk_ksm_keyslot *slot; > + int err = 0; > + > + blk_ksm_hw_enter(ksm); > + slot = blk_ksm_find_keyslot(ksm, key); > + if (!slot) > + goto out_unlock; > + > + if (atomic_read(&slot->slot_refs) != 0) { > + err = -EBUSY; > + goto out_unlock; > + } This check looks racy.