From: David Sterba <dsterba@suse.cz>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Boris Burkov <boris@bur.io>,
linux-fscrypt@vger.kernel.org, linux-btrfs@vger.kernel.org,
kernel-team@fb.com
Subject: Re: [PATCH v3] btrfs: send: add support for fs-verity
Date: Thu, 4 Aug 2022 16:25:11 +0200 [thread overview]
Message-ID: <20220804142511.GO13489@twin.jikos.cz> (raw)
In-Reply-To: <YumLTcHPUL5M8rY8@sol.localdomain>
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.
next prev parent reply other threads:[~2022-08-04 14:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2022-08-03 8:07 ` kernel test robot
2022-08-04 14:27 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220804142511.GO13489@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=boris@bur.io \
--cc=ebiggers@kernel.org \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox