SUSE / clang-extract

A tool to extract code content from source files using the clang and LLVM infrastructure.
Other
16 stars 2 forks source link

Issue parsing kernel/sched/psi.c #118

Closed fgyanz closed 3 months ago

fgyanz commented 3 months ago

Hello,

I'm trying to extract the function psi_trigger_destroy in kernel/sched/psi.c, but unfortunately it's failing with the following error:

/home/fgonzalez/src/klp-data/x86_64/usr/src/linux-5.3.18-150200.24.175/kernel/sched/psi.c:747:27: error: initializing 'struct static_key_false (*)' with an expression of incompatible type 'struct static_key_false'; take the address with &
  747 | DEFINE_STATIC_KEY_FALSE((*klpe_psi_disabled));
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/home/fgonzalez/src/klp-data/x86_64/usr/src/linux-5.3.18-150200.24.175/include/linux/jump_label.h:367:26: note: expanded from macro 'DEFINE_STATIC_KEY_FALSE'
  367 |         struct static_key_false name = STATIC_KEY_FALSE_INIT
      |                                 ^      ~~~~~~~~~~~~~~~~~~~~~
/home/fgonzalez/src/klp-data/x86_64/usr/src/linux-5.3.18-150200.24.175/kernel/sched/psi.c:757:33: error: static declaration of 'klpe_psi_disabled' follows non-static declaration
  757 | static struct static_key_false *klpe_psi_disabled;
      |                                 ^
/home/fgonzalez/src/klp-data/x86_64/usr/src/linux-5.3.18-150200.24.175/kernel/sched/psi.c:747:27: note: previous definition is here
  747 | DEFINE_STATIC_KEY_FALSE((*klpe_psi_disabled));
      |                           ^

Error on pass: FunctionExternalizerPass

Full report.txt

The error can be triggered by using klp-build, with the following commands: 1) klp-build setup -n bsc1225110 --cve 2023-52707 --conf CONFIG_PSI --file-func kernel/sched/psi.c psi_trigger_destroy 2) klp-build extract -n bsc1225110 --type ce

Tested with codestreams SLE 15.2u39-44 and clang-extract latest version

Let me know if you need anything else :)

Thanks!

marcosps commented 3 months ago

I did some local tests, and it worked with upstream kernel (using IBT and klp-convert), but it does fail on our codestreams since we use the kallsyms externalization method. It at least trims down what we need to look for.

@fgyanz thanks a lot for the report!

giulianobelinassi commented 3 months ago

Disabling -DCE_LATE_EXTERNALIZE should work for now. The issue here is in the Macro Rewriting.