• hellsgod's avatar
    Linux 3.4.80 · bfc85ea2
    hellsgod authored
    SELinux: Fix memory leak upon loading policy
    
    commit 8ed814602876bec9bad2649ca17f34b499357a1c upstream.
    
    Hello.
    
    I got below leak with linux-3.10.0-54.0.1.el7.x86_64 .
    
    [  681.903890] kmemleak: 5538 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
    
    Below is a patch, but I don't know whether we need special handing for undoing
    ebitmap_set_bit() call.
    ----------
    >>From fe97527a90fe95e2239dfbaa7558f0ed559c0992 Mon Sep 17 00:00:00 2001
    From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
    Date: Mon, 6 Jan 2014 16:30:21 +0900
    Subject: SELinux: Fix memory leak upon loading policy
    
    Commit 2463c26d "SELinux: put name based create rules in a hashtable" did not
    check return value from hashtab_insert() in filename_trans_read(). It leaks
    memory if hashtab_insert() returns error.
    
      unreferenced object 0xffff88005c9160d0 (size 8):
        comm "systemd", pid 1, jiffies 4294688674 (age 235.265s)
        hex dump (first 8 bytes):
          57 0b 00 00 6b 6b 6b a5                          W...kkk.
        backt...
    bfc85ea2
slub.c 130 KB