diff options
author | Arnd Bergmann <arnd@arndb.de> | 2017-09-15 21:55:46 +0200 |
---|---|---|
committer | John Johansen <john.johansen@canonical.com> | 2017-11-21 11:15:50 +0100 |
commit | 7bba39ae52c4d7b467d0a6f74cc067a561aac043 (patch) | |
tree | 3995a82c162d555bfdfc8901655fb19e852b0090 /drivers/spi/spi-bcm2835.c | |
parent | apparmor: fix spelling mistake: "resoure" -> "resource" (diff) | |
download | linux-7bba39ae52c4d7b467d0a6f74cc067a561aac043.tar.xz linux-7bba39ae52c4d7b467d0a6f74cc067a561aac043.zip |
apparmor: initialized returned struct aa_perms
gcc-4.4 points out suspicious code in compute_mnt_perms, where
the aa_perms structure is only partially initialized before getting
returned:
security/apparmor/mount.c: In function 'compute_mnt_perms':
security/apparmor/mount.c:227: error: 'perms.prompt' is used uninitialized in this function
security/apparmor/mount.c:227: error: 'perms.hide' is used uninitialized in this function
security/apparmor/mount.c:227: error: 'perms.cond' is used uninitialized in this function
security/apparmor/mount.c:227: error: 'perms.complain' is used uninitialized in this function
security/apparmor/mount.c:227: error: 'perms.stop' is used uninitialized in this function
security/apparmor/mount.c:227: error: 'perms.deny' is used uninitialized in this function
Returning or assigning partially initialized structures is a bit tricky,
in particular it is explicitly allowed in c99 to assign a partially
initialized structure to another, as long as only members are read that
have been initialized earlier. Looking at what various compilers do here,
the version that produced the warning copied uninitialized stack data,
while newer versions (and also clang) either set the other members to
zero or don't update the parts of the return buffer that are not modified
in the temporary structure, but they never warn about this.
In case of apparmor, it seems better to be a little safer and always
initialize the aa_perms structure. Most users already do that, this
changes the remaining ones, including the one instance that I got the
warning for.
Fixes: fa488437d0f9 ("apparmor: add mount mediation")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'drivers/spi/spi-bcm2835.c')
0 files changed, 0 insertions, 0 deletions