codeql icon indicating copy to clipboard operation
codeql copied to clipboard

Unable to create database on latest Linux kernel

Open ftyghome opened this issue 1 month ago • 6 comments

Description of the issue

I'm attempting to analyze the Linux kernel using CodeQL, but I'm encountering errors during database creation.

Steps to reproduce:

  1. Clone the latest Linux kernel repository
  2. Run: codeql database create db --language c
  3. CodeQL correctly detects it as a Linux kernel and starts the autobuild process
  4. The build completes defconfig and compiles the kernel successfully

Problem:

The trace output contains numerous "identifier 'asm' is undefined" errors, such as:

[E 15:16:45 4019640] Warning[extractor-c++]: In construct_text_message: "./include/linux/sched/signal.h", line 278: error: identifier "asm" is undefined
        WARN_ON(sig->flags & SIGNAL_GROUP_EXIT);
        ^

"./include/linux/mm_types.h", line 1362: error: identifier "asm" is undefined
        set_mask_bits(bitmap, mask, bits);
        ^

"./arch/x86/include/asm/pgtable.h", line 741: error: identifier "asm" is undefined
        WARN_ON_ONCE((pgprot_val(pgprot) & (_PAGE_DIRTY | _PAGE_RW)) ==
        ^

Additionally, the resulting database is highly incomplete and contains very little information, making it unusable for analysis.

Environment tested:

  • Ubuntu 24.04 and Arch Linux
  • Latest CodeQL and version from June 2024

I would greatly appreciate any guidance on what might be causing this issue. Thank you very much for your time!

ftyghome avatar Dec 07 '25 15:12 ftyghome

Hi @ftyghome,

Before diving into this, did you see https://github.com/github/codeql/issues/16908#issuecomment-2213507452? Also could you tell us exactly which CodeQL versions you are using?

jketema avatar Dec 07 '25 15:12 jketema

Hi @ftyghome,

Before diving into this, did you see #16908 (comment)? Also could you tell us exactly which CodeQL versions you are using?

Hi @jketema,

Yes, I did see that comment. Although the issues may not be directly related, I tried following the approach mentioned in that issue and modified the kernel accordingly, but the problem persists.

I'm using CodeQL version 2.23.7 (release version).

Thank you!

ftyghome avatar Dec 07 '25 15:12 ftyghome

It looks like the Linux kernel is now compiled with the -fms-extensions option https://github.com/torvalds/linux/commit/c4781dc3d1cf0e017e1f290607ddc56cfe187afc. We support this option. However, it looks like there's some issue in combination with the inline assembly that the Linux kernel uses. I'll report this problem to our frontend supplier, but I cannot give you a timeline for a fix.

jketema avatar Dec 08 '25 10:12 jketema

Hi @jketema,

Thanks for tracking this down! Looking forward to hearing about a fix.

ftyghome avatar Dec 08 '25 11:12 ftyghome

We've received a patch for the inline assembly issue. However, this uncovered a number of additional issues affecting database creation for Linux. Those have also been reported to our frontend provider.

jketema avatar Dec 12 '25 13:12 jketema

Thanks for the update!

ftyghome avatar Dec 12 '25 14:12 ftyghome