From patchwork Tue Oct 29 20:41:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11218543 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C900714DB for ; Tue, 29 Oct 2019 20:44:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A57A121882 for ; Tue, 29 Oct 2019 20:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572381841; bh=bA1Nt9TWZvija+pWQm/jvZD5pLPHccs35Yz1RfF2GZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=qeZVwfL4Yxi3uYd7OS9V3sYeEHQRUjZHdqdQd62buqCyHhsURSrmMOjhPjQ6Pk1e+ Ku9a0Ze1OvetpxA/ovhKS9rxcmjF8J3Sl49ssXRPN6El0ndpb5OSz3SoV2V0+v4VOg w8QX0D1iKY1wVn7zYyuDjC0sm1Kj46hjctbMyreg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727744AbfJ2Un4 (ORCPT ); Tue, 29 Oct 2019 16:43:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:34740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726636AbfJ2Un4 (ORCPT ); Tue, 29 Oct 2019 16:43:56 -0400 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 27ABC21721; Tue, 29 Oct 2019 20:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572381835; bh=bA1Nt9TWZvija+pWQm/jvZD5pLPHccs35Yz1RfF2GZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rd7PXg6zwRW6AzBcDukG70kVXPnDFY/Yp1M1Yi465IxdRteBn/mWEGk2RcSAX0bx9 zel1es+30DpGpOmI1ko07QXwQLI0WJLYWrVJ486au+twTpg7V/PgIwyKBDURx3jDP4 2oMAidPnxs9Tw9ec8wOtrlajmDWE6C9PK+eKYyUs= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-api@vger.kernel.org, David Howells , Theodore Ts'o , Jaegeuk Kim , Victor Hsieh Subject: [PATCH 1/4] statx: define STATX_ATTR_VERITY Date: Tue, 29 Oct 2019 13:41:38 -0700 Message-Id: <20191029204141.145309-2-ebiggers@kernel.org> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191029204141.145309-1-ebiggers@kernel.org> References: <20191029204141.145309-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org From: Eric Biggers Add a statx attribute bit STATX_ATTR_VERITY which will be set if the file has fs-verity enabled. This is the statx() equivalent of FS_VERITY_FL which is returned by FS_IOC_GETFLAGS. This is useful because it allows applications to check whether a file is a verity file without opening it. Opening a verity file can be expensive because the fsverity_info is set up on open, which involves parsing metadata and optionally verifying a cryptographic signature. This is analogous to how various other bits are exposed through both FS_IOC_GETFLAGS and statx(), e.g. the encrypt bit. Signed-off-by: Eric Biggers Reviewed-by: Andreas Dilger Acked-by: Darrick J. Wong --- include/linux/stat.h | 3 ++- include/uapi/linux/stat.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/stat.h b/include/linux/stat.h index 765573dc17d659..528c4baad09146 100644 --- a/include/linux/stat.h +++ b/include/linux/stat.h @@ -33,7 +33,8 @@ struct kstat { STATX_ATTR_IMMUTABLE | \ STATX_ATTR_APPEND | \ STATX_ATTR_NODUMP | \ - STATX_ATTR_ENCRYPTED \ + STATX_ATTR_ENCRYPTED | \ + STATX_ATTR_VERITY \ )/* Attrs corresponding to FS_*_FL flags */ u64 ino; dev_t dev; diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h index 7b35e98d3c58b1..ad80a5c885d598 100644 --- a/include/uapi/linux/stat.h +++ b/include/uapi/linux/stat.h @@ -167,8 +167,8 @@ struct statx { #define STATX_ATTR_APPEND 0x00000020 /* [I] File is append-only */ #define STATX_ATTR_NODUMP 0x00000040 /* [I] File is not to be dumped */ #define STATX_ATTR_ENCRYPTED 0x00000800 /* [I] File requires key to decrypt in fs */ - #define STATX_ATTR_AUTOMOUNT 0x00001000 /* Dir: Automount trigger */ +#define STATX_ATTR_VERITY 0x00100000 /* [I] Verity protected file */ #endif /* _UAPI_LINUX_STAT_H */ From patchwork Tue Oct 29 20:41:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11218529 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7393414DB for ; Tue, 29 Oct 2019 20:43:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 514472173E for ; Tue, 29 Oct 2019 20:43:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572381837; bh=6uKinpfPcLRaz3evDg6XWZp9GRM69VU/7RKl098ZYrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=REZNEnPaJlj5RYlVhP3w9x2UzVESRfPLOSsHdi2eUH24yiDeJcjPCZI/YnnVM1Szo k+B/vnAYHi6M42bQfQ7B3XVL3bKbEVB90B8JlfD+hJtuHk8k3yzm/6m8Rdt1y3PdLr NnBjoCEVceoRqJuWfUCApEPa3Nt0teBE3Zdadods= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728118AbfJ2Un4 (ORCPT ); Tue, 29 Oct 2019 16:43:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:34752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbfJ2Un4 (ORCPT ); Tue, 29 Oct 2019 16:43:56 -0400 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 928D521479; Tue, 29 Oct 2019 20:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572381835; bh=6uKinpfPcLRaz3evDg6XWZp9GRM69VU/7RKl098ZYrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F1vqZRv2eFon0GtBrubS3F8e3n4v3lX+Jc7jDQg+EZxKCGfEixUVBHBkysbExqltN roBhndZO2TwSgAGdgGQDvkeehTBKaAmzZ3De6S2jApC8pcFCkEdmVptT1PczW0qk0K jbi9gPsqlqJrizoOxtRc9vp5wHXzAHRlP9oxJ79A= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-api@vger.kernel.org, David Howells , Theodore Ts'o , Jaegeuk Kim , Victor Hsieh Subject: [PATCH 2/4] ext4: support STATX_ATTR_VERITY Date: Tue, 29 Oct 2019 13:41:39 -0700 Message-Id: <20191029204141.145309-3-ebiggers@kernel.org> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191029204141.145309-1-ebiggers@kernel.org> References: <20191029204141.145309-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org From: Eric Biggers Set the STATX_ATTR_VERITY bit when the statx() system call is used on a verity file on ext4. Signed-off-by: Eric Biggers Reviewed-by: Andreas Dilger --- fs/ext4/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 516faa280ceda8..a7ca6517798008 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5717,12 +5717,15 @@ int ext4_getattr(const struct path *path, struct kstat *stat, stat->attributes |= STATX_ATTR_IMMUTABLE; if (flags & EXT4_NODUMP_FL) stat->attributes |= STATX_ATTR_NODUMP; + if (flags & EXT4_VERITY_FL) + stat->attributes |= STATX_ATTR_VERITY; stat->attributes_mask |= (STATX_ATTR_APPEND | STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED | STATX_ATTR_IMMUTABLE | - STATX_ATTR_NODUMP); + STATX_ATTR_NODUMP | + STATX_ATTR_VERITY); generic_fillattr(inode, stat); return 0; From patchwork Tue Oct 29 20:41:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11218541 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A5881709 for ; Tue, 29 Oct 2019 20:44:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2EA0218AC for ; Tue, 29 Oct 2019 20:44:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572381841; bh=QJkibpFmPY+L1l0BTOxPJ+ZzOzC9a95hZioeK/4QcCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=gX0UKxTjkJyrQffNlKyZyFXpH9XGxpXeyHFv4xjgSQ94rYIPaTa0cFAAxhX6M752P ACcCRiOhIHk1Rp7M/TQP0ioYYjTjsr8GvijiHQpdXTiIg/O1Z8qlC3ucB0LIYXCjSz eh1dkLOG9AIsODVSaD5IqqEiNHXJZUUcOAGzqfmg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728267AbfJ2Un7 (ORCPT ); Tue, 29 Oct 2019 16:43:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:34776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727518AbfJ2Un4 (ORCPT ); Tue, 29 Oct 2019 16:43:56 -0400 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 05878217D9; Tue, 29 Oct 2019 20:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572381836; bh=QJkibpFmPY+L1l0BTOxPJ+ZzOzC9a95hZioeK/4QcCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BLmEHvRFOhMawxj8dbjPdVj9lV+aMT03HEGnZryulKlISNzap/aO3XJvYfT3EcjCg 7c5nbYz5/ntLx21/L1gFiBGlM9TW4Vxz9Wb37hrufKVX2YRPelOvT2mdzbi15r15h+ 7HuRJZ9V1Cwe2775DkNf1dof2WmVtaUw181Ynp64= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-api@vger.kernel.org, David Howells , Theodore Ts'o , Jaegeuk Kim , Victor Hsieh Subject: [PATCH 3/4] f2fs: support STATX_ATTR_VERITY Date: Tue, 29 Oct 2019 13:41:40 -0700 Message-Id: <20191029204141.145309-4-ebiggers@kernel.org> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191029204141.145309-1-ebiggers@kernel.org> References: <20191029204141.145309-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org From: Eric Biggers Set the STATX_ATTR_VERITY bit when the statx() system call is used on a verity file on f2fs. Signed-off-by: Eric Biggers --- fs/f2fs/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 29bc0a542759a2..6a2e5b7d8fc74c 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -726,11 +726,14 @@ int f2fs_getattr(const struct path *path, struct kstat *stat, stat->attributes |= STATX_ATTR_IMMUTABLE; if (flags & F2FS_NODUMP_FL) stat->attributes |= STATX_ATTR_NODUMP; + if (IS_VERITY(inode)) + stat->attributes |= STATX_ATTR_VERITY; stat->attributes_mask |= (STATX_ATTR_APPEND | STATX_ATTR_ENCRYPTED | STATX_ATTR_IMMUTABLE | - STATX_ATTR_NODUMP); + STATX_ATTR_NODUMP | + STATX_ATTR_VERITY); generic_fillattr(inode, stat); From patchwork Tue Oct 29 20:41:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 11218537 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6910714DB for ; Tue, 29 Oct 2019 20:43:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D18921924 for ; Tue, 29 Oct 2019 20:43:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572381839; bh=p5iqeRBG0wAn8vG31RO8K0J2sdKd+zlwDuiiVCe/arU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=snekW8mmxr+T4I6AeWMbG/9smOdEgIb/jSbxLjJVz6YsUggstcEVOWejVPU6jv3tT 3AuNZFM8BaaatNNJw3lz3CjA7hOWdM/rGSs4XmmTTTGT5a6bH1D1t55S1yxfUZ+DAq QFLx7Mcxf8RyY7CwIteKVRxh4wkUIl/yYILz5nvo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728224AbfJ2Un5 (ORCPT ); Tue, 29 Oct 2019 16:43:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:34752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728156AbfJ2Un5 (ORCPT ); Tue, 29 Oct 2019 16:43:57 -0400 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6F32721835; Tue, 29 Oct 2019 20:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572381836; bh=p5iqeRBG0wAn8vG31RO8K0J2sdKd+zlwDuiiVCe/arU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fqLabC+4M1549VLoHu+fT+YMZrTGGCI6h26q23IVXUV+l623EaOFPGHWTbPJw6rZQ z6+Hb6lOhwnAuiq9iVMCCKczLZk3npUaZaH86ZnpoxrQvfeVOOuYLC9FnrJvJznCMQ fH9S1BHEqrrcJqKGPANaSpjGiCl63Sl7zkWvb3wE= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-api@vger.kernel.org, David Howells , Theodore Ts'o , Jaegeuk Kim , Victor Hsieh Subject: [PATCH 4/4] docs: fs-verity: mention statx() support Date: Tue, 29 Oct 2019 13:41:41 -0700 Message-Id: <20191029204141.145309-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191029204141.145309-1-ebiggers@kernel.org> References: <20191029204141.145309-1-ebiggers@kernel.org> MIME-Version: 1.0 Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org From: Eric Biggers Document that the statx() system call can now be used to check whether a file is a verity file. Signed-off-by: Eric Biggers --- Documentation/filesystems/fsverity.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/filesystems/fsverity.rst b/Documentation/filesystems/fsverity.rst index 42a0b6dd9e0b68..3355377a24398d 100644 --- a/Documentation/filesystems/fsverity.rst +++ b/Documentation/filesystems/fsverity.rst @@ -226,6 +226,14 @@ To do so, check for FS_VERITY_FL (0x00100000) in the returned flags. The verity flag is not settable via FS_IOC_SETFLAGS. You must use FS_IOC_ENABLE_VERITY instead, since parameters must be provided. +statx +----- + +Since Linux v5.5, the statx() system call sets STATX_ATTR_VERITY if +the file has fs-verity enabled. This can perform better than +FS_IOC_GETFLAGS and FS_IOC_MEASURE_VERITY because it doesn't require +opening the file, and opening verity files can be expensive. + Accessing verity files ======================