Skip to content

Commit 3584c1d

Browse files
frozencemeterydhowells
authored andcommitted
asymmetric_keys: log on fatal failures in PE/pkcs7
These particular errors can be encountered while trying to kexec when secureboot lockdown is in place. Without this change, even with a signed debug build, one still needs to reboot the machine to add the appropriate dyndbg parameters (since lockdown blocks debugfs). Accordingly, upgrade all pr_debug() before fatal error into pr_warn(). Signed-off-by: Robbie Harwood <[email protected]> Signed-off-by: David Howells <[email protected]> cc: Jarkko Sakkinen <[email protected]> cc: Eric Biederman <[email protected]> cc: Herbert Xu <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] Link: https://lore.kernel.org/r/[email protected]/ # v2
1 parent 4fc5c74 commit 3584c1d

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

crypto/asymmetric_keys/pkcs7_verify.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ static int pkcs7_digest(struct pkcs7_message *pkcs7,
7979
}
8080

8181
if (sinfo->msgdigest_len != sig->digest_size) {
82-
pr_debug("Sig %u: Invalid digest size (%u)\n",
83-
sinfo->index, sinfo->msgdigest_len);
82+
pr_warn("Sig %u: Invalid digest size (%u)\n",
83+
sinfo->index, sinfo->msgdigest_len);
8484
ret = -EBADMSG;
8585
goto error;
8686
}
8787

8888
if (memcmp(sig->digest, sinfo->msgdigest,
8989
sinfo->msgdigest_len) != 0) {
90-
pr_debug("Sig %u: Message digest doesn't match\n",
91-
sinfo->index);
90+
pr_warn("Sig %u: Message digest doesn't match\n",
91+
sinfo->index);
9292
ret = -EKEYREJECTED;
9393
goto error;
9494
}
@@ -478,7 +478,7 @@ int pkcs7_supply_detached_data(struct pkcs7_message *pkcs7,
478478
const void *data, size_t datalen)
479479
{
480480
if (pkcs7->data) {
481-
pr_debug("Data already supplied\n");
481+
pr_warn("Data already supplied\n");
482482
return -EINVAL;
483483
}
484484
pkcs7->data = data;

crypto/asymmetric_keys/verify_pefile.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int pefile_parse_binary(const void *pebuf, unsigned int pelen,
7474
break;
7575

7676
default:
77-
pr_debug("Unknown PEOPT magic = %04hx\n", pe32->magic);
77+
pr_warn("Unknown PEOPT magic = %04hx\n", pe32->magic);
7878
return -ELIBBAD;
7979
}
8080

@@ -95,7 +95,7 @@ static int pefile_parse_binary(const void *pebuf, unsigned int pelen,
9595
ctx->certs_size = ddir->certs.size;
9696

9797
if (!ddir->certs.virtual_address || !ddir->certs.size) {
98-
pr_debug("Unsigned PE binary\n");
98+
pr_warn("Unsigned PE binary\n");
9999
return -ENODATA;
100100
}
101101

@@ -127,7 +127,7 @@ static int pefile_strip_sig_wrapper(const void *pebuf,
127127
unsigned len;
128128

129129
if (ctx->sig_len < sizeof(wrapper)) {
130-
pr_debug("Signature wrapper too short\n");
130+
pr_warn("Signature wrapper too short\n");
131131
return -ELIBBAD;
132132
}
133133

@@ -142,16 +142,16 @@ static int pefile_strip_sig_wrapper(const void *pebuf,
142142
* rounded up since 0.110.
143143
*/
144144
if (wrapper.length > ctx->sig_len) {
145-
pr_debug("Signature wrapper bigger than sig len (%x > %x)\n",
146-
ctx->sig_len, wrapper.length);
145+
pr_warn("Signature wrapper bigger than sig len (%x > %x)\n",
146+
ctx->sig_len, wrapper.length);
147147
return -ELIBBAD;
148148
}
149149
if (wrapper.revision != WIN_CERT_REVISION_2_0) {
150-
pr_debug("Signature is not revision 2.0\n");
150+
pr_warn("Signature is not revision 2.0\n");
151151
return -ENOTSUPP;
152152
}
153153
if (wrapper.cert_type != WIN_CERT_TYPE_PKCS_SIGNED_DATA) {
154-
pr_debug("Signature certificate type is not PKCS\n");
154+
pr_warn("Signature certificate type is not PKCS\n");
155155
return -ENOTSUPP;
156156
}
157157

@@ -164,7 +164,7 @@ static int pefile_strip_sig_wrapper(const void *pebuf,
164164
ctx->sig_offset += sizeof(wrapper);
165165
ctx->sig_len -= sizeof(wrapper);
166166
if (ctx->sig_len < 4) {
167-
pr_debug("Signature data missing\n");
167+
pr_warn("Signature data missing\n");
168168
return -EKEYREJECTED;
169169
}
170170

@@ -198,7 +198,7 @@ static int pefile_strip_sig_wrapper(const void *pebuf,
198198
return 0;
199199
}
200200
not_pkcs7:
201-
pr_debug("Signature data not PKCS#7\n");
201+
pr_warn("Signature data not PKCS#7\n");
202202
return -ELIBBAD;
203203
}
204204

@@ -341,8 +341,8 @@ static int pefile_digest_pe(const void *pebuf, unsigned int pelen,
341341
digest_size = crypto_shash_digestsize(tfm);
342342

343343
if (digest_size != ctx->digest_len) {
344-
pr_debug("Digest size mismatch (%zx != %x)\n",
345-
digest_size, ctx->digest_len);
344+
pr_warn("Digest size mismatch (%zx != %x)\n",
345+
digest_size, ctx->digest_len);
346346
ret = -EBADMSG;
347347
goto error_no_desc;
348348
}
@@ -373,7 +373,7 @@ static int pefile_digest_pe(const void *pebuf, unsigned int pelen,
373373
* PKCS#7 certificate.
374374
*/
375375
if (memcmp(digest, ctx->digest, ctx->digest_len) != 0) {
376-
pr_debug("Digest mismatch\n");
376+
pr_warn("Digest mismatch\n");
377377
ret = -EKEYREJECTED;
378378
} else {
379379
pr_debug("The digests match!\n");

0 commit comments

Comments
 (0)