Re: [PATCH 0/3] Fix duplicated VAR and secinfo
Stephen Brennan <[email protected]> Mon, 24 Feb 2025 17:16:16 -0800
| Newsgroups | org.kernel.vger.linux-debuggers,org.kernel.vger.dwarves |
|---|---|
| Message-ID | <[email protected]> |
Eduard Zingerman <[email protected]> writes: > On Thu, 2025-02-20 at 17:05 -0800, Stephen Brennan wrote: > > [...] > >> Thank you for the testing (and the review). I haven't yet been able to >> reproduce this. But I see you're using clang. I'll spend the morning >> building & running selftests with clang to see whether that is the >> issue. > > Right, should have pointed that out in the email. > Clang version is 19.1.7. > Just tried with gcc, and `./test_progs -n 1` indeed works. > Then re-tried with clang, same result as yesterday, test fails. So I've set-up a Fedora 41 environment with the same clang version, and the plot thickens, at least for me. I haven't even gotten to the BPF self-tests, because clang is giving other duplicate variables! (To get these values, I uncommented the error return from my pahole patch) From vmlinux: error: encountered variable "fs_ftype_by_dtype" (type 149818) at offset "3d7500" which duplicates variable "ext4_type_by_mode" at the same offset error: encountered variable "fs_dtype_by_ftype" (type 149814) at offset "3d8c60" which duplicates variable "ext4_filetype_table" at the same offset error: encountered variable "pt_regoff" (type 52d893) at offset "3d8e50" which duplicates variable "addrmode_regoffs" at the same offset And from modules: error: encountered variable "evergreen_dp_offsets" (type 4e9b6) at offset "19760" which duplicates variable "crtc_offsets" at the same offset error: encountered variable "ni_dig_offsets" (type 4e9b6) at offset "19760" which duplicates variable "crtc_offsets" at the same offset error: encountered variable "rv770_smc_int_vectors" (type 5cd3d) at offset "2f220" which duplicates variable "rv740_smc_int_vectors" at the same offset error: encountered variable "cypress_smc_int_vectors" (type 5cd3d) at offset "2f260" which duplicates variable "cedar_smc_int_vectors" at the same offset error: encountered variable "juniper_smc_int_vectors" (type 5cd3d) at offset "2f260" which duplicates variable "cedar_smc_int_vectors" at the same offset error: encountered variable "redwood_smc_int_vectors" (type 5cd3d) at offset "2f260" which duplicates variable "cedar_smc_int_vectors" at the same offset error: encountered variable "caicos_smc_int_vectors" (type 5cd3d) at offset "2f2a0" which duplicates variable "barts_smc_int_vectors" at the same offset error: encountered variable "turks_smc_int_vectors" (type 5cd3d) at offset "2f2a0" which duplicates variable "barts_smc_int_vectors" at the same offset error: encountered variable "caicos_cgcg_cgls_default" (type 5e61d) at offset "2f550" which duplicates variable "barts_cgcg_cgls_default" at the same offset error: encountered variable "turks_cgcg_cgls_default" (type 5e61d) at offset "2f550" which duplicates variable "barts_cgcg_cgls_default" at the same offset error: encountered variable "turks_sysls_default" (type 5e622) at offset "30660" which duplicates variable "barts_sysls_default" at the same offset error: encountered variable "caicos_cgcg_cgls_enable" (type 5e624) at offset "30920" which duplicates variable "barts_cgcg_cgls_enable" at the same offset error: encountered variable "turks_cgcg_cgls_enable" (type 5e624) at offset "30920" which duplicates variable "barts_cgcg_cgls_enable" at the same offset error: encountered variable "caicos_cgcg_cgls_disable" (type 5e625) at offset "30b70" which duplicates variable "barts_cgcg_cgls_disable" at the same offset error: encountered variable "turks_cgcg_cgls_disable" (type 5e625) at offset "30b70" which duplicates variable "barts_cgcg_cgls_disable" at the same offset error: encountered variable "caicos_mgcg_disable" (type 5e626) at offset "30f50" which duplicates variable "barts_mgcg_disable" at the same offset error: encountered variable "turks_mgcg_disable" (type 5e626) at offset "30f50" which duplicates variable "barts_mgcg_disable" at the same offset error: encountered variable "turks_sysls_enable" (type 5e622) at offset "30fd0" which duplicates variable "barts_sysls_enable" at the same offset error: encountered variable "turks_sysls_disable" (type 5e622) at offset "31140" which duplicates variable "barts_sysls_disable" at the same offset error: encountered variable "sumo_utc" (type 5f2dc) at offset "313f0" which duplicates variable "sumo_dtc" at the same offset error: encountered variable "dte_data_curacao_xt" (type 63dee) at offset "38f00" which duplicates variable "dte_data_curacao_pro" at the same offset From what I can tell, these are all const arrays thrown into the r/o data section. Their data are duplicated, so it looks like clang has mapped them to the same addresses. Which is a pretty neat optimization! As far as I can tell, this is perfectly valid, and I think BTF should allow these variables to be aliased. So we may need to revisit the approach more: (1) pahole should still deduplicate identically-named variables at the same address due to the weak symbol issue. That would just save space and avoid silliness. But (2), I think we'll need the verifier to allow variables to overlap. I'll do that and continue testing. Stephen > > Thanks, > Eduard