Re: [PATCH bpf-next v1 0/3] Avoid typedef size mismatches in skeletons

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2022-02-10 at 15:14 -0800, Alexei Starovoitov wrote:
> So adding
> _Static_assert(sizeof(type_in_skel) == const_size_from_kernel);
> to skel.h would force users to pick types that are the same
> both in bpf prog and in corresponding user space part.

I'm not sure users have this much control over the definition of the types in
their program though. If a kernel and uapi typedef differ in size, this approach
would force the user to use kernel types for the entire program.

If, for example, pid_t is a different size in glibc and the kernel, it would
force you out of using any glibc functions taking pid_t (and potentially all of
glibc depending on how entangled the headers are).

By normalizing to stdint types, we're saying that the contract represented by
the skel does not operate with either uapi or kernel types and it's up to you to
ensure you use the right one (or mix and match, if you can). It feels
fundamentally more permissive to different types of situations than forcing the
skel user to only use kernel types or refactor their program to isolate the
kernel type leakage to only the compilation unit using the skel.




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux