bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@meta.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Song Liu <song@kernel.org>, bpf <bpf@vger.kernel.org>,
	"fsverity@lists.linux.dev" <fsverity@lists.linux.dev>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@kernel.org>,
	Kernel Team <kernel-team@meta.com>,
	"tytso@mit.edu" <tytso@mit.edu>,
	"roberto.sassu@huaweicloud.com" <roberto.sassu@huaweicloud.com>
Subject: Re: [PATCH bpf-next 2/5] bpf, fsverity: Add kfunc bpf_get_fsverity_digest
Date: Tue, 17 Oct 2023 14:16:18 +0000	[thread overview]
Message-ID: <338D3CA0-2AAA-4F61-A336-3739DE8EE2DB@fb.com> (raw)
In-Reply-To: <20231017054637.GH1907@sol.localdomain>



> On Oct 16, 2023, at 10:46 PM, Eric Biggers <ebiggers@kernel.org> wrote:
> 
> On Mon, Oct 16, 2023 at 10:35:16PM -0700, Song Liu wrote:
>> On Mon, Oct 16, 2023 at 8:12 PM Eric Biggers <ebiggers@kernel.org> wrote:
>>> 
>>> On Mon, Oct 16, 2023 at 01:10:40PM -0700, Song Liu wrote:
>>>> On Sun, Oct 15, 2023 at 12:07 AM Eric Biggers <ebiggers@kernel.org> wrote:
>>>>> 
>>>> [...]
>>>>>> + */
>>>>>> +__bpf_kfunc int bpf_get_fsverity_digest(struct file *file, struct bpf_dynptr_kern *digest_ptr)
>>>>>> +{
>>>>>> +     const struct inode *inode = file_inode(file);
>>>>>> +     struct fsverity_digest *arg = digest_ptr->data;
>>>>> 
>>>>> What alignment is guaranteed here?
>>>> 
>>>> drnptr doesn't not provide alignment guarantee for digest_ptr->data.
>>>> If we need alignment guarantee, we need to add it here.
>>> 
>>> So technically it's wrong to cast it to struct fsverity_digest, then.
>> 
>> We can enforce alignment here. Would __aligned(2) be sufficient?
>> 
> 
> Do you mean something like the following:
> 
> if (!IS_ALIGNED((uintptr_t)digest_ptr->data, __alignof__(*arg)))
> return -EINVAL;

I was thinking about hard-coding the alignment requirement. 
__alignof__ is much better. Thanks for the suggestion!

Song

  reply	other threads:[~2023-10-17 14:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20231013182644.2346458-1-song@kernel.org>
     [not found] ` <20231013182644.2346458-3-song@kernel.org>
2023-10-15  7:07   ` [PATCH bpf-next 2/5] bpf, fsverity: Add kfunc bpf_get_fsverity_digest Eric Biggers
2023-10-16 20:10     ` Song Liu
2023-10-17  3:12       ` Eric Biggers
2023-10-17  5:35         ` Song Liu
2023-10-17  5:46           ` Eric Biggers
2023-10-17 14:16             ` Song Liu [this message]
2023-10-17 19:50   ` Andrii Nakryiko
     [not found] ` <20231013182644.2346458-6-song@kernel.org>
2023-10-17 19:08   ` [PATCH bpf-next 5/5] selftests/bpf: Add test that use fsverity and xattr to sign a file Alexei Starovoitov
2023-10-17 20:36     ` Song Liu
     [not found] ` <20231013182644.2346458-2-song@kernel.org>
2023-10-17 18:58   ` [PATCH bpf-next 1/5] bpf: Add kfunc bpf_get_file_xattr Andrii Nakryiko
2023-10-17 20:31     ` Song Liu
2023-10-17 21:52       ` Andrii Nakryiko
2023-10-17 22:16         ` Song Liu
2023-10-17 22:40           ` Andrii Nakryiko
2023-10-17 22:46             ` Song Liu
2023-10-18  1:42       ` Hou Tao
2023-10-17 19:10   ` Alexei Starovoitov
2023-11-02  1:19     ` KP Singh

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=338D3CA0-2AAA-4F61-A336-3739DE8EE2DB@fb.com \
    --to=songliubraving@meta.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=ebiggers@kernel.org \
    --cc=fsverity@lists.linux.dev \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=roberto.sassu@huaweicloud.com \
    --cc=song@kernel.org \
    --cc=tytso@mit.edu \
    /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;
as well as URLs for NNTP newsgroup(s).