Skip to contentSkip to conversation

sandbox error handling broken on origin/next

BUG Simon Glass 2 participants 5 messages Mar 22, 2021 – Apr 21, 2021 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi Heinrich,

Quoted 33 lines · Heinrich Schuchardt

Hello Simon,

using sandbox_defconfig on origin/master:

Hit any key to stop autoboot: 0
=> exception sigsegv

Segmentation violation
pc = 0x55d3566d04f9, pc_reloc = 0x554f9

$

Here the SIGSEGV is correctly handled by the sandbox.

On origin/next:

=> exception sigsegv

Segmentation violation
pc = 0x5567966da96b, pc_reloc = 0x5567866da96b

Writing sandbox state
Segmentation fault
$

The same problem is visible when executing the poweroff command.

=> poweroff
poweroff ...
Segmentation fault
$

Quoted 7 lines

Bisecting points to your commit

b308d9fd18fa
sandbox: Avoid using malloc() for system state

The segmentation fault occurs when os_exit() calls dm_uninit(). The value of gd is invalid at this point.

Can you please check this patch?

http://patchwork.ozlabs.org/project/uboot/patch/20210315051124.1940496-10-sjg at chromium.org/

Also, is there no test covering the above?

Regards,
Simon

#2 lore raw
Quoted 44 lines · Simon Glass

Hi Heinrich,

Quoted 33 lines · Heinrich Schuchardt

Hello Simon,

using sandbox_defconfig on origin/master:

Hit any key to stop autoboot: 0
=> exception sigsegv

Segmentation violation
pc = 0x55d3566d04f9, pc_reloc = 0x554f9

$

Here the SIGSEGV is correctly handled by the sandbox.

On origin/next:

=> exception sigsegv

Segmentation violation
pc = 0x5567966da96b, pc_reloc = 0x5567866da96b

Writing sandbox state
Segmentation fault
$

The same problem is visible when executing the poweroff command.

=> poweroff
poweroff ...
Segmentation fault
$

Quoted 7 lines

Bisecting points to your commit

b308d9fd18fa
sandbox: Avoid using malloc() for system state

The segmentation fault occurs when os_exit() calls dm_uninit(). The value of gd is invalid at this point.

Quoted 9 lines

Can you please check this patch?

http://patchwork.ozlabs.org/project/uboot/patch/20210315051124.1940496-10-sjg at chromium.org/

Also, is there no test covering the above?

Regards,
Simon

Hello Simon,

We have a poweroff test but there is no detection for the 'Segmentation fault' string.

For CONFIG_SANDBOX_CRASH_RESET=n the patch helps.

For CONFIG_SANDBOX_CRASH_RESET=y you still get a segmentation fault when executing 'exception sigsegv'.

Unfortunately you decided to disable CONFIG_SANDBOX_CRASH_RESET in sandbox_defconfig. Otherwise you would have detected the problem as "FAILED test/py/tests/test_sandbox_exit.py::test_exception_reset".

Please, adjust sandbox_reset().

Best regards

Heinrich

#3 lore raw

Hi Heinrich,

Quoted 58 lines · Heinrich Schuchardt
Quoted 44 lines · Simon Glass

Hi Heinrich,

Quoted 33 lines · Heinrich Schuchardt

Hello Simon,

using sandbox_defconfig on origin/master:

Hit any key to stop autoboot: 0
=> exception sigsegv

Segmentation violation
pc = 0x55d3566d04f9, pc_reloc = 0x554f9

$

Here the SIGSEGV is correctly handled by the sandbox.

On origin/next:

=> exception sigsegv

Segmentation violation
pc = 0x5567966da96b, pc_reloc = 0x5567866da96b

Writing sandbox state
Segmentation fault
$

The same problem is visible when executing the poweroff command.

=> poweroff
poweroff ...
Segmentation fault
$

Quoted 7 lines

Bisecting points to your commit

b308d9fd18fa
sandbox: Avoid using malloc() for system state

The segmentation fault occurs when os_exit() calls dm_uninit(). The value of gd is invalid at this point.

Quoted 9 lines

Can you please check this patch?

http://patchwork.ozlabs.org/project/uboot/patch/20210315051124.1940496-10-sjg at chromium.org/

Also, is there no test covering the above?

Regards,
Simon

Hello Simon,

Quoted 7 lines

We have a poweroff test but there is no detection for the 'Segmentation fault' string.

For CONFIG_SANDBOX_CRASH_RESET=n the patch helps.

For CONFIG_SANDBOX_CRASH_RESET=y you still get a segmentation fault when executing 'exception sigsegv'.

OK, is that caused by the same commit? The problem is that the commit is actually fixing a bug. I'll need to think about how to fix the fix.

Quoted 4 lines

Unfortunately you decided to disable CONFIG_SANDBOX_CRASH_RESET in sandbox_defconfig. Otherwise you would have detected the problem as "FAILED test/py/tests/test_sandbox_exit.py::test_exception_reset".

Well we don't generally want to reset when we get a crash, right?

Quoted 2 lines

Please, adjust sandbox_reset().

What would you like it to do?

Regards,
Simon

#4 lore raw

Am 23. M?rz 2021 01:57:00 MEZ schrieb Simon Glass <[email protected]>:

Quoted 68 lines

Hi Heinrich,

Quoted 5 lines · Heinrich Schuchardt
Quoted 3 lines · Simon Glass

Hi Heinrich,

On Tue, 23 Mar 2021 at 07:12, Heinrich Schuchardt

Quoted 38 lines · <[email protected]> wrote:
Quoted 38 lines
Quoted 38 lines

Hello Simon,

using sandbox_defconfig on origin/master:

Hit any key to stop autoboot: 0
=> exception sigsegv

Segmentation violation
pc = 0x55d3566d04f9, pc_reloc = 0x554f9

$

Here the SIGSEGV is correctly handled by the sandbox.

On origin/next:

=> exception sigsegv

Segmentation violation
pc = 0x5567966da96b, pc_reloc = 0x5567866da96b

Writing sandbox state
Segmentation fault
$

The same problem is visible when executing the poweroff command.

=> poweroff
poweroff ...
Segmentation fault
$

Bisecting points to your commit

b308d9fd18fa
sandbox: Avoid using malloc() for system state

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

The segmentation fault occurs when os_exit() calls dm_uninit(). The value of gd is invalid at this point.

Can you please check this patch?

http://patchwork.ozlabs.org/project/uboot/patch/20210315051124.1940496-10-sjg at chromium.org/

Quoted 10 lines
Quoted 6 lines

Also, is there no test covering the above?

Regards,
Simon

Hello Simon,

We have a poweroff test but there is no detection for the

'Segmentation

Quoted 2 lines

fault' string.

Quoted 7 lines
Quoted 3 lines

For CONFIG_SANDBOX_CRASH_RESET=n the patch helps.

For CONFIG_SANDBOX_CRASH_RESET=y you still get a segmentation fault

when

Quoted 1 line

executing 'exception sigsegv'.

OK, is that caused by the same commit?

Yes

Quoted 10 lines

The problem is that the commit
is actually fixing a bug. I'll need to think about how to fix the fix.

Quoted 4 lines

Unfortunately you decided to disable CONFIG_SANDBOX_CRASH_RESET in sandbox_defconfig. Otherwise you would have detected the problem as "FAILED test/py/tests/test_sandbox_exit.py::test_exception_reset".

Well we don't generally want to reset when we get a crash, right?

Resetting after a crash is what all other boards do.

I personally don't have a need for the sandbox to behave differently.

Quoted 4 lines
Quoted 2 lines

Please, adjust sandbox_reset().

What would you like it to do?

Executing the 'reset' command fails with a crash.

The crash occurs when dm_uninit() is invoked.

Best regards

Heinrich

#5 lore raw

Hi Heinrich,

Quoted 88 lines · Heinrich Schuchardt

Am 23. M?rz 2021 01:57:00 MEZ schrieb Simon Glass <[email protected]>:

Quoted 68 lines

Hi Heinrich,

Quoted 5 lines · Heinrich Schuchardt
Quoted 3 lines · Simon Glass

Hi Heinrich,

On Tue, 23 Mar 2021 at 07:12, Heinrich Schuchardt

Quoted 38 lines · <[email protected]> wrote:
Quoted 38 lines
Quoted 38 lines

Hello Simon,

using sandbox_defconfig on origin/master:

Hit any key to stop autoboot: 0
=> exception sigsegv

Segmentation violation
pc = 0x55d3566d04f9, pc_reloc = 0x554f9

$

Here the SIGSEGV is correctly handled by the sandbox.

On origin/next:

=> exception sigsegv

Segmentation violation
pc = 0x5567966da96b, pc_reloc = 0x5567866da96b

Writing sandbox state
Segmentation fault
$

The same problem is visible when executing the poweroff command.

=> poweroff
poweroff ...
Segmentation fault
$

Bisecting points to your commit

b308d9fd18fa
sandbox: Avoid using malloc() for system state

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

The segmentation fault occurs when os_exit() calls dm_uninit(). The value of gd is invalid at this point.

Can you please check this patch?

http://patchwork.ozlabs.org/project/uboot/patch/20210315051124.1940496-10-sjg at chromium.org/

Quoted 10 lines
Quoted 6 lines

Also, is there no test covering the above?

Regards,
Simon

Hello Simon,

We have a poweroff test but there is no detection for the

'Segmentation

Quoted 2 lines

fault' string.

Quoted 7 lines
Quoted 3 lines

For CONFIG_SANDBOX_CRASH_RESET=n the patch helps.

For CONFIG_SANDBOX_CRASH_RESET=y you still get a segmentation fault

when

Quoted 1 line

executing 'exception sigsegv'.

OK, is that caused by the same commit?

Yes

Quoted 8 lines

The problem is that the commit
is actually fixing a bug. I'll need to think about how to fix the fix.

Quoted 4 lines

Unfortunately you decided to disable CONFIG_SANDBOX_CRASH_RESET in sandbox_defconfig. Otherwise you would have detected the problem as "FAILED test/py/tests/test_sandbox_exit.py::test_exception_reset".

Quoted 6 lines
Quoted 2 lines

Well we don't generally want to reset when we get a crash, right?

Resetting after a crash is what all other boards do.

I personally don't have a need for the sandbox to behave differently.

I see sandbox as a normal program. If you run grimp and it crashes, it doesn't reset. The only reason we have a reset feature in sandbox is for testing purposes.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Please, adjust sandbox_reset().

What would you like it to do?

Executing the 'reset' command fails with a crash.

The crash occurs when dm_uninit() is invoked.

This is definitely a tricky area. Since devices are allocated in the 'emulated' RAM we really can't close down sandbox before uniniting devices, and vice versa. Some separation is needed.

I will take a look at this at some point, but it needs a fair bit of thought.

Regards,
Simon