From patchwork Thu Dec 15 07:27:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juerg Haefliger X-Patchwork-Id: 1716021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=rJoTsG/2; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NXkN23vfJz240d for ; Thu, 15 Dec 2022 18:27:44 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1p5ieG-0007R7-Qd; Thu, 15 Dec 2022 07:27:20 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1p5ieC-0007Pm-E5 for kernel-team@lists.ubuntu.com; Thu, 15 Dec 2022 07:27:16 +0000 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 272994432D for ; Thu, 15 Dec 2022 07:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1671089236; bh=YT7m3TuVMWhjMs/mGeMHuKY1o1j122UuQPQ+/G10NKM=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rJoTsG/2mSXxl9gVP5byikmLiGRBB6I5f9fzK18pMpGlrNrn8JTbqNCSUOcX/Thyp eAXgY0p+dE3+Wz0CEux+6eg0IhkKhUFBhxmwkTxwb/FXRSeJ+HhnP/38dEyuHUOokj BjxROCUmSOEJ2vudfUDmcc0D83W1TkVrBmi8FD48qNVJiSBYm10sflXPM4r0r8LAET XhjyStOR884gmlMhDV/+KoRgqG2PwcYrXkoMnt5ygnR2BQWM1GNqdmygvjEs7ZoNXj 4IiHq2lEdp+EyFlEXzaTO2EnUzReaS9Lqy2lOcWY8zUOVO/+UFX0fxAwCRMCqI3CkV SgJ0Wb6prtcnQ== Received: by mail-ed1-f72.google.com with SMTP id q10-20020a056402518a00b00472a255eef7so2425893edd.15 for ; Wed, 14 Dec 2022 23:27:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YT7m3TuVMWhjMs/mGeMHuKY1o1j122UuQPQ+/G10NKM=; b=2SxzpNopInZAONGhR8pBrpzGKaif2U2eLs5HZB0Tk0Ea92e50ZkQYxAe1JcrnP+BYa 2rIFJMP+pyN0Z4elo119vce2Io9TmYezqsaPRuo+J/sDEQEX/DArls3rsjEeLiyQE+H/ /ia1yQvv3B7lGPDh2zoy2Erb6Jm/bUzSchszjz0Ag+2dbv3qa8Quy081c3DQh6uhfNT3 goEwJQY2J2sDbenAsqK7uz23nycJC0hp8jcSWewVSVI4p4PdoOqr1cO9cBgpYqeXkxZ5 5cYOBZKeMJuZ0GEzN04RW4sfMllll4Uw1QOlWTw2B8QfYBt1PUxMMCGZwuw5xfANhaC+ 0eMQ== X-Gm-Message-State: ANoB5pnKXyLi1kc+sazarXnM6Y+arVvzXEV7OVPYneJHi5pAQsCRcO2V eF0Lp5g15DgpcWBteZwS5r3u8EUxW5TPbsTRFauo4SNp7qO+GgOfsZzUlj6Crsz0iPVvnVFry8S FHKy7eMXqmaoVUoT2ADG+KihmFGMjS63Y3ckBwJYo8A== X-Received: by 2002:a17:906:850d:b0:7c0:d886:b9ff with SMTP id i13-20020a170906850d00b007c0d886b9ffmr32887032ejx.16.1671089235135; Wed, 14 Dec 2022 23:27:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf5y7DeKJSyzPQ+MsQuadH2NObHCYKRRY3qL0nJ008fT2FnCjLVmpzK40QgrYFmRNIqBHBAfPA== X-Received: by 2002:a17:906:850d:b0:7c0:d886:b9ff with SMTP id i13-20020a170906850d00b007c0d886b9ffmr32887009ejx.16.1671089234937; Wed, 14 Dec 2022 23:27:14 -0800 (PST) Received: from gollum.fritz.box ([194.191.244.86]) by smtp.gmail.com with ESMTPSA id j18-20020a17090623f200b00782ee6b34f2sm6677910ejg.183.2022.12.14.23.27.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 23:27:14 -0800 (PST) From: Juerg Haefliger To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 5/6] UBUNTU: [Packaging] Introduce debian/scripts/sign-module Date: Thu, 15 Dec 2022 08:27:07 +0100 Message-Id: <20221215072708.466941-6-juerg.haefliger@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221215072708.466941-1-juerg.haefliger@canonical.com> References: <20221215072708.466941-1-juerg.haefliger@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1642368 Move the logic that determines if a module needs to be signed to a script and extend it to also check the signature-inclusion list of derivatives. Signed-off-by: Juerg Haefliger Signed-off-by: Andrea Righi (cherry picked from commit 2ce8907f20c3691096e27ea9ae18dd17e5c4f63c kinetic:linux) Signed-off-by: Juerg Haefliger --- debian/scripts/sign-module | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 debian/scripts/sign-module diff --git a/debian/scripts/sign-module b/debian/scripts/sign-module new file mode 100755 index 000000000000..03ce543de7f8 --- /dev/null +++ b/debian/scripts/sign-module @@ -0,0 +1,40 @@ +#!/bin/bash -eu +# +# Staging drivers must not be signed if they are not listed in a +# signature-inclusion file to prevent loading of 'unsafe' drivers in a +# Secure Boot environment. +# +# Exit with status 0 if the provided module needs to be signed, 1 otherwise +# + +mod=${1} + +# Sign the module if not a staging driver +if [ "${mod/\/drivers\/staging\//}" = "${mod}" ] ; then + exit 0 +fi + +root=$(dirname "$(realpath -e "${0}")")/../.. +. "${root}"/debian/debian.env + +# Collect the signature-inclusion files +sig_incls=() +for d in debian "${DEBIAN}" ; do + if [ -f "${root}"/"${d}"/signature-inclusion ] ; then + sig_incls+=("${root}"/"${d}"/signature-inclusion) + fi +done + +# Sign the module if no signature-inclusion files +if [ ${#sig_incls[@]} -eq 0 ] ; then + exit 0 +fi + +# Sign the module if listed in signature-inclusion files +if grep -qFx "${mod##*/}" "${sig_incls[@]}" ; then + exit 0 +fi + +# Don't sign the module +echo "UBUNTU: Not signing ${1}" +exit 1