Bug 82041 - memset optimized out in random.c
Summary: memset optimized out in random.c
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Other (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: drivers_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-09 17:33 UTC by zatimend
Modified: 2021-10-15 18:00 UTC (History)
4 users (show)

See Also:
Kernel Version: 3.16
Tree: Mainline
Regression: No


Attachments
force memset calls (1.81 KB, patch)
2014-08-25 17:16 UTC, hannes
Details | Diff

Description zatimend 2014-08-09 17:33:10 UTC
When looking at drivers/char/random.c, I noticed in the compile output the 
code for memset() had been optimized out. This is normal action of GCC for 
variables which are about to go out of scope. This causes a small security 
risk as sensitive data is not cleared after use.

Found by looking at the output of objdump -S random.o, functions
extract_buf, extract_entropy, extract_entropy_user

Kernel 3.16 (gentoo), GCC 4.8.3, on a Intel i7 (X86_64) processor.
Comment 1 Alexey Dobriyan 2014-08-12 11:47:34 UTC
same issue all over crypto/ as well
Comment 2 Alan 2014-08-21 18:19:05 UTC
Probably we need a memset_me_harder() that ensures gcc knows to behave (casting to volatile perhaps ?)
Comment 3 hannes 2014-08-25 17:16:10 UTC
Created attachment 148081 [details]
force memset calls
Comment 4 Ahmed Sayeed 2021-10-15 18:00:04 UTC
[gdb/symtab] Handle DW_TAG_type_unit in process_psymtab_comp_unit 
    
    When running test-case gdb.cp/cpexprs-debug-types.exp with target board
    unix/gdb:debug_flags=-gdwarf-5, I run into:
    ...
    (gdb) file cpexprs-debug-types^M
    Reading symbols from cpexprs-debug-types...^M
    ERROR: Couldn't load cpexprs-debug-types into GDB (eof).
    ERROR: Couldn't send delete breakpoints to GDB.
    ERROR: GDB process no longer exists
    GDB process exited with wait status 23054 exp9 0 0 CHILDKILLED SIGABRT SIGABRT
    ... https://www.webb-dev.co.uk/crypto/crypto-for-investing/
    
    We're running into this abort in process_psymtab_comp_unit:
    ...
      switch (reader.comp_unit_die->tag) 
        {
        case DW_TAG_compile_unit:
          this_cu->unit_type = DW_UT_compile; http://www.compilatori.com/tech/nvidia-and-samsung/
          break;
        case DW_TAG_partial_unit:
          this_cu->unit_type = DW_UT_partial; http://www.acpirateradio.co.uk/tech/nvidia-and-samsung/
          break;
        default:
          abort (); http://www.logoarts.co.uk/tech/nvidia-and-samsung/ 
        }
    ...
    because reader.comp_unit_die->tag == DW_TAG_type_unit.
     http://www.slipstone.co.uk/tech/nvidia-and-samsung/
    Fix this by adding a DW_TAG_type_unit case.
    
    Tested on x86_64-linux.
    
    gdb/ChangeLog: http://embermanchester.uk/tech/nvidia-and-samsung/
[gdb/symtab] Handle DW_TAG_type_unit in process_psymtab_comp_unit
    
    When running test-case gdb.cp/cpexprs-debug-types.exp with target board
    unix/gdb:debug_flags=-gdwarf-5, I run into: http://connstr.net/tech/nvidia-and-samsung/
    ...
    (gdb) file cpexprs-debug-types^M
    Reading symbols from cpexprs-debug-types...^M http://joerg.li/tech/nvidia-and-samsung/
    ERROR: Couldn't load cpexprs-debug-types into GDB (eof).
    ERROR: Couldn't send delete breakpoints to GDB.
    ERROR: GDB process no longer exists http://www.jopspeech.com/tech/nvidia-and-samsung/
    GDB process exited with wait status 23054 exp9 0 0 CHILDKILLED SIGABRT SIGABRT
    ...
    
    We're running into this abort in process_psymtab_comp_unit: http://www.wearelondonmade.com/tech/nvidia-and-samsung/
    ...
      switch (reader.comp_unit_die->tag)
        {
        case DW_TAG_compile_unit: https://waytowhatsnext.com/technology/korean-technology/
          this_cu->unit_type = DW_UT_compile;
          break;
        case DW_TAG_partial_unit: http://www.iu-bloomington.com/technology/miui13/
          this_cu->unit_type = DW_UT_partial;
          break;
        default:
          abort (); https://komiya-dental.com/technology/miui-13/
        }
    ...
    because reader.comp_unit_die->tag == DW_TAG_type_unit.
    http://www-look-4.com/tech/nvidia-and-samsung/
    Fix this by adding a DW_TAG_type_unit case.
    
    Tested on x86_64-linux.
    https://www.webb-dev.co.uk/technology/grt-r910/
    gdb/ChangeLog:

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