Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp2004158rdb; Wed, 31 Jan 2024 16:38:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfRBt0FYQPGs4PYsUVLQwgSXjbNaFF3Goy7m2u/gwz2CzyRir/YiZea2f+XSqnMF3PvInE X-Received: by 2002:a17:902:c209:b0:1d8:d3e8:c322 with SMTP id 9-20020a170902c20900b001d8d3e8c322mr5622529pll.0.1706747919077; Wed, 31 Jan 2024 16:38:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706747919; cv=pass; d=google.com; s=arc-20160816; b=GjJ/wUgVOZruvykHElSWGRSraM80/CU/EeGt/1QsBn2JbQukAk/IzbEoQVRQLOBd1Z 4QpYUzvmE6mfQAP4m4vQT70wKSv9CcSzR+BgdGvKg04Lt7r05xUeNir0Y2IqefGIVIdh 1RmQVCNA30E9BsmwiFB3wYbWyDgWn9Iy1daC3nkEfy5oRX4rnjTt4ObKHgYsmeCxiGWc lCXN9QBKKlrIXof319T+95p2nfUzkd19fFmcFj4lLFYk2Fy262HjKSfpiLlc5zC6xLzq 8kuPKlekRc2FHYPx3btZFHqMUjYxTeEU4honiIlrKwd0a7NVMZO0ag/5jarrFwFG1UEm ALOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=ah1RKuhRRRnaXJKeyFjE6ASX3Aql4IiSaABAAELIE4M=; fh=5xkYpdvoGUAl2QQgS3vAMs6488a9rWo8OwMVA15Ndt0=; b=N3a+AUdga7e3n/joy7xAQ/BU/Z0M3jfuQmPzFoUn6SCybX0qmo05c1tberJyTvy76w 1d2wxr2km3gNS8PmXrl/f3WIlyZmIlV0cHPOjv8lBUwfoH2vzt+boSFlw6sMA78opB2B JFvGQl6sqSH8SKRKIIs0I+WqQnG8zzxetUVNVNzk+jQhl3kQAi0xIfKuYXKM4st0/wcp MyKp0vPjMF1v59ZYlgCpyxwNqMGMs51gd5CrtNwBAMjYuO2EdXV/gbIe3JMkIqJgH+XN eoT/f98c7NAKm9cvvlFkoJ4OjoTx13o98firKs4Hk9vxhUDux7sK4DCj6j263+UpKBkz 579Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PZXNDsk9; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-47438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCVapGiY6CQWE2BIo4ZV179UbE7dGV49zeq81Ak9+1UHsqQMxJtSCOOXo+i6Krkn3rVNvFLvy4lGMs8/8BNEzrPwcFfFZotslLhS/AntbQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u2-20020a170902bf4200b001d886195534si10539934pls.441.2024.01.31.16.38.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 16:38:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PZXNDsk9; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-47438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6A4D828966E for ; Thu, 1 Feb 2024 00:38:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ABB42210D; Thu, 1 Feb 2024 00:37:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PZXNDsk9" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 510B41FC4 for ; Thu, 1 Feb 2024 00:37:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706747873; cv=none; b=Eomv+WuZYLZOehQtp/gNa8yLv8APXFdoxt7X2XASj483jUc06HCxgnHrK30Bt39JMtlOIljfYldNF6Ar8Hy6+7HJELGVLUkjLW5PhTLn2KNkNzP0HNAIQnbvOkRvsjv9qKkPWTN/Os2SkmvProruDH6R0ef9IPg7BexUj+XCyJQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706747873; c=relaxed/simple; bh=qr8rACMNs5RIY8f9kv6asHpnLhXEAXtdGkLGoE0MlO4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=G6l7tcsldaizd5/mVf5vGPOP92dJhzrPyeCiPmD422sLSl6/uqJNYo6O21QcFk9f7/XpwrseVlCYyFTVD1iyClqhq76r1fxLg3A5ESIcQbs+dR5fldPvbaLRbpP0pdVkDMcj4/6dn8EyjTfIoUD4t3M6rSW6XkwkOfXgmhuSBVk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PZXNDsk9; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706747871; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ah1RKuhRRRnaXJKeyFjE6ASX3Aql4IiSaABAAELIE4M=; b=PZXNDsk9+1Bu35dZDS550PLN14viR1ntCFnPMAwKT5URh9XW2C7ncCqSSPIWJ88M3HHwFd ZeRmWpXeKe1nKhW3FdQBheBye4w/9R1aTai/O7e9OiVfEmGf+wBJpRd/QOTST4Wmmv1wpl tzwV59TVR9a2PC02YU+dnyqEiXjXDKY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-Yrwu-v3rPWCE82p2J6UpYg-1; Wed, 31 Jan 2024 19:37:47 -0500 X-MC-Unique: Yrwu-v3rPWCE82p2J6UpYg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3FED138005CC; Thu, 1 Feb 2024 00:37:47 +0000 (UTC) Received: from li-a71a4dcc-35d1-11b2-a85c-951838863c8d.ibm.com.com (unknown [10.72.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1874C1C060AF; Thu, 1 Feb 2024 00:37:41 +0000 (UTC) From: xiubli@redhat.com To: linux-fscrypt@vger.kernel.org Cc: ebiggers@kernel.org, tytso@mit.edu, jaegeuk@kernel.org, linux-kernel@vger.kernel.org, idryomov@gmail.com, ceph-devel@vger.kernel.org, jlayton@kernel.org, vshankar@redhat.com, mchangir@redhat.com, Xiubo Li Subject: [PATCH v2] fscrypt: to make sure the inode->i_blkbits is correctly set Date: Thu, 1 Feb 2024 08:35:25 +0800 Message-ID: <20240201003525.1788594-1-xiubli@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 From: Xiubo Li The inode->i_blkbits should be already set before calling fscrypt_get_encryption_info() and it will use this to setup the ci_data_unit_bits later. URL: https://tracker.ceph.com/issues/64035 Signed-off-by: Xiubo Li --- V2: - Fixed the comments suggested by Eric, thanks. fs/crypto/keysetup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c index d71f7c799e79..9a0a40c81bf2 100644 --- a/fs/crypto/keysetup.c +++ b/fs/crypto/keysetup.c @@ -687,7 +687,7 @@ int fscrypt_get_encryption_info(struct inode *inode, bool allow_unsupported) /** * fscrypt_prepare_new_inode() - prepare to create a new inode in a directory * @dir: a possibly-encrypted directory - * @inode: the new inode. ->i_mode must be set already. + * @inode: the new inode. ->i_mode and ->i_blkbits must be set already. * ->i_ino doesn't need to be set yet. * @encrypt_ret: (output) set to %true if the new inode will be encrypted * @@ -717,6 +717,9 @@ int fscrypt_prepare_new_inode(struct inode *dir, struct inode *inode, if (IS_ERR(policy)) return PTR_ERR(policy); + if (WARN_ON_ONCE(inode->i_blkbits == 0)) + return -EINVAL; + if (WARN_ON_ONCE(inode->i_mode == 0)) return -EINVAL; -- 2.43.0