[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240216152435.1575-9-petrtesarik@huaweicloud.com>
Date: Fri, 16 Feb 2024 16:24:35 +0100
From: Petr Tesarik <petrtesarik@...weicloud.com>
To: Dave Hansen <dave.hansen@...el.com>
Cc: Petr Tesařík <petr@...arici.cz>,
Petr Tesarik <petrtesarik@...weicloud.com>,
Jonathan Corbet <corbet@....net>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>,
Andy Lutomirski <luto@...nel.org>,
Oleg Nesterov <oleg@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Xin Li <xin3.li@...el.com>,
Arnd Bergmann <arnd@...db.de>,
Andrew Morton <akpm@...ux-foundation.org>,
Rick Edgecombe <rick.p.edgecombe@...el.com>,
Kees Cook <keescook@...omium.org>,
"Masami Hiramatsu (Google)" <mhiramat@...nel.org>,
Pengfei Xu <pengfei.xu@...el.com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Ze Gao <zegao2021@...il.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Kai Huang <kai.huang@...el.com>,
David Woodhouse <dwmw@...zon.co.uk>,
Brian Gerst <brgerst@...il.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Joerg Roedel <jroedel@...e.de>,
"Mike Rapoport (IBM)" <rppt@...nel.org>,
Tina Zhang <tina.zhang@...el.com>,
Jacob Pan <jacob.jun.pan@...ux.intel.com>,
"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>,
Roberto Sassu <roberto.sassu@...weicloud.com>,
David Howells <dhowells@...hat.com>,
Petr Tesarik <petr.tesarik1@...wei-partners.com>
Subject: [RFC 8/8] KEYS: Add intentional fault injection
From: Roberto Sassu <roberto.sassu@...wei.com>
gpg --dearmor < <PGP key> | keyctl padd asymmetric "fault" @u
Signed-off-by: Roberto Sassu <roberto.sassu@...wei.com>
---
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
Powered by blists - more mailing lists