[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <D9E4PE3RTE37.2LU30RI1ZS6XL@bootlin.com>
Date: Wed, 23 Apr 2025 17:38:09 +0200
From: Alexis Lothoré <alexis.lothore@...tlin.com>
To: "Xu Kuohai" <xukuohai@...weicloud.com>, "Andrii Nakryiko"
<andrii.nakryiko@...il.com>
Cc: "Alexei Starovoitov" <ast@...nel.org>, "Daniel Borkmann"
<daniel@...earbox.net>, "John Fastabend" <john.fastabend@...il.com>,
"Andrii Nakryiko" <andrii@...nel.org>, "Martin KaFai Lau"
<martin.lau@...ux.dev>, "Eduard Zingerman" <eddyz87@...il.com>, "Song Liu"
<song@...nel.org>, "Yonghong Song" <yonghong.song@...ux.dev>, "KP Singh"
<kpsingh@...nel.org>, "Stanislav Fomichev" <sdf@...ichev.me>, "Hao Luo"
<haoluo@...gle.com>, "Jiri Olsa" <jolsa@...nel.org>, "Puranjay Mohan"
<puranjay@...nel.org>, "Catalin Marinas" <catalin.marinas@....com>, "Will
Deacon" <will@...nel.org>, "Mykola Lysenko" <mykolal@...com>, "Shuah Khan"
<shuah@...nel.org>, "Maxime Coquelin" <mcoquelin.stm32@...il.com>,
"Alexandre Torgue" <alexandre.torgue@...s.st.com>, "Florent Revest"
<revest@...omium.org>, "Bastien Curutchet" <bastien.curutchet@...tlin.com>,
<ebpf@...uxfoundation.org>, "Thomas Petazzoni"
<thomas.petazzoni@...tlin.com>, <bpf@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>,
<linux-kselftest@...r.kernel.org>,
<linux-stm32@...md-mailman.stormreply.com>
Subject: Re: [PATCH RFC bpf-next 1/4] bpf: add struct largest member size in
func model
On Mon Apr 21, 2025 at 4:14 AM CEST, Xu Kuohai wrote:
> On 4/21/2025 12:02 AM, Alexis Lothoré wrote:
>> Hi Xu,
>>
>> On Thu Apr 17, 2025 at 4:10 PM CEST, Xu Kuohai wrote:
>>> On 4/17/2025 3:14 PM, Alexis Lothoré wrote:
>>>> Hi Andrii,
>>>>
>>>> On Wed Apr 16, 2025 at 11:24 PM CEST, Andrii Nakryiko wrote:
>>>>> On Fri, Apr 11, 2025 at 1:32 PM Alexis Lothoré (eBPF Foundation)
>>>>> <alexis.lothore@...tlin.com> wrote:
[...]
>> Ah, thanks for those clear examples, I completely overlooked this
>> possibility. And now that you mention it, I feel a bit dumb because I now
>> remember that you mentioned this in Puranjay's series...
>>
>> I took a quick look at the x86 JIT compiler for reference, and saw no code
>> related to this specific case neither. So I searched in the kernel for
>> actual functions taking struct arguments by value AND being declared with some
>> packed or aligned attribute. I only found a handful of those, and none
>> seems to take enough arguments to have the corresponding struct passed on the
>> stack. So rather than supporting this very specific case, I am tempted
>> to just return an error for now during trampoline creation if we detect such
>> structure (and then the JIT compiler can keep using data size to compute
>> alignment, now that it is sure not to receive custom alignments). Or am I
>> missing some actual cases involving those very specific alignments ?
>>
>
> How can we reliably 'detect' the case? If a function has such a parameter
> but we fail to detect it, the BPF trampoline will pass an incorrect value
> to the function, which is also unacceptable.
That's a question I still have to answer :) I imagined being able to detect
it thanks to some info somewhere in BTF, but I have to dig further to find
how.
Alexis
--
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Powered by blists - more mailing lists