[PATCH 4.9 31/48] pkcs7: Prevent NULL pointer dereference, since sinfo is not always set.

From: Greg Kroah-Hartman
Date: Tue Oct 24 2017 - 09:37:26 EST


4.9-stable review patch. If anyone has any objections, please let me know.

------------------

From: Eric Sesterhenn <eric.sesterhenn@xxxxxxxxxxx>

commit 68a1fdbbf8bd3378325e45c19e167a165f9ffc3a upstream.

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@xxxxxxxxxxx>
Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
crypto/asymmetric_keys/pkcs7_parser.c | 3 +++
1 file changed, 3 insertions(+)

--- a/crypto/asymmetric_keys/pkcs7_parser.c
+++ b/crypto/asymmetric_keys/pkcs7_parser.c
@@ -88,6 +88,9 @@ static int pkcs7_check_authattrs(struct
bool want = false;

sinfo = msg->signed_infos;
+ if (!sinfo)
+ goto inconsistent;
+
if (sinfo->authattrs) {
want = true;
msg->have_authattrs = true;