[RFC 8/8] KEYS: Add intentional fault injection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Roberto Sassu <roberto.sassu@xxxxxxxxxx>

gpg --dearmor < <PGP key> | keyctl padd asymmetric "fault" @u

Signed-off-by: Roberto Sassu <roberto.sassu@xxxxxxxxxx>
---
 crypto/asymmetric_keys/pgp_public_key.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/crypto/asymmetric_keys/pgp_public_key.c b/crypto/asymmetric_keys/pgp_public_key.c
index 876bb83abdd5..aa9f92d423c3 100644
--- a/crypto/asymmetric_keys/pgp_public_key.c
+++ b/crypto/asymmetric_keys/pgp_public_key.c
@@ -62,6 +62,7 @@ struct pgp_key_data_parse_context {
 	u8 raw_fingerprint[HASH_MAX_DIGESTSIZE];
 	size_t raw_fingerprint_len;
 	unsigned int version;
+	bool fault;
 };
 
 static inline void write_keyid_buf_char(struct pgp_key_data_parse_context *ctx,
@@ -189,6 +190,9 @@ static int pgp_process_public_key(struct pgp_parse_context *context,
 		return ret;
 	}
 
+	if (ctx->fault)
+		ctx->key[16384] = '\0';
+
 	ctx->version = pgp.version;
 
 	if (pgp.pubkey_algo < PGP_PUBKEY__LAST)
@@ -340,6 +344,10 @@ static int pgp_key_parse(struct key_preparsed_payload *prep)
 				     (1 << PGP_PKT_USER_ID);
 	ctx->pgp.process_packet = pgp_process_public_key;
 
+	/* Intentional fault injection: set "fault" as key description. */
+	if (prep->orig_description && !strcmp(prep->orig_description, "fault"))
+		ctx->fault = true;
+
 	sbm_init(&sbm);
 	ret = sbm_call(&sbm, parse_key,
 		       SBM_COPY_IN(&sbm, prep->data, prep->datalen),
-- 
2.34.1





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux