<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/ecryptfs/keystore.c, branch linux-4.4.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-03-11T06:51:14Z</updated>
<entry>
<title>ecryptfs: Fix up bad backport of fe2e082f5da5b4a0a92ae32978f81507ef37ec66</title>
<updated>2020-03-11T06:51:14Z</updated>
<author>
<name>Nathan Chancellor</name>
</author>
<published>2020-03-02T20:39:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6c2c0ed34eeac5163dd793ce1aa32f8c95b8cff8'/>
<id>urn:sha1:6c2c0ed34eeac5163dd793ce1aa32f8c95b8cff8</id>
<content type='text'>
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 fe2e082f5da5 ("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 &lt;natechancellor@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>ecryptfs: fix a memory leak bug in parse_tag_1_packet()</title>
<updated>2020-02-28T14:38:47Z</updated>
<author>
<name>Wenwen Wang</name>
</author>
<published>2019-08-20T05:16:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a77294e348043778bff168c70d0cd6be3c3ae02c'/>
<id>urn:sha1:a77294e348043778bff168c70d0cd6be3c3ae02c</id>
<content type='text'>
commit fe2e082f5da5b4a0a92ae32978f81507ef37ec66 upstream.

In parse_tag_1_packet(), if tag 1 packet contains a key larger than
ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES, no cleanup is executed, leading to a
memory leak on the allocated 'auth_tok_list_item'. To fix this issue, go to
the label 'out_free' to perform the cleanup work.

Cc: stable@vger.kernel.org
Fixes: dddfa461fc89 ("[PATCH] eCryptfs: Public key; packet management")
Signed-off-by: Wenwen Wang &lt;wenwen@cs.uga.edu&gt;
Signed-off-by: Tyler Hicks &lt;tyhicks@canonical.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ecryptfs: fix dereference of NULL user_key_payload</title>
<updated>2017-11-02T08:40:50Z</updated>
<author>
<name>Eric Biggers</name>
</author>
<published>2017-10-09T19:51:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=50044e419e83cb4cab63375541f9c099a0d059a5'/>
<id>urn:sha1:50044e419e83cb4cab63375541f9c099a0d059a5</id>
<content type='text'>
commit f66665c09ab489a11ca490d6a82df57cfc1bea3e upstream.

In eCryptfs, we failed to verify that the authentication token keys are
not revoked before dereferencing their payloads, which is problematic
because the payload of a revoked key is NULL.  request_key() *does* skip
revoked keys, but there is still a window where the key can be revoked
before we acquire the key semaphore.

Fix it by updating ecryptfs_get_key_payload_data() to return
-EKEYREVOKED if the key payload is NULL.  For completeness we check this
for "encrypted" keys as well as "user" keys, although encrypted keys
cannot be revoked currently.

Alternatively we could use key_validate(), but since we'll also need to
fix ecryptfs_get_key_payload_data() to validate the payload length, it
seems appropriate to just check the payload pointer.

Fixes: 237fead61998 ("[PATCH] ecryptfs: fs/Makefile and fs/Kconfig")
Reviewed-by: James Morris &lt;james.l.morris@oracle.com&gt;
Cc: Michael Halcrow &lt;mhalcrow@google.com&gt;
Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;


</content>
</entry>
<entry>
<title>eCryptfs: ensure copy to crypt_stat-&gt;cipher does not overrun</title>
<updated>2015-02-25T01:23:28Z</updated>
<author>
<name>Colin Ian King</name>
</author>
<published>2015-02-23T11:34:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2a559a8bdeae853b6a8abb477c88875e1d4de591'/>
<id>urn:sha1:2a559a8bdeae853b6a8abb477c88875e1d4de591</id>
<content type='text'>
The patch 237fead61998: "[PATCH] ecryptfs: fs/Makefile and
fs/Kconfig" from Oct 4, 2006, leads to the following static checker
warning:

  fs/ecryptfs/crypto.c:846 ecryptfs_new_file_context()
  error: off-by-one overflow 'crypt_stat-&gt;cipher' size 32.  rl = '0-32'

There is a mismatch between the size of ecryptfs_crypt_stat.cipher
and ecryptfs_mount_crypt_stat.global_default_cipher_name causing the
copy of the cipher name to cause a off-by-one string copy error. This
fix ensures the space reserved for this string is the same size including
the trailing zero at the end throughout ecryptfs.

This fix avoids increasing the size of ecryptfs_crypt_stat.cipher
and also ecryptfs_parse_tag_70_packet_silly_stack.cipher_string and instead
reduces the of ECRYPTFS_MAX_CIPHER_NAME_SIZE to 31 and includes the + 1 for
the end of string terminator.

NOTE: An overflow is not possible in practice since the value copied
into global_default_cipher_name is validated by
ecryptfs_code_for_cipher_string() at mount time. None of the allowed
cipher strings are long enough to cause the potential buffer overflow
fixed by this patch.

Signed-off-by: Colin Ian King &lt;colin.king@canonical.com&gt;
Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
[tyhicks: Added the NOTE about the overflow not being triggerable]
Signed-off-by: Tyler Hicks &lt;tyhicks@canonical.com&gt;
</content>
</entry>
<entry>
<title>eCryptfs: Remove unnecessary casts when parsing packet lengths</title>
<updated>2014-10-29T23:32:59Z</updated>
<author>
<name>Tyler Hicks</name>
</author>
<published>2014-10-23T14:16:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=831115af5ca36d713355bf1b379081691eca8b3f'/>
<id>urn:sha1:831115af5ca36d713355bf1b379081691eca8b3f</id>
<content type='text'>
The elements in the data array are already unsigned chars and do not
need to be casted.

Signed-off-by: Tyler Hicks &lt;tyhicks@canonical.com&gt;
Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
</content>
</entry>
<entry>
<title>ecryptfs: remove unnecessary break after goto</title>
<updated>2014-07-14T19:29:11Z</updated>
<author>
<name>Fabian Frederick</name>
</author>
<published>2014-07-08T16:30:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=04ec5f5c0022ee941615e304bc75853fe1bc94ba'/>
<id>urn:sha1:04ec5f5c0022ee941615e304bc75853fe1bc94ba</id>
<content type='text'>
Signed-off-by: Fabian Frederick &lt;fabf@skynet.be&gt;
Cc: ecryptfs@vger.kernel.org
Signed-off-by: Tyler Hicks &lt;tyhicks@canonical.com&gt;
</content>
</entry>
<entry>
<title>ecryptfs: Remove unnecessary include of syscall.h in keystore.c</title>
<updated>2014-07-03T21:38:23Z</updated>
<author>
<name>Steven Rostedt</name>
</author>
<published>2014-06-19T01:15:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=27199b15e4f027e24969f6644ce4ff414c7e6cba'/>
<id>urn:sha1:27199b15e4f027e24969f6644ce4ff414c7e6cba</id>
<content type='text'>
There's no reason to include syscalls.h in keystore.c. Remove it.

Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Signed-off-by: Tyler Hicks &lt;tyhicks@canonical.com&gt;
</content>
</entry>
<entry>
<title>ecryptfs: Fix memory leakage in keystore.c</title>
<updated>2013-10-16T22:18:01Z</updated>
<author>
<name>Geyslan G. Bem</name>
</author>
<published>2013-10-11T19:49:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3edc8376c06133e3386265a824869cad03a4efd4'/>
<id>urn:sha1:3edc8376c06133e3386265a824869cad03a4efd4</id>
<content type='text'>
In 'decrypt_pki_encrypted_session_key' function:

Initializes 'payload' pointer and releases it on exit.

Signed-off-by: Geyslan G. Bem &lt;geyslan@gmail.com&gt;
Signed-off-by: Tyler Hicks &lt;tyhicks@canonical.com&gt;
Cc: stable@vger.kernel.org # v2.6.28+
</content>
</entry>
<entry>
<title>eCryptfs: allow userspace messaging to be disabled</title>
<updated>2013-03-04T07:59:59Z</updated>
<author>
<name>Kees Cook</name>
</author>
<published>2013-02-28T08:39:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=290502bee239062499297916bb7d21d205e99d62'/>
<id>urn:sha1:290502bee239062499297916bb7d21d205e99d62</id>
<content type='text'>
When the userspace messaging (for the less common case of userspace key
wrap/unwrap via ecryptfsd) is not needed, allow eCryptfs to build with
it removed. This saves on kernel code size and reduces potential attack
surface by removing the /dev/ecryptfs node.

Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Signed-off-by: Tyler Hicks &lt;tyhicks@canonical.com&gt;
</content>
</entry>
<entry>
<title>eCryptfs: decrypt_pki_encrypted_session_key(): remove kfree() redundant null check</title>
<updated>2013-02-12T18:06:01Z</updated>
<author>
<name>Tim Gardner</name>
</author>
<published>2013-02-12T17:56:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3a46741804a4226cd837d1246eed95d4161f7159'/>
<id>urn:sha1:3a46741804a4226cd837d1246eed95d4161f7159</id>
<content type='text'>
smatch analysis:

fs/ecryptfs/keystore.c:1206 decrypt_pki_encrypted_session_key() info:
 redundant null check on msg calling kfree()

Cc: Dustin Kirkland &lt;dustin.kirkland@gazzang.com&gt;
Cc: ecryptfs@vger.kernel.org
Signed-off-by: Tim Gardner &lt;tim.gardner@canonical.com&gt;
Signed-off-by: Tyler Hicks &lt;tyhicks@canonical.com&gt;
</content>
</entry>
</feed>
