From patchwork Thu Jul 22 09:17:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ahmad Fatoum X-Patchwork-Id: 12393519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6199BC63798 for ; Thu, 22 Jul 2021 09:18:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 474196101B for ; Thu, 22 Jul 2021 09:18:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231406AbhGVIiB (ORCPT ); Thu, 22 Jul 2021 04:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231350AbhGVIhz (ORCPT ); Thu, 22 Jul 2021 04:37:55 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DC2FC061575 for ; Thu, 22 Jul 2021 02:18:30 -0700 (PDT) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m6UqE-0001NK-VX; Thu, 22 Jul 2021 11:18:06 +0200 Received: from afa by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1m6UqC-0001Ch-DB; Thu, 22 Jul 2021 11:18:04 +0200 From: Ahmad Fatoum To: David Howells , Jarkko Sakkinen , James Morris , "Serge E. Hallyn" , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Song Liu , Richard Weinberger Cc: kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-mtd@lists.infradead.org, linux-security-module@vger.kernel.org Subject: [RFC PATCH v1 0/4] keys: introduce key_extract_material helper Date: Thu, 22 Jul 2021 11:17:58 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: afa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-integrity@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org While keys of differing type have a common struct key definition, there is no common scheme to the payload and key material extraction differs. For kernel functionality that supports different key types, this means duplicated code for key material extraction and because key type is discriminated by a pointer to a global, users need to replicate reachability checks as well, so builtin code doesn't depend on a key type symbol offered by a module. Make this easier by adding a common helper with initial support for user, logon, encrypted and trusted keys. This series contains two example of its use: dm-crypt uses it to reduce boilerplate and ubifs authentication uses it to gain support for trusted and encrypted keys alongside the already supported logon keys. Looking forward to your feedback, Ahmad --- To: David Howells To: Jarkko Sakkinen To: James Morris To: "Serge E. Hallyn" To: Alasdair Kergon To: Mike Snitzer To: dm-devel@redhat.com To: Song Liu To: Richard Weinberger Cc: linux-kernel@vger.kernel.org Cc: linux-raid@vger.kernel.org Cc: linux-integrity@vger.kernel.org Cc: keyrings@vger.kernel.org Cc: linux-mtd@lists.infradead.org Cc: linux-security-module@vger.kernel.org Ahmad Fatoum (4): keys: introduce key_extract_material helper dm: crypt: use new key_extract_material helper ubifs: auth: remove never hit key type error check ubifs: auth: consult encrypted and trusted keys if no logon key was found Documentation/filesystems/ubifs.rst | 2 +- drivers/md/dm-crypt.c | 65 ++++-------------------------- fs/ubifs/auth.c | 25 +++++------- include/linux/key.h | 45 +++++++++++++++++++++- security/keys/key.c | 40 ++++++++++++++++++- 5 files changed, 107 insertions(+), 70 deletions(-) base-commit: 2734d6c1b1a089fb593ef6a23d4b70903526fe0c