Messages in this thread | | | Subject | Re: [PATCH bpf-next 0/2] Implement BPF formatted output helpers with bstr_printf | From | Rasmus Villemoes <> | Date | Fri, 23 Apr 2021 10:50:22 +0200 |
| |
On 23/04/2021 03.15, Florent Revest wrote: > Our formatted output helpers are currently implemented with > snprintf-like functions which take arguments as va_list but the types > stored in a va_list need to be known at compilation time which causes > problems when dealing with arguments from the BPF world that are always > u64 but considered differently depending on the format specifiers they > are associated with at runtime. > > This series replaces snprintf usages with bstr_printf calls. This lets > us construct a binary representation of arguments in bpf_printf_prepare > at runtime that matches an ABI that is neither arch nor compiler > specific. > > This solves a bug reported by Rasmus Villemoes that would mangle > arguments on 32 bit machines.
That's not entirely accurate. The arguments are also mangled on x86-64, it's just that in a few cases that goes unnoticed. That's why I suggested you try and take your test case (which I assume had been passing with flying colours on x86-64) and rearrange the specifiers, arguments and expected output string so that the (morally) 32 bit arguments end up beyond those-that-end-up-in-the-reg_save_area.
IOWs, it is the 32 bit arguments that are mangled (because they get passed as-if they were actually 64 bits), and that applies on all architectures; nothing to do with sizeof(long).
Rasmus
| |