Linux Kernels

pkcs7: Prevent NULL pointer dereference, since sinfo is not always set.

This change “pkcs7: Prevent NULL pointer dereference, since sinfo is not always set.” (commit 68a1fdb) in Linux kernel is authored by Eric Sesterhenn <eric.sesterhenn [at] x41-dsec.de> on Sun Oct 8 20:02:32 2017 +0200.

Description of "pkcs7: Prevent NULL pointer dereference, since sinfo is not always set."

The change “pkcs7: Prevent NULL pointer dereference, since sinfo is not always set.” introduces changes as follows.

pkcs7: Prevent NULL pointer dereference, since sinfo is not always set.

The ASN.1 parser does not necessarily set the sinfo field,
this patch prevents a NULL pointer dereference on broken
input.

Fixes: 99db44350672 ("PKCS#7: Appropriately restrict authenticated attributes and content type")
Signed-off-by: Eric Sesterhenn <eric.sesterhenn@x41-dsec.de>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: stable@vger.kernel.org # 4.3+

Linux kernel releases containing commit 68a1fdb

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "pkcs7: Prevent NULL pointer dereference, since sinfo is not always set."

There are 3 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 crypto/asymmetric_keys/pkcs7_parser.c | 3 +++
 1 file changed, 3 insertions(+)
 
diff --git a/crypto/asymmetric_keys/pkcs7_parser.c b/crypto/asymmetric_keys/pkcs7_parser.c
index af4cd8649117..d140d8bb2c96 100644
--- a/crypto/asymmetric_keys/pkcs7_parser.c
+++ b/crypto/asymmetric_keys/pkcs7_parser.c
@@ -88,6 +88,9 @@ static int pkcs7_check_authattrs(struct pkcs7_message *msg)
 	bool want = false;
 
 	sinfo = msg->signed_infos;
+	if (!sinfo)
+		goto inconsistent;
+
 	if (sinfo->authattrs) {
 		want = true;
 		msg->have_authattrs = true;

The commit for this change in Linux stable tree is 68a1fdb (patch).

Last modified: 2020/01/11 09:46