Bug 216905 - Kernel won't compile with KASAN
Summary: Kernel won't compile with KASAN
Status: RESOLVED ANSWERED
Alias: None
Product: Memory Management
Classification: Unclassified
Component: Sanitizers (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: MM/Sanitizers virtual assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-09 23:42 UTC by Robert Dinse
Modified: 2023-01-16 07:02 UTC (History)
2 users (show)

See Also:
Kernel Version: 6.1.4
Subsystem:
Regression: No
Bisected commit-id:


Attachments
These are errors when trying to compile KASAN inline (24.22 KB, text/plain)
2023-01-09 23:42 UTC, Robert Dinse
Details
These are errors when trying to compile KASAN outline (24.79 KB, text/plain)
2023-01-09 23:43 UTC, Robert Dinse
Details
Config used for inline. (266.23 KB, text/plain)
2023-01-09 23:46 UTC, Robert Dinse
Details

Description Robert Dinse 2023-01-09 23:42:40 UTC
Created attachment 303563 [details]
These are errors when trying to compile KASAN inline

Using GCC 12.2, can not compile a kernel with KASAN enabled, either inline or outline.
The hardware is an i7-6700k based home brew machine, Asus motherboard.
running Ubuntu 22.10 32GB of RAM but using gcc 12.2 rather than the Ubuntu compiler.
Comment 1 Robert Dinse 2023-01-09 23:43:58 UTC
Created attachment 303564 [details]
These are errors when trying to compile KASAN outline
Comment 2 Robert Dinse 2023-01-09 23:46:00 UTC
Created attachment 303565 [details]
Config used for inline.

Didn't include the outline config is that is the only config change made.
Comment 3 Andrew Morton 2023-01-10 00:09:32 UTC
(switched to email.  Please respond via emailed reply-to-all, not via the
bugzilla web interface).

On Mon, 09 Jan 2023 23:42:40 +0000 bugzilla-daemon@kernel.org wrote:

> https://bugzilla.kernel.org/show_bug.cgi?id=216905
> 
>             Bug ID: 216905
>            Summary: Kernel won't compile with KASAN
>            Product: Memory Management
>            Version: 2.5
>     Kernel Version: 6.1.4
>           Hardware: All
>                 OS: Linux
>               Tree: Mainline
>             Status: NEW
>           Severity: normal
>           Priority: P1
>          Component: Other
>           Assignee: akpm@linux-foundation.org
>           Reporter: nanook@eskimo.com
>         Regression: No
> 
> Created attachment 303563 [details]
>   --> https://bugzilla.kernel.org/attachment.cgi?id=303563&action=edit
> These are errors when trying to compile KASAN inline
> 
> Using GCC 12.2, can not compile a kernel with KASAN enabled, either inline or
> outline.
> The hardware is an i7-6700k based home brew machine, Asus motherboard.
> running Ubuntu 22.10 32GB of RAM but using gcc 12.2 rather than the Ubuntu
> compiler.

crypto/ecc.c: In function ‘ecc_point_mult_shamir’:
crypto/ecc.c:1414:1: warning: the frame size of 1168 bytes is larger than 1024 bytes [-Wframe-larger-than=]
 1414 | }
      | ^
lib/crypto/curve25519-hacl64.c: In function ‘ladder_cmult.constprop’:
lib/crypto/curve25519-hacl64.c:601:1: warning: the frame size of 1376 bytes is larger than 1024 bytes [-Wframe-larger-than=]
  601 | }
      | ^
lib/zstd/common/entropy_common.c: In function ‘HUF_readStats’:
lib/zstd/common/entropy_common.c:258:1: warning: the frame size of 1088 bytes is larger than 1024 bytes [-Wframe-larger-than=]
  258 | }
      | ^

(etcetera)

Increasing CONFIG_FRAME_WARN should fix this.  Try 2048.

Perhaps KASAN could increase it somehow to prevent others from tripping
over this.
Comment 4 Robert Dinse 2023-01-10 04:58:50 UTC
      Increasing to 2048 did allow kernels to compile with KASAN 
enabled.  I am curious why e-mail only?  It would seem bugzilla, a 
public forum would make this fix available to others who may be 
experiencing the same or related problems.  Interestingly, I could not 
locate the symbol with xconfig, had to hand edit the .config file in 
deference to the fact that it tells you not to.

On 1/9/23 16:09, Andrew Morton wrote:
> (switched to email.  Please respond via emailed reply-to-all, not via the
> bugzilla web interface).
>
> On Mon, 09 Jan 2023 23:42:40 +0000 bugzilla-daemon@kernel.org wrote:
>
>> https://bugzilla.kernel.org/show_bug.cgi?id=216905
>>
>>              Bug ID: 216905
>>             Summary: Kernel won't compile with KASAN
>>             Product: Memory Management
>>             Version: 2.5
>>      Kernel Version: 6.1.4
>>            Hardware: All
>>                  OS: Linux
>>                Tree: Mainline
>>              Status: NEW
>>            Severity: normal
>>            Priority: P1
>>           Component: Other
>>            Assignee: akpm@linux-foundation.org
>>            Reporter: nanook@eskimo.com
>>          Regression: No
>>
>> Created attachment 303563 [details]
>>    --> https://bugzilla.kernel.org/attachment.cgi?id=303563&action=edit
>> These are errors when trying to compile KASAN inline
>>
>> Using GCC 12.2, can not compile a kernel with KASAN enabled, either inline
>> or
>> outline.
>> The hardware is an i7-6700k based home brew machine, Asus motherboard.
>> running Ubuntu 22.10 32GB of RAM but using gcc 12.2 rather than the Ubuntu
>> compiler.
> crypto/ecc.c: In function ‘ecc_point_mult_shamir’:
> crypto/ecc.c:1414:1: warning: the frame size of 1168 bytes is larger than
> 1024 bytes [-Wframe-larger-than=]
>   1414 | }
>        | ^
> lib/crypto/curve25519-hacl64.c: In function ‘ladder_cmult.constprop’:
> lib/crypto/curve25519-hacl64.c:601:1: warning: the frame size of 1376 bytes
> is larger than 1024 bytes [-Wframe-larger-than=]
>    601 | }
>        | ^
> lib/zstd/common/entropy_common.c: In function ‘HUF_readStats’:
> lib/zstd/common/entropy_common.c:258:1: warning: the frame size of 1088 bytes
> is larger than 1024 bytes [-Wframe-larger-than=]
>    258 | }
>        | ^
>
> (etcetera)
>
> Increasing CONFIG_FRAME_WARN should fix this.  Try 2048.
>
> Perhaps KASAN could increase it somehow to prevent others from tripping
> over this.
Comment 5 Dmitry Vyukov 2023-01-10 08:52:49 UTC
Maybe we should add noinline_for_stack to ecc_point_double_jacobian() function declaration:
https://elixir.bootlin.com/linux/v6.2-rc3/source/include/linux/compiler_types.h#L192

it's called from ecc_point_mult_shamir():
https://elixir.bootlin.com/linux/v6.2-rc3/source/crypto/ecc.c#L1396

Though I am not sure about performance impact in non-KASAN build.

Meanwhile you may try gcc 10.2. syzbot uses it with KASAN and builds seem to be fine.
Comment 6 Theodore Tso 2023-01-10 19:33:45 UTC
On Mon, Jan 09, 2023 at 08:58:41PM -0800, Robert Dinse wrote:
> 
>  Increasing to 2048 did allow kernels to compile with KASAN enabled. I
> am curious why e-mail only? It would seem bugzilla, a public forum would
> make this fix available to others who may be experiencing the same or
> related problems.

Not all kernel developers pay attention to bugzilla.  (In fact, most
kernel developers do not.)

>  Interestingly, I could not locate the symbol with
> xconfig, had to hand edit the .config file in deference to the fact that it
> tells you not to.

If you search for FRAME_WARN in menuconfig ('/', followed by
"FRAME_WARN", followed by return), it will report:

Symbol: FRAME_WARN [=2048]
 Type  : integer
 Range : [0 8192]
 Defined at lib/Kconfig.debug:395
   Prompt: Warn for stack frames larger than
   Locationf
     -> Kernel hacking
       -> Compile-time checks and compiler options
 (1)     -> Warn for stack frames larger than (FRAME_WARN [=2048])


That being said, you can edit the .config file if you know what you
are doing.  But if it breaks, you get to keep both pieces, since there
aren't the safety checks and guardrails of the supported paths.  For
novices, I recommend saving a copy of .config before editing the
.config, and then afterwards, run "make oldconfig", and then diff the
resulting .config with the saved copy to make sure there aren't any
unexpected changes.

Cheers,

							- Ted
Comment 7 Robert Dinse 2023-01-10 21:13:14 UTC
I used xconfig and used control-F and then searched on the same term, didn't find.  But moot at this point.  Kernel is built and installed on one machine, will install on the other two NFS servers this friday, they have more mission critical apps so can not boot them during the business week.
Comment 8 Robert Dinse 2023-01-16 07:02:01 UTC
Since this got around the compile issue, I am closing this ticket.

Note You need to log in before you can comment on or make changes to this bug.