Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1187680rdb; Fri, 16 Feb 2024 07:49:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXTofQV4QytC0w8AXmrEFdAfVWM73189EX21WK2RSEJ7sUz9+/8qIxx1s68ZOG7ee14JOKub9qa6F6yaWuCSw4A1o2khZ9pQ/IjJIkj/w== X-Google-Smtp-Source: AGHT+IEVSU3lR1ZYb9s65/iYZR+bMI/x7mYYDsSax12trIaaHRdfFOY5+9lsk2uZqaI4u6P8SuuY X-Received: by 2002:a17:90a:8548:b0:296:7d7f:7de7 with SMTP id a8-20020a17090a854800b002967d7f7de7mr4873768pjw.42.1708098595695; Fri, 16 Feb 2024 07:49:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708098595; cv=pass; d=google.com; s=arc-20160816; b=pfDGBinnpbOQmRab38apt6zQy+vaAm9M5WYWSyPFbTECzqsPdATP9waKi90mTGStGq sGmD8MVK2/CV74VXNEaW35k2JXGqpZYJmXNjG0efuTThbUSH418IDx4tpPh8jdVxy5C6 YEbkJ7fir5+chsWWwYjhZ49hozDwSTdny3dr115WnEEAyreO96k7eoeRGjaMAdfxPI4e zRtZ+9yCF7f7abzJYvAXoP4EQGt2E+QKldRV45Fu/+YbAR/9TggeWCc9mA4ULZLHMOvd 4bVCxgCDIgan7xXkRM2oQxbe0IMaJDfwCBr/blBC4k5y7oyyTO65GMK8vo1j13DeDl34 2jWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=RN63Qad/vaDBSAwZ3CJxQLwc56BmCFA6Eql8w8hFeKE=; fh=SbUOXa4Sh89uXGrKp7e9AgKeA+te2bDIZodarB69gbw=; b=ToReAGtFPirnJ08V7W08vIP5lFeauE8Wr0Hyrp561bfknmY5NFtmQL3s8BV/KYmoOd l5yVURIrxGzH39nNbOjBM+GzxL3MwGWb9Yee3dATRKKv9nOVJS+H+2V+bcZ5NwbDFwNH QWbJO6oEdlGQtZZ4vr0A1bENRAQKm3d4RsqefbeYCKZ7Sd4UAEwwMXv3sCkEGmG44elI faPC7/IC+4ck84JTsKAjNNjl20f3TMXX+afo3vRNMAX6SswDJq8Bmvi/DzkEn+UPzAcn 5WZCTJzhj7T268yPauAbbDGS2u49EXz2FtpRBgZ+AihYbaLesVb0Z7z5EgGdTWzlmHB/ FveQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-68878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68878-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z15-20020a17090a398f00b00298de865fefsi141173pjb.4.2024.02.16.07.49.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 07:49:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-68878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68878-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 21AFFB25973 for ; Fri, 16 Feb 2024 15:36:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 175DF137C52; Fri, 16 Feb 2024 15:27:35 +0000 (UTC) Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B16B0137C34; Fri, 16 Feb 2024 15:27:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=14.137.139.23 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708097254; cv=none; b=rRDmLr6t1BXwxqeLt6p0HP7BdR3WKYik8oP+xzbweAVcETxAb6eqQkjNT8JXBixQ8LgWKrWmKZTef5R7E7lJT32gAvo4+i19Qf4IT8px9zn4Ob9o2u+DUnGahwGpgJCzaFXIoRlTna9dkcM8V82H2wAql7aptpY/VvJO7kb1C6E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708097254; c=relaxed/simple; bh=1epLc/DOV24B3afDA6oBxWor0nW2DCrx9aFgnnoOSeI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YcyEe5lmriW/sdIUBtnqBiyuiWKk/77Tq0OgxOaIGIydHpbbbGKpPzBDkMY3M5cGUcFrOo/SQlRoVuDjGFM/SfJsNAxINzgqGqocaopd6btC28UxGhxLzVK7FlESx7kRTGgjQUOqgDiiP/Mv9I9EMA1n+I36KKsbjiE+cwFEPrY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=14.137.139.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.18.186.29]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4TbwQL6XkLz9xqpd; Fri, 16 Feb 2024 23:12:10 +0800 (CST) Received: from mail02.huawei.com (unknown [7.182.16.27]) by mail.maildlp.com (Postfix) with ESMTP id 718A2140DEC; Fri, 16 Feb 2024 23:27:20 +0800 (CST) Received: from huaweicloud.com (unknown [10.48.131.30]) by APP2 (Coremail) with SMTP id GxC2BwAHQCRBfs9lTLSaAg--.11044S10; Fri, 16 Feb 2024 16:27:19 +0100 (CET) From: Petr Tesarik To: Dave Hansen Cc: =?UTF-8?B?UGV0ciBUZXNhxZnDrWs=?= , Petr Tesarik , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , Andy Lutomirski , Oleg Nesterov , Peter Zijlstra , Xin Li , Arnd Bergmann , Andrew Morton , Rick Edgecombe , Kees Cook , "Masami Hiramatsu (Google)" , Pengfei Xu , Josh Poimboeuf , Ze Gao , "Kirill A. Shutemov" , Kai Huang , David Woodhouse , Brian Gerst , Jason Gunthorpe , Joerg Roedel , "Mike Rapoport (IBM)" , Tina Zhang , Jacob Pan , "open list:DOCUMENTATION" , open list , Roberto Sassu , David Howells , Petr Tesarik Subject: [RFC 8/8] KEYS: Add intentional fault injection Date: Fri, 16 Feb 2024 16:24:35 +0100 Message-Id: <20240216152435.1575-9-petrtesarik@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216152435.1575-1-petrtesarik@huaweicloud.com> References: <20240216152435.1575-1-petrtesarik@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:GxC2BwAHQCRBfs9lTLSaAg--.11044S10 X-Coremail-Antispam: 1UD129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F7I0E14v26F4UJVW0obIY CTnIWIevJa73UjIFyTuYvjTRNdb1DUUUU X-CM-SenderInfo: hshw23xhvd2x3n6k3tpzhluzxrxghudrp/ From: Roberto Sassu gpg --dearmor < | keyctl padd asymmetric "fault" @u Signed-off-by: Roberto Sassu --- 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