lkml.org 
[lkml]   [2018]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH 3.16 093/328] ext4: fix spectre gadget in ext4_mb_regular_allocator()
    3.16.62-rc1 review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Jeremy Cline <jcline@redhat.com>

    commit 1a5d5e5d51e75a5bca67dadbcea8c841934b7b85 upstream.

    'ac->ac_g_ex.fe_len' is a user-controlled value which is used in the
    derivation of 'ac->ac_2order'. 'ac->ac_2order', in turn, is used to
    index arrays which makes it a potential spectre gadget. Fix this by
    sanitizing the value assigned to 'ac->ac2_order'. This covers the
    following accesses found with the help of smatch:

    * fs/ext4/mballoc.c:1896 ext4_mb_simple_scan_group() warn: potential
    spectre issue 'grp->bb_counters' [w] (local cap)

    * fs/ext4/mballoc.c:445 mb_find_buddy() warn: potential spectre issue
    'EXT4_SB(e4b->bd_sb)->s_mb_offsets' [r] (local cap)

    * fs/ext4/mballoc.c:446 mb_find_buddy() warn: potential spectre issue
    'EXT4_SB(e4b->bd_sb)->s_mb_maxs' [r] (local cap)

    Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
    Signed-off-by: Jeremy Cline <jcline@redhat.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    ---
    fs/ext4/mballoc.c | 4 +++-
    1 file changed, 3 insertions(+), 1 deletion(-)

    --- a/fs/ext4/mballoc.c
    +++ b/fs/ext4/mballoc.c
    @@ -26,6 +26,7 @@
    #include <linux/log2.h>
    #include <linux/module.h>
    #include <linux/slab.h>
    +#include <linux/nospec.h>
    #include <trace/events/ext4.h>

    #ifdef CONFIG_EXT4_DEBUG
    @@ -2124,7 +2125,8 @@ ext4_mb_regular_allocator(struct ext4_al
    * This should tell if fe_len is exactly power of 2
    */
    if ((ac->ac_g_ex.fe_len & (~(1 << (i - 1)))) == 0)
    - ac->ac_2order = i - 1;
    + ac->ac_2order = array_index_nospec(i - 1,
    + sb->s_blocksize_bits + 2);
    }

    /* if stream allocation is enabled, use global goal */
    \
     
     \ /
      Last update: 2018-12-09 23:26    [W:4.047 / U:0.092 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site