Changeset 962c89af in mainline


Ignore:
Timestamp:
2019-06-20T14:51:57Z (5 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Parents:
5acf533
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-06-20 14:48:53)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-06-20 14:51:57)
Message:

Prevent leaking kernel stack bytes via sys_as_area_get_info()

The compiler will try to avoid initializing the padding bytes if it
doesn't have to, so copying the whole structure would copy whatever
bytes were on the stack before. We prevent that by clearing the whole
structure using memset().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/as.c

    r5acf533 r962c89af  
    21282128{
    21292129        as_area_t *area;
     2130        as_area_info_t info;
     2131
     2132        /* Prevent leaking stack bytes via structure padding. */
     2133        memset(&info, 0, sizeof(info));
    21302134
    21312135        mutex_lock(&AS->lock);
     
    21362140        }
    21372141
    2138         as_area_info_t info = {
    2139                 .start_addr = area->base,
    2140                 .size = P2SZ(area->pages),
    2141                 .flags = area->flags,
    2142         };
     2142        info.start_addr = area->base;
     2143        info.size = P2SZ(area->pages);
     2144        info.flags = area->flags;
    21432145
    21442146        mutex_unlock(&area->lock);
Note: See TracChangeset for help on using the changeset viewer.