All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] btrfs: send: add support for fs-verity
@ 2022-08-01 18:54 Boris Burkov
  2022-08-02 20:38 ` Eric Biggers
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Boris Burkov @ 2022-08-01 18:54 UTC (permalink / raw)
  To: linux-fscrypt, linux-btrfs, kernel-team

Preserve the fs-verity status of a btrfs file across send/recv.

There is no facility for installing the Merkle tree contents directly on
the receiving filesystem, so we package up the parameters used to enable
verity found in the verity descriptor. This gives the receive side
enough information to properly enable verity again. Note that this means
that receive will have to re-compute the whole Merkle tree, similar to
how compression worked before encoded_write.

Since the file becomes read-only after verity is enabled, it is
important that verity is added to the send stream after any file writes.
Therefore, when we process a verity item, merely note that it happened,
then actually create the command in the send stream during
'finish_inode_if_needed'.

This also creates V3 of the send stream format, without any format
changes besides adding the new commands and attributes.

Signed-off-by: Boris Burkov <boris@bur.io>

--
Changes in v3:
- Fixed build failure when CONFIG_FS_VERITY was not set. This required a
  kludge to avoid a build warning as well.
Changes in v2:
- Allocate 16K with kvmalloc and keep it around till the end of send
  instead of re-allocating on each file with fs-verity.
- Use unsigned literal for bitshift.
---
 fs/btrfs/send.c              | 114 +++++++++++++++++++++++++++++++++++
 fs/btrfs/send.h              |  15 ++++-
 fs/verity/fsverity_private.h |   2 -
 include/linux/fsverity.h     |   3 +
 4 files changed, 129 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index e7671afcee4f..084f19d39218 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -15,6 +15,7 @@
 #include <linux/string.h>
 #include <linux/compat.h>
 #include <linux/crc32c.h>
+#include <linux/fsverity.h>
 
 #include "send.h"
 #include "ctree.h"
@@ -127,6 +128,8 @@ struct send_ctx {
 	bool cur_inode_new_gen;
 	bool cur_inode_deleted;
 	bool ignore_cur_inode;
+	bool cur_inode_needs_verity;
+	void *verity_descriptor;
 
 	u64 send_progress;
 
@@ -624,6 +627,7 @@ static int tlv_put(struct send_ctx *sctx, u16 attr, const void *data, int len)
 		return tlv_put(sctx, attr, &__tmp, sizeof(__tmp));	\
 	}
 
+TLV_PUT_DEFINE_INT(8)
 TLV_PUT_DEFINE_INT(32)
 TLV_PUT_DEFINE_INT(64)
 
@@ -4886,6 +4890,94 @@ static int process_all_new_xattrs(struct send_ctx *sctx)
 	return ret;
 }
 
+#ifdef CONFIG_FS_VERITY
+static int send_verity(struct send_ctx *sctx, struct fs_path *path,
+		       struct fsverity_descriptor *desc)
+{
+	int ret;
+
+	ret = begin_cmd(sctx, BTRFS_SEND_C_ENABLE_VERITY);
+	if (ret < 0)
+		goto out;
+
+	TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path);
+	TLV_PUT_U8(sctx, BTRFS_SEND_A_VERITY_ALGORITHM, desc->hash_algorithm);
+	TLV_PUT_U32(sctx, BTRFS_SEND_A_VERITY_BLOCK_SIZE, 1U << desc->log_blocksize);
+	TLV_PUT(sctx, BTRFS_SEND_A_VERITY_SALT_DATA, desc->salt, desc->salt_size);
+	TLV_PUT(sctx, BTRFS_SEND_A_VERITY_SIG_DATA, desc->signature, (int)desc->sig_size);
+
+	ret = send_cmd(sctx);
+
+tlv_put_failure:
+out:
+	return ret;
+}
+
+static int process_new_verity(struct send_ctx *sctx)
+{
+	int ret = 0;
+	struct btrfs_fs_info *fs_info = sctx->send_root->fs_info;
+	struct inode *inode;
+	struct fs_path *p;
+
+	inode = btrfs_iget(fs_info->sb, sctx->cur_ino, sctx->send_root);
+	if (IS_ERR(inode))
+		return PTR_ERR(inode);
+
+	ret = fs_info->sb->s_vop->get_verity_descriptor(inode, NULL, 0);
+	if (ret < 0)
+		goto iput;
+
+	if (ret > FS_VERITY_MAX_DESCRIPTOR_SIZE) {
+		ret = -EMSGSIZE;
+		goto iput;
+	}
+	if (!sctx->verity_descriptor) {
+		sctx->verity_descriptor = kvmalloc(FS_VERITY_MAX_DESCRIPTOR_SIZE, GFP_KERNEL);
+		if (!sctx->verity_descriptor) {
+			ret = -ENOMEM;
+			goto iput;
+		}
+	}
+
+	ret = fs_info->sb->s_vop->get_verity_descriptor(inode, sctx->verity_descriptor, ret);
+	if (ret < 0)
+		goto iput;
+
+	p = fs_path_alloc();
+	if (!p) {
+		ret = -ENOMEM;
+		goto iput;
+	}
+	ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p);
+	if (ret < 0)
+		goto free_path;
+
+	ret = send_verity(sctx, p, sctx->verity_descriptor);
+	if (ret < 0)
+		goto free_path;
+
+free_path:
+	fs_path_free(p);
+iput:
+	iput(inode);
+	return ret;
+}
+#else
+static int process_new_verity(struct send_ctx *sctx)
+{
+	int ret = 0;
+	struct send_ctx tmp;
+
+	return -EPERM;
+	/* avoid unused TLV_PUT_U8 build warning without CONFIG_FS_VERITY */
+	TLV_PUT_U8(&tmp, 0, 0);
+tlv_put_failure:
+	return -EPERM;
+}
+#endif
+
+
 static inline u64 max_send_read_size(const struct send_ctx *sctx)
 {
 	return sctx->send_max_size - SZ_16K;
@@ -6377,6 +6469,11 @@ static int finish_inode_if_needed(struct send_ctx *sctx, int at_end)
 		if (ret < 0)
 			goto out;
 	}
+	if (sctx->cur_inode_needs_verity) {
+		ret = process_new_verity(sctx);
+		if (ret < 0)
+			goto out;
+	}
 
 	ret = send_capabilities(sctx);
 	if (ret < 0)
@@ -6785,6 +6882,18 @@ static int changed_extent(struct send_ctx *sctx,
 	return ret;
 }
 
+static int changed_verity(struct send_ctx *sctx,
+			  enum btrfs_compare_tree_result result)
+{
+	int ret = 0;
+
+	if (!sctx->cur_inode_new_gen && !sctx->cur_inode_deleted) {
+		if (result == BTRFS_COMPARE_TREE_NEW)
+			sctx->cur_inode_needs_verity = true;
+	}
+	return ret;
+}
+
 static int dir_changed(struct send_ctx *sctx, u64 dir)
 {
 	u64 orig_gen, new_gen;
@@ -6939,6 +7048,9 @@ static int changed_cb(struct btrfs_path *left_path,
 			ret = changed_xattr(sctx, result);
 		else if (key->type == BTRFS_EXTENT_DATA_KEY)
 			ret = changed_extent(sctx, result);
+		else if (key->type == BTRFS_VERITY_DESC_ITEM_KEY &&
+			 key->offset == 0)
+			ret = changed_verity(sctx, result);
 	}
 
 out:
@@ -8036,6 +8148,8 @@ long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg)
 		kvfree(sctx->clone_roots);
 		kfree(sctx->send_buf_pages);
 		kvfree(sctx->send_buf);
+		if (sctx->verity_descriptor)
+			kvfree(sctx->verity_descriptor);
 
 		name_cache_free(sctx);
 
diff --git a/fs/btrfs/send.h b/fs/btrfs/send.h
index 4bb4e6a638cb..0a4537775e0c 100644
--- a/fs/btrfs/send.h
+++ b/fs/btrfs/send.h
@@ -92,8 +92,11 @@ enum btrfs_send_cmd {
 	BTRFS_SEND_C_ENCODED_WRITE	= 25,
 	BTRFS_SEND_C_MAX_V2		= 25,
 
+	/* Version 3 */
+	BTRFS_SEND_C_ENABLE_VERITY	= 26,
+	BTRFS_SEND_C_MAX_V3		= 26,
 	/* End */
-	BTRFS_SEND_C_MAX		= 25,
+	BTRFS_SEND_C_MAX		= 26,
 };
 
 /* attributes in send stream */
@@ -160,8 +163,14 @@ enum {
 	BTRFS_SEND_A_ENCRYPTION		= 31,
 	BTRFS_SEND_A_MAX_V2		= 31,
 
-	/* End */
-	BTRFS_SEND_A_MAX		= 31,
+	/* Version 3 */
+	BTRFS_SEND_A_VERITY_ALGORITHM	= 32,
+	BTRFS_SEND_A_VERITY_BLOCK_SIZE	= 33,
+	BTRFS_SEND_A_VERITY_SALT_DATA	= 34,
+	BTRFS_SEND_A_VERITY_SIG_DATA	= 35,
+	BTRFS_SEND_A_MAX_V3		= 35,
+
+	__BTRFS_SEND_A_MAX		= 35,
 };
 
 long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg);
diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h
index 629785c95007..dbe1ce5b450a 100644
--- a/fs/verity/fsverity_private.h
+++ b/fs/verity/fsverity_private.h
@@ -70,8 +70,6 @@ struct fsverity_info {
 	const struct inode *inode;
 };
 
-/* Arbitrary limit to bound the kmalloc() size.  Can be changed. */
-#define FS_VERITY_MAX_DESCRIPTOR_SIZE	16384
 
 #define FS_VERITY_MAX_SIGNATURE_SIZE	(FS_VERITY_MAX_DESCRIPTOR_SIZE - \
 					 sizeof(struct fsverity_descriptor))
diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h
index 7af030fa3c36..40f14e5fed9d 100644
--- a/include/linux/fsverity.h
+++ b/include/linux/fsverity.h
@@ -22,6 +22,9 @@
  */
 #define FS_VERITY_MAX_DIGEST_SIZE	SHA512_DIGEST_SIZE
 
+/* Arbitrary limit to bound the kmalloc() size.  Can be changed. */
+#define FS_VERITY_MAX_DESCRIPTOR_SIZE	16384
+
 /* Verity operations for filesystems */
 struct fsverity_operations {
 
-- 
2.37.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] btrfs: send: add support for fs-verity
  2022-08-01 18:54 [PATCH v3] btrfs: send: add support for fs-verity Boris Burkov
@ 2022-08-02 20:38 ` Eric Biggers
  2022-08-04 14:25   ` David Sterba
  2022-08-03  8:07 ` kernel test robot
  2022-08-04 14:27 ` David Sterba
  2 siblings, 1 reply; 6+ messages in thread
From: Eric Biggers @ 2022-08-02 20:38 UTC (permalink / raw)
  To: Boris Burkov; +Cc: linux-fscrypt, linux-btrfs, kernel-team

On Mon, Aug 01, 2022 at 11:54:40AM -0700, Boris Burkov wrote:
> +#ifdef CONFIG_FS_VERITY
> +static int send_verity(struct send_ctx *sctx, struct fs_path *path,
> +		       struct fsverity_descriptor *desc)
> +{
> +	int ret;
> +
> +	ret = begin_cmd(sctx, BTRFS_SEND_C_ENABLE_VERITY);
> +	if (ret < 0)
> +		goto out;
> +
> +	TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path);
> +	TLV_PUT_U8(sctx, BTRFS_SEND_A_VERITY_ALGORITHM, desc->hash_algorithm);
> +	TLV_PUT_U32(sctx, BTRFS_SEND_A_VERITY_BLOCK_SIZE, 1U << desc->log_blocksize);
> +	TLV_PUT(sctx, BTRFS_SEND_A_VERITY_SALT_DATA, desc->salt, desc->salt_size);
> +	TLV_PUT(sctx, BTRFS_SEND_A_VERITY_SIG_DATA, desc->signature, (int)desc->sig_size);

le32_to_cpu(desc->sig_size)

> +
> +	ret = send_cmd(sctx);
> +
> +tlv_put_failure:
> +out:
> +	return ret;
> +}

The 'out' label is unnecessary.

> +
> +static int process_new_verity(struct send_ctx *sctx)

What does "new verity" mean in this context?  The other functions called by
finish_inode_if_needed() have names like send_chown(), send_chmod(), etc., so
this name seems inconsistent (although I'm not familiar with this code).

> +
> +	ret = send_verity(sctx, p, sctx->verity_descriptor);
> +	if (ret < 0)
> +		goto free_path;
> +
> +free_path:
> +	fs_path_free(p);

The goto above is unnecessary.

> +static int process_new_verity(struct send_ctx *sctx)
> +{
> +	int ret = 0;
> +	struct send_ctx tmp;
> +
> +	return -EPERM;
> +	/* avoid unused TLV_PUT_U8 build warning without CONFIG_FS_VERITY */
> +	TLV_PUT_U8(&tmp, 0, 0);
> +tlv_put_failure:
> +	return -EPERM;
> +}
> +#endif

How about adding __maybe_unused to tlv_put_u##bits instead?

> @@ -8036,6 +8148,8 @@ long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg)
>  		kvfree(sctx->clone_roots);
>  		kfree(sctx->send_buf_pages);
>  		kvfree(sctx->send_buf);
> +		if (sctx->verity_descriptor)
> +			kvfree(sctx->verity_descriptor);

There's no need to check for NULL before calling kvfree().

- Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] btrfs: send: add support for fs-verity
  2022-08-01 18:54 [PATCH v3] btrfs: send: add support for fs-verity Boris Burkov
  2022-08-02 20:38 ` Eric Biggers
@ 2022-08-03  8:07 ` kernel test robot
  2022-08-04 14:27 ` David Sterba
  2 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-08-03  8:07 UTC (permalink / raw)
  To: Boris Burkov, linux-fscrypt, linux-btrfs, kernel-team; +Cc: kbuild-all

Hi Boris,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kdave/for-next]
[also build test WARNING on next-20220802]
[cannot apply to fscrypt/fsverity linus/master v5.19]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Boris-Burkov/btrfs-send-add-support-for-fs-verity/20220802-025522
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
config: loongarch-randconfig-s042-20220803 (https://download.01.org/0day-ci/archive/20220803/202208031528.55Suyci3-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/7edb074602581840675f2c1d8fafb6a16f4a1f47
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Boris-Burkov/btrfs-send-add-support-for-fs-verity/20220802-025522
        git checkout 7edb074602581840675f2c1d8fafb6a16f4a1f47
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=loongarch SHELL=/bin/bash fs/btrfs/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

sparse warnings: (new ones prefixed by >>)
>> fs/btrfs/send.c:4907:9: sparse: sparse: cast from restricted __le32
   fs/btrfs/send.c: note: in included file (through include/linux/uaccess.h, include/linux/sched/task.h, include/linux/sched/signal.h, ...):
   arch/loongarch/include/asm/uaccess.h:232:32: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const *from @@     got void const [noderef] __user *from @@
   arch/loongarch/include/asm/uaccess.h:232:32: sparse:     expected void const *from
   arch/loongarch/include/asm/uaccess.h:232:32: sparse:     got void const [noderef] __user *from

vim +4907 fs/btrfs/send.c

  4892	
  4893	#ifdef CONFIG_FS_VERITY
  4894	static int send_verity(struct send_ctx *sctx, struct fs_path *path,
  4895			       struct fsverity_descriptor *desc)
  4896	{
  4897		int ret;
  4898	
  4899		ret = begin_cmd(sctx, BTRFS_SEND_C_ENABLE_VERITY);
  4900		if (ret < 0)
  4901			goto out;
  4902	
  4903		TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path);
  4904		TLV_PUT_U8(sctx, BTRFS_SEND_A_VERITY_ALGORITHM, desc->hash_algorithm);
  4905		TLV_PUT_U32(sctx, BTRFS_SEND_A_VERITY_BLOCK_SIZE, 1U << desc->log_blocksize);
  4906		TLV_PUT(sctx, BTRFS_SEND_A_VERITY_SALT_DATA, desc->salt, desc->salt_size);
> 4907		TLV_PUT(sctx, BTRFS_SEND_A_VERITY_SIG_DATA, desc->signature, (int)desc->sig_size);
  4908	
  4909		ret = send_cmd(sctx);
  4910	
  4911	tlv_put_failure:
  4912	out:
  4913		return ret;
  4914	}
  4915	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] btrfs: send: add support for fs-verity
  2022-08-02 20:38 ` Eric Biggers
@ 2022-08-04 14:25   ` David Sterba
  0 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2022-08-04 14:25 UTC (permalink / raw)
  To: Eric Biggers; +Cc: Boris Burkov, linux-fscrypt, linux-btrfs, kernel-team

On Tue, Aug 02, 2022 at 01:38:37PM -0700, Eric Biggers wrote:
> On Mon, Aug 01, 2022 at 11:54:40AM -0700, Boris Burkov wrote:
> > +#ifdef CONFIG_FS_VERITY
> > +static int send_verity(struct send_ctx *sctx, struct fs_path *path,
> > +		       struct fsverity_descriptor *desc)
> > +{
> > +	int ret;
> > +
> > +	ret = begin_cmd(sctx, BTRFS_SEND_C_ENABLE_VERITY);
> > +	if (ret < 0)
> > +		goto out;
> > +
> > +	TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path);
> > +	TLV_PUT_U8(sctx, BTRFS_SEND_A_VERITY_ALGORITHM, desc->hash_algorithm);
> > +	TLV_PUT_U32(sctx, BTRFS_SEND_A_VERITY_BLOCK_SIZE, 1U << desc->log_blocksize);
> > +	TLV_PUT(sctx, BTRFS_SEND_A_VERITY_SALT_DATA, desc->salt, desc->salt_size);
> > +	TLV_PUT(sctx, BTRFS_SEND_A_VERITY_SIG_DATA, desc->signature, (int)desc->sig_size);
> 
> le32_to_cpu(desc->sig_size)

Don't all the members of desc need the le/cpu helpers? The whole
structure is read from disk directly to the memory buffer, there's no
conversion to a cpu-native order structure, so this must be done when
the members are accessed.

While the first four are of type __u8 so there's no endianness
conversion needed, I'd rather do it for clarity that the structure needs
special handling.

> > +	ret = send_cmd(sctx);
> > +
> > +tlv_put_failure:
> > +out:
> > +	return ret;
> > +}
> 
> The 'out' label is unnecessary.

It's a common pattern in send callbacks to have out: label next to
tlv_put_failure.

> > +static int process_new_verity(struct send_ctx *sctx)
> 
> What does "new verity" mean in this context?  The other functions called by
> finish_inode_if_needed() have names like send_chown(), send_chmod(), etc., so
> this name seems inconsistent (although I'm not familiar with this code).

Yeah I think process_verity or process_verity_desc will be better.

> > +	ret = send_verity(sctx, p, sctx->verity_descriptor);
> > +	if (ret < 0)
> > +		goto free_path;
> > +
> > +free_path:
> > +	fs_path_free(p);
> 
> The goto above is unnecessary.
> 
> > +static int process_new_verity(struct send_ctx *sctx)
> > +{
> > +	int ret = 0;
> > +	struct send_ctx tmp;
> > +
> > +	return -EPERM;
> > +	/* avoid unused TLV_PUT_U8 build warning without CONFIG_FS_VERITY */
> > +	TLV_PUT_U8(&tmp, 0, 0);
> > +tlv_put_failure:
> > +	return -EPERM;
> > +}
> > +#endif
> 
> How about adding __maybe_unused to tlv_put_u##bits instead?

Or it could use U16 or U32 type, it's not strictly necessary to use the
same type width as the in-memory structures.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] btrfs: send: add support for fs-verity
  2022-08-01 18:54 [PATCH v3] btrfs: send: add support for fs-verity Boris Burkov
  2022-08-02 20:38 ` Eric Biggers
  2022-08-03  8:07 ` kernel test robot
@ 2022-08-04 14:27 ` David Sterba
  2 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2022-08-04 14:27 UTC (permalink / raw)
  To: Boris Burkov; +Cc: linux-fscrypt, linux-btrfs, kernel-team

On Mon, Aug 01, 2022 at 11:54:40AM -0700, Boris Burkov wrote:
> +static int process_new_verity(struct send_ctx *sctx)
> +{
> +	int ret = 0;
> +	struct btrfs_fs_info *fs_info = sctx->send_root->fs_info;
> +	struct inode *inode;
> +	struct fs_path *p;
> +
> +	inode = btrfs_iget(fs_info->sb, sctx->cur_ino, sctx->send_root);
> +	if (IS_ERR(inode))
> +		return PTR_ERR(inode);
> +
> +	ret = fs_info->sb->s_vop->get_verity_descriptor(inode, NULL, 0);

This is a long way to call btrfs_get_verity_descriptor from
fs/btrfs/verity.c , is there a reason we can't call it directly?

> +	if (ret < 0)
> +		goto iput;
> +
> +	if (ret > FS_VERITY_MAX_DESCRIPTOR_SIZE) {
> +		ret = -EMSGSIZE;
> +		goto iput;
> +	}
> +	if (!sctx->verity_descriptor) {
> +		sctx->verity_descriptor = kvmalloc(FS_VERITY_MAX_DESCRIPTOR_SIZE, GFP_KERNEL);
> +		if (!sctx->verity_descriptor) {
> +			ret = -ENOMEM;
> +			goto iput;
> +		}
> +	}
> +
> +	ret = fs_info->sb->s_vop->get_verity_descriptor(inode, sctx->verity_descriptor, ret);
> +	if (ret < 0)
> +		goto iput;
> +
> +	p = fs_path_alloc();
> +	if (!p) {
> +		ret = -ENOMEM;
> +		goto iput;
> +	}
> +	ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p);
> +	if (ret < 0)
> +		goto free_path;
> +
> +	ret = send_verity(sctx, p, sctx->verity_descriptor);
> +	if (ret < 0)
> +		goto free_path;
> +
> +free_path:
> +	fs_path_free(p);
> +iput:
> +	iput(inode);
> +	return ret;
> +}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] btrfs: send: add support for fs-verity
@ 2022-08-08  6:10 kernel test robot
  0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-08-08  6:10 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 6086 bytes --]

BCC: lkp(a)intel.com
CC: kbuild-all(a)lists.01.org
In-Reply-To: <7ac3a01572a872f8779f357598215e0e07d191bd.1659379913.git.boris@bur.io>
References: <7ac3a01572a872f8779f357598215e0e07d191bd.1659379913.git.boris(a)bur.io>
TO: Boris Burkov <boris@bur.io>
TO: linux-fscrypt(a)vger.kernel.org
TO: linux-btrfs(a)vger.kernel.org
TO: kernel-team(a)fb.com

Hi Boris,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kdave/for-next]
[also build test WARNING on linus/master next-20220805]
[cannot apply to fscrypt/fsverity v5.19]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Boris-Burkov/btrfs-send-add-support-for-fs-verity/20220802-025522
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
:::::: branch date: 6 days ago
:::::: commit date: 6 days ago
config: x86_64-randconfig-m031-20220801 (https://download.01.org/0day-ci/archive/20220808/202208081452.5uhcUjew-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/nvme/target/tcp.c:1634 nvmet_tcp_alloc_queue() warn: '&queue->queue_list' not removed from list
fs/btrfs/send.c:4974 process_new_verity() warn: ignoring unreachable code.

vim +1634 drivers/nvme/target/tcp.c

872d26a391da92 Sagi Grimberg 2018-12-03  1577  
872d26a391da92 Sagi Grimberg 2018-12-03  1578  static int nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port,
872d26a391da92 Sagi Grimberg 2018-12-03  1579  		struct socket *newsock)
872d26a391da92 Sagi Grimberg 2018-12-03  1580  {
872d26a391da92 Sagi Grimberg 2018-12-03  1581  	struct nvmet_tcp_queue *queue;
872d26a391da92 Sagi Grimberg 2018-12-03  1582  	int ret;
872d26a391da92 Sagi Grimberg 2018-12-03  1583  
872d26a391da92 Sagi Grimberg 2018-12-03  1584  	queue = kzalloc(sizeof(*queue), GFP_KERNEL);
872d26a391da92 Sagi Grimberg 2018-12-03  1585  	if (!queue)
872d26a391da92 Sagi Grimberg 2018-12-03  1586  		return -ENOMEM;
872d26a391da92 Sagi Grimberg 2018-12-03  1587  
872d26a391da92 Sagi Grimberg 2018-12-03  1588  	INIT_WORK(&queue->release_work, nvmet_tcp_release_queue_work);
872d26a391da92 Sagi Grimberg 2018-12-03  1589  	INIT_WORK(&queue->io_work, nvmet_tcp_io_work);
872d26a391da92 Sagi Grimberg 2018-12-03  1590  	queue->sock = newsock;
872d26a391da92 Sagi Grimberg 2018-12-03  1591  	queue->port = port;
872d26a391da92 Sagi Grimberg 2018-12-03  1592  	queue->nr_cmds = 0;
872d26a391da92 Sagi Grimberg 2018-12-03  1593  	spin_lock_init(&queue->state_lock);
872d26a391da92 Sagi Grimberg 2018-12-03  1594  	queue->state = NVMET_TCP_Q_CONNECTING;
872d26a391da92 Sagi Grimberg 2018-12-03  1595  	INIT_LIST_HEAD(&queue->free_list);
872d26a391da92 Sagi Grimberg 2018-12-03  1596  	init_llist_head(&queue->resp_list);
872d26a391da92 Sagi Grimberg 2018-12-03  1597  	INIT_LIST_HEAD(&queue->resp_send_list);
872d26a391da92 Sagi Grimberg 2018-12-03  1598  
44f331a630bdc7 Sagi Grimberg 2022-02-14  1599  	queue->idx = ida_alloc(&nvmet_tcp_queue_ida, GFP_KERNEL);
872d26a391da92 Sagi Grimberg 2018-12-03  1600  	if (queue->idx < 0) {
872d26a391da92 Sagi Grimberg 2018-12-03  1601  		ret = queue->idx;
872d26a391da92 Sagi Grimberg 2018-12-03  1602  		goto out_free_queue;
872d26a391da92 Sagi Grimberg 2018-12-03  1603  	}
872d26a391da92 Sagi Grimberg 2018-12-03  1604  
872d26a391da92 Sagi Grimberg 2018-12-03  1605  	ret = nvmet_tcp_alloc_cmd(queue, &queue->connect);
872d26a391da92 Sagi Grimberg 2018-12-03  1606  	if (ret)
872d26a391da92 Sagi Grimberg 2018-12-03  1607  		goto out_ida_remove;
872d26a391da92 Sagi Grimberg 2018-12-03  1608  
872d26a391da92 Sagi Grimberg 2018-12-03  1609  	ret = nvmet_sq_init(&queue->nvme_sq);
872d26a391da92 Sagi Grimberg 2018-12-03  1610  	if (ret)
872d26a391da92 Sagi Grimberg 2018-12-03  1611  		goto out_free_connect;
872d26a391da92 Sagi Grimberg 2018-12-03  1612  
872d26a391da92 Sagi Grimberg 2018-12-03  1613  	nvmet_prepare_receive_pdu(queue);
872d26a391da92 Sagi Grimberg 2018-12-03  1614  
872d26a391da92 Sagi Grimberg 2018-12-03  1615  	mutex_lock(&nvmet_tcp_queue_mutex);
872d26a391da92 Sagi Grimberg 2018-12-03  1616  	list_add_tail(&queue->queue_list, &nvmet_tcp_queue_list);
872d26a391da92 Sagi Grimberg 2018-12-03  1617  	mutex_unlock(&nvmet_tcp_queue_mutex);
872d26a391da92 Sagi Grimberg 2018-12-03  1618  
872d26a391da92 Sagi Grimberg 2018-12-03  1619  	ret = nvmet_tcp_set_queue_sock(queue);
872d26a391da92 Sagi Grimberg 2018-12-03  1620  	if (ret)
872d26a391da92 Sagi Grimberg 2018-12-03  1621  		goto out_destroy_sq;
872d26a391da92 Sagi Grimberg 2018-12-03  1622  
872d26a391da92 Sagi Grimberg 2018-12-03  1623  	return 0;
872d26a391da92 Sagi Grimberg 2018-12-03  1624  out_destroy_sq:
872d26a391da92 Sagi Grimberg 2018-12-03  1625  	mutex_lock(&nvmet_tcp_queue_mutex);
872d26a391da92 Sagi Grimberg 2018-12-03  1626  	list_del_init(&queue->queue_list);
872d26a391da92 Sagi Grimberg 2018-12-03  1627  	mutex_unlock(&nvmet_tcp_queue_mutex);
872d26a391da92 Sagi Grimberg 2018-12-03  1628  	nvmet_sq_destroy(&queue->nvme_sq);
872d26a391da92 Sagi Grimberg 2018-12-03  1629  out_free_connect:
872d26a391da92 Sagi Grimberg 2018-12-03  1630  	nvmet_tcp_free_cmd(&queue->connect);
872d26a391da92 Sagi Grimberg 2018-12-03  1631  out_ida_remove:
44f331a630bdc7 Sagi Grimberg 2022-02-14  1632  	ida_free(&nvmet_tcp_queue_ida, queue->idx);
872d26a391da92 Sagi Grimberg 2018-12-03  1633  out_free_queue:
872d26a391da92 Sagi Grimberg 2018-12-03 @1634  	kfree(queue);
872d26a391da92 Sagi Grimberg 2018-12-03  1635  	return ret;
872d26a391da92 Sagi Grimberg 2018-12-03  1636  }
872d26a391da92 Sagi Grimberg 2018-12-03  1637  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-08  6:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-01 18:54 [PATCH v3] btrfs: send: add support for fs-verity Boris Burkov
2022-08-02 20:38 ` Eric Biggers
2022-08-04 14:25   ` David Sterba
2022-08-03  8:07 ` kernel test robot
2022-08-04 14:27 ` David Sterba
2022-08-08  6:10 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.