Page MenuHomeFreeBSD

amd64: Use a larger boot stack
ClosedPublic

Authored by markj on Jul 24 2023, 8:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 30 2024, 3:58 PM
Unknown Object (File)
Sep 30 2024, 9:32 AM
Unknown Object (File)
Sep 27 2024, 1:28 PM
Unknown Object (File)
Sep 27 2024, 7:15 AM
Unknown Object (File)
Sep 27 2024, 4:09 AM
Unknown Object (File)
Sep 26 2024, 5:29 AM
Unknown Object (File)
Sep 25 2024, 8:49 PM
Unknown Object (File)
Sep 25 2024, 2:57 AM
Subscribers

Details

Summary

With sanitizers enabled, it becomes possible to overflow the stack when
only a single page is used. Follow arm64's example and use the default
kernel stack size instead. This is a bit wasteful, but without a guard
page, overflow is difficult to debug.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Jul 24 2023, 8:18 PM

Could you only enable it for sanitizers enable case?

In D41166#937374, @kib wrote:

Could you only enable it for sanitizers enable case?

I could, but is it really important to save three pages? We already consume more than half a page for the stack below, not sure if it's the worst case. Stack overflow corrupts adjacent pages in the BSS, which can take a lot of effort to debug. I'm sure that someday we'll hit the limit in GENERIC kernels.

#0  vsscanf (inp=<optimized out>, ap=0xffffffff81791820, fmt0=<optimized out>) at /root/freebsd/sys/kern/subr_scanf.c:132                                                                                                                                                                                                     
#1  sscanf (ibuf=ibuf@entry=0xffffffff81fc81a6 "acpi_throttle.0.disabled=1", fmt=<optimized out>) at /root/freebsd/sys/kern/subr_scanf.c:102                                                                                                                                                                                  
#2  0xffffffff80b9a6e2 in res_find (hintp_cookie=hintp_cookie@entry=0xffffffff817919e0, line=line@entry=0xffffffff817919ec, startln=startln@entry=0x0, 
    name=name@entry=0xffffffff812179e3 "acpi", unit=unit@entry=0xffffffff817919dc, resname=resname@entry=0xffffffff81223da5 "disabled", value=0x0, 
    ret_name=0x0, ret_namelen=0x0, ret_unit=0x0, ret_resname=0x0, ret_resnamelen=0x0, ret_value=0xffffffff817919d0)
    at /root/freebsd/sys/kern/subr_hints.c:241
#3  0xffffffff80b99d05 in resource_find (line=0xffffffff817919ec, startln=0x0, name=0xffffffff812179e3 "acpi", unit=0xffffffff817919dc, 
    resname=0xffffffff81223da5 "disabled", value=0x0, ret_name=0x0, ret_namelen=0x0, ret_unit=0x0, ret_resname=0x0, ret_resnamelen=0x0, 
    ret_value=0xffffffff817919d0) at /root/freebsd/sys/kern/subr_hints.c:323
#4  resource_int_value (name=0xffffffff812179e3 "acpi", unit=unit@entry=0, resname=0xffffffff81223da5 "disabled", result=result@entry=0xffffffff81791a2c)
    at /root/freebsd/sys/kern/subr_hints.c:350
#5  0xffffffff80b9a0e8 in resource_disabled (name=0xffffffff81fc81c0 "", unit=-2128589492, unit@entry=0) at /root/freebsd/sys/kern/subr_hints.c:489
#6  0xffffffff81013b15 in acpi_find_table (sig=0xffffffff81184309 "FACP") at /root/freebsd/sys/amd64/acpica/acpi_machdep.c:175
#7  0xffffffff81005485 in acpi_get_fadt_bootflags (flagsp=flagsp@entry=0xffffffff81791abe) at /root/freebsd/sys/x86/x86/cpu_machdep.c:1514
#8  0xffffffff8098cb96 in vga_acpi_disabled () at /root/freebsd/sys/dev/vt/hw/vga/vt_vga.c:1270                                                                
#9  vga_probe (vd=<optimized out>) at /root/freebsd/sys/dev/vt/hw/vga/vt_vga.c:1282                                                                            
#10 0xffffffff8099290e in vtterm_cnprobe (tm=0xffffffff816ab320 <vt_consterm>, cp=0xffffffff816ab120 <vt_consterm_consdev>)
    at /root/freebsd/sys/dev/vt/vt_core.c:1656
#11 0xffffffff80add88e in cninit () at /root/freebsd/sys/kern/kern_cons.c:168
#12 0xffffffff81022f81 in hammer_time (modulep=<optimized out>, physfree=<optimized out>) at /root/freebsd/sys/amd64/amd64/machdep.c:1552
#13 0xffffffff8037e01b in btext () at /root/freebsd/sys/amd64/amd64/locore.S:88
This revision is now accepted and ready to land.Jul 24 2023, 9:41 PM
This revision was automatically updated to reflect the committed changes.