linux-stable/fs/ecryptfs
Nathan Chancellor 35dc93efe5 ecryptfs: Fix up bad backport of fe2e082f5d
When doing the 4.9 merge into certain Android trees, I noticed a warning
from Android's deprecated GCC 4.9.4, which causes a build failure in
those trees due to basically -Werror:

fs/ecryptfs/keystore.c: In function 'ecryptfs_parse_packet_set':
fs/ecryptfs/keystore.c:1357:2: warning: 'auth_tok_list_item' may be used
uninitialized in this function [-Wmaybe-uninitialized]
  memset(auth_tok_list_item, 0,
  ^
fs/ecryptfs/keystore.c:1260:38: note: 'auth_tok_list_item' was declared
here
  struct ecryptfs_auth_tok_list_item *auth_tok_list_item;
                                      ^

GCC 9.2.0 was not able to pick up this warning when I tested it.

Turns out that Clang warns as well when -Wuninitialized is used, which
is not the case in older stable trees at the moment (but shows value in
potentially backporting the various warning fixes currently in upstream
to get more coverage).

fs/ecryptfs/keystore.c:1284:6: warning: variable 'auth_tok_list_item' is
used uninitialized whenever 'if' condition is true
[-Wsometimes-uninitialized]
        if (data[(*packet_size)++] != ECRYPTFS_TAG_1_PACKET_TYPE) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/ecryptfs/keystore.c:1360:4: note: uninitialized use occurs here
                        auth_tok_list_item);
                        ^~~~~~~~~~~~~~~~~~
fs/ecryptfs/keystore.c:1284:2: note: remove the 'if' if its condition is
always false
        if (data[(*packet_size)++] != ECRYPTFS_TAG_1_PACKET_TYPE) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/ecryptfs/keystore.c:1260:56: note: initialize the variable
'auth_tok_list_item' to silence this warning
        struct ecryptfs_auth_tok_list_item *auth_tok_list_item;
                                                              ^
                                                               = NULL
1 warning generated.

Somehow, commit fe2e082f5d ("ecryptfs: fix a memory leak bug in
parse_tag_1_packet()") upstream was not applied in the correct if block
in 4.4.215, 4.9.215, and 4.14.172, which will indeed lead to use of
uninitialized memory. Fix it up by undoing the bad backport in those
trees then reapplying the patch in the proper location.

Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-11 18:02:51 +01:00
..
Kconfig Minor code cleanups and new Kconfig option to disable /dev/ecryptfs 2013-03-07 12:47:24 -08:00
Makefile
crypto.c ecryptfs: replace BUG_ON with error handling code 2020-02-28 16:36:15 +01:00
debug.c
dentry.c eCryptfs: Invalidate dcache entries when lower i_nlink is zero 2015-08-18 17:29:48 -05:00
ecryptfs_kernel.h ecryptfs: fix dereference of NULL user_key_payload 2017-10-12 17:16:40 +01:00
file.c eCryptfs: don't pass up plaintext names when using filename encryption 2018-06-21 04:02:42 +09:00
inode.c ecryptfs_lookup_interpose(): lower_dentry->d_parent is not stable either 2019-11-20 17:59:32 +01:00
keystore.c ecryptfs: Fix up bad backport of fe2e082f5d 2020-03-11 18:02:51 +01:00
kthread.c scripts/spelling.txt: add "againt" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
main.c VFS: Convert sb->s_flags & MS_RDONLY to sb_rdonly(sb) 2017-07-17 08:45:34 +01:00
messaging.c ecryptfs: fix a memory leak bug in ecryptfs_init_messaging() 2020-02-28 16:35:51 +01:00
miscdev.c ecryptfs: close rmmod race 2013-04-09 14:08:16 -04:00
mmap.c xattr: Add __vfs_{get,set,remove}xattr helpers 2016-10-07 20:10:44 -04:00
read_write.c fs: fix kernel_write prototype 2017-09-04 19:05:15 -04:00
super.c eCryptfs: Do not allocate hash tfm in NORECLAIM context 2016-04-20 17:50:01 +08:00