> So the fortify_string code has decided that only a single-byte (or > empty) memcpy is ok. > > And that, in turn, seems to be because we're copying from > optprobe_template_entry, which is declared as > > extern __visible kprobe_opcode_t optprobe_template_entry; > > so the fortify code decides it's a single character. > > Does just changing all those things to be declared as arrays fix > things?
Yeah, that fixes it because GCC will consider the size of 'char foo[]' unknown (i.e. (size_t)-1 from __builtin_object_size). GCC doesn't know this essentially constant value at compile-time so it wasn't a compile-time error: #define TMPL_END_IDX \ ((long)&optprobe_template_end - (long)&optprobe_template_entry) -fsanitize=object-size works the same way for pointer dereferences so replacing might fix some issues for CONFIG_UBSAN_SANITIZE_ALL. I guess that's way too noisy at the moment thus the !COMPILE_TEST.