From patchwork Mon Oct 4 13:35:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1536112 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=vCfI/+U6; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNMDg4WHHz9t54 for ; Tue, 5 Oct 2021 00:36:03 +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 1mXO8M-00010K-2I; Mon, 04 Oct 2021 13:35:58 +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 1mXO8J-0000zc-Ru for kernel-team@lists.ubuntu.com; Mon, 04 Oct 2021 13:35:55 +0000 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.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 AA1BD405F1 for ; Mon, 4 Oct 2021 13:35:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1633354555; bh=ZpDhIxm6gCTTn+rw+IDnM74OsINRY1NSVh+E6/zkP9Q=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=vCfI/+U6SljIlFjkJLEc/vvyyIjnGQs90so21ZfwkwLuJdr1SZKaB3+RooasAv3hc JC43R/4Jkc4G69UPZRNqD9ykfgd95TuSbT4rAFb3Z2uQJ1b+O6UCAJzKIRfn6IlK9M mnn2fZQdi2a7BzNJAvkTxsXDsQUi8bUNkTOs1X0FBY+iWEY0wVttNPGDUDIPrKt0Nq 4mzrfbBulBqRn3pBxkok1/OAP+/Y+cCU4BydO7D6Jh2aZZ5KhTG06RCRUwUSQbKrpa O3EGeMIp2foPb2NmcLLHne9juBWijpGPf/EgUsvKb7KDJ4bNDGOzFvH8pB109NxHsP O3EcxXHnCtYvA== Received: by mail-qv1-f72.google.com with SMTP id z6-20020a056214060600b0037a3f6bd9abso18379046qvw.3 for ; Mon, 04 Oct 2021 06:35:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZpDhIxm6gCTTn+rw+IDnM74OsINRY1NSVh+E6/zkP9Q=; b=OPAeKBJjQZxJO5ggWwcvYS6jXkMGgk/2QIXqxCMHdfV+1fLqBZ0iY6IWNgKeYx67KY MN+6fYyQgouzTfr1kHS1QEMMQRnSd8Oq5lUdagCvc73/ZfZI2i0nzOSEWwzVgiag+mEf L4FwzB8UGbZ1XVzL3nn2UahntuUtlxw3Zd+Dc7lwPmS51Be2KrdpIsE6eU3BdQEiePbe FKHxMV4eDfiN1mxEineMRpQYzQcm7a6B4WbOjtyfzX/Bc27l6FwFwYl8qrcaPEBhQv4i CvfNqzBOuOAvrkr/Uhz7mOzvf6WQ+eQAQvqD57wvY8DHoq1ksDWnxww1b/EaOF9GbRQu 9ssw== X-Gm-Message-State: AOAM532MQOHK604CuuFoVh9PSyL20lNU5JZe5ApYbmZ0Pf4dLGDOoUoD odUwnCq4m2BylNs6bTRqGk9eHsEfP7aJuJFoUtRDQ/IXSGwKAW6dMpdoN/gIrtW+9WlS7zNnDnh nWTyq4Y3JXzyBER7CkZ8iOD7Rf1ZObY/1EtVUnsMQ X-Received: by 2002:a05:622a:181:: with SMTP id s1mr13771562qtw.47.1633354554393; Mon, 04 Oct 2021 06:35:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV3aXmvyLtI4HFEaoeyid2m473llhYBqCKdzsUbPTKV/fXHRnQnsHkV+5C5ZA+Bo+tQpamgA== X-Received: by 2002:a05:622a:181:: with SMTP id s1mr13771515qtw.47.1633354554023; Mon, 04 Oct 2021 06:35:54 -0700 (PDT) Received: from valinor.lan ([177.95.46.212]) by smtp.gmail.com with ESMTPSA id f5sm8437400qtp.44.2021.10.04.06.35.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 06:35:53 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [B,F,I][PATCH 1/2] UBUNTU: [Packaging] Add a new fips-checks script Date: Mon, 4 Oct 2021 10:35:46 -0300 Message-Id: <20211004133548.2168392-2-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004133548.2168392-1-marcelo.cerri@canonical.com> References: <20211004133548.2168392-1-marcelo.cerri@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/1945989 Add a new script responsible for checking if any FIPS relevant commit was added since the last version. If a new change is found, a corresponding entry should exist in the justifications file otherwise the check will fail. The justifications file is located at "${DEBIAN}/fips.justifications" and should follow the following format for each commit justification: Signed-off-by: Marcelo Henrique Cerri Acked-by: Tim Gardner --- debian/scripts/misc/fips-checks | 138 ++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100755 debian/scripts/misc/fips-checks diff --git a/debian/scripts/misc/fips-checks b/debian/scripts/misc/fips-checks new file mode 100755 index 000000000000..9dadd3939a62 --- /dev/null +++ b/debian/scripts/misc/fips-checks @@ -0,0 +1,138 @@ +#!/bin/bash -eu +export LC_ALL=C.UTF-8 + +usage() { + cat << EOF +Usage: ${P:-$(basename "$0")} [-h|--help] + +Check if there are any FIPS relevant changes since the last +release. Any change that is identified should have a justification in +the justifications file or the check will fail. + +Optional arguments: + -h, --help Show this help message and exit. + -p, --previous Version to use as the previous base version. + -c, --current Version to use as the current base version. + +EOF +} + +prev_base_version= +curr_base_version= +crypto_files=( crypto arch/x86/crypto drivers/char/random.c lib/sha\* ) + +c_red='\033[0;31m' +c_green='\033[0;32m' +c_off='\033[0m' + +# Parse arguments +while [ "$#" -gt 0 ]; do + case "$1" in + -h|--help) + usage + exit 0 + ;; + -p|--previous) + shift + prev_base_version="$1" + ;; + -c|--current) + shift + curr_base_version="$1" + ;; + *) + usage + exit 1 + ;; + esac + shift +done + +DEBIAN= +# shellcheck disable=SC1091 +. debian/debian.env + +# Check if the "$DEBIAN" directory exists. +if [ ! -d "$DEBIAN" ]; then + echo "You must run this script from the top directory of this repository." + exit 1 +fi + +CONF="$DEBIAN/etc/update.conf" +if [ ! -f "$CONF" ]; then + echo "Missing file: $CONF" + exit 1 +fi +# shellcheck disable=SC1090 +. "$CONF" + +if [ "$DEBIAN_MASTER" = "" ]; then + echo "DEBIAN_MASTER should be defined either in $DEBIAN/etc/update.conf or the environment" + exit 1 +fi + +# Find the base kernel version use by the previous version +if [ -z "$prev_base_version" ]; then + offset=1 + # Loop through each entry of the current changelog, searching for an + # entry that refers to the master version used as base (ie a line + # containing "[ Ubuntu: 4.15.0-39.42 ]"): + while true; do + changes=$(dpkg-parsechangelog -l"$DEBIAN/changelog" -SChanges -c1 -o"$offset") + if ! [ "$changes" ]; then + echo "Failed to retrieve base master version from changelog file: $DEBIAN/changelog" + exit 1 + fi + prev_base_version=$(echo "$changes" | sed -n -r -e '/^\s.*\[ Ubuntu: ([~0-9.-]*) \]$/{s//\1/p;q}') + [ "$prev_base_version" ] && break + offset=$(( offset + 1 )) + done + if [ -z "${prev_base_version}" ]; then + echo "Failed to retrieve base version from previous version from changelog: $DEBIAN/changelog" + exit 1 + fi +fi + +# Find the current base kernel version +if [ -z "$curr_base_version" ]; then + curr_base_version=$(dpkg-parsechangelog -l"${DEBIAN_MASTER}/changelog" -SVersion) + if ! [ "$curr_base_version" ]; then + echo "Failed to retrieve current master version from changelog: $DEBIAN_MASTER/changelog" + exit 1 + fi +fi + +# Check base kernel tags +tag_prefix="Ubuntu-${DEBIAN_MASTER#debian.}-" +prev_tag="${tag_prefix}${prev_base_version}" +curr_tag="${tag_prefix}${curr_base_version}" +for tag in "$prev_tag" "$curr_tag"; do + if ! git rev-parse --verify "$tag" &> /dev/null; then + echo "Missing tag \"$tag\". Please fetch tags from base kernel." + exit 1 + fi +done + +# Check all the changes +fails=0 +justifications_file="$DEBIAN/fips.justifications" +justifications=$(grep -P '^[^#\s]' "$justifications_file" 2> /dev/null || true) +while read -r id; do + short_msg=$(git log --format=%s --max-count=1 "$id") + if echo "$justifications" | grep -q -x -F "$short_msg"; then + echo -e "${c_green}OK${c_off} | ${id::12} ${short_msg}" + continue + fi + echo -e "${c_red}FAIL${c_off} | ${id::12} ${short_msg}" + fails=$(( fails + 1 )) +done < <(git rev-list "${prev_tag}..${curr_tag}" -- "${crypto_files[@]}") + +echo +if [ "$fails" -gt 0 ]; then + echo "FIPS relevant changes were found without justification: ${fails} change(s)." + echo "Please, check the commits above and update the file \"${justifications_file}\"." + exit 1 +fi + +echo "Check completed without errors." +exit 0 From patchwork Mon Oct 4 13:35:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1536113 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=BH86xUEH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNMDj13bTz9t54 for ; Tue, 5 Oct 2021 00:36:05 +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 1mXO8N-00011F-7p; Mon, 04 Oct 2021 13:35:59 +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 1mXO8L-000107-6I for kernel-team@lists.ubuntu.com; Mon, 04 Oct 2021 13:35:57 +0000 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (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 ECA0A405F1 for ; Mon, 4 Oct 2021 13:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1633354556; bh=BXc34x1nj9ZqIzv5xjMNLa/u9dXVPF40z6sOmZhwhE4=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BH86xUEHrG0PhJ1R7wkKRHnPJGDQU1SmXBG2j3YcdMbYggaFR9PTPzRqW9GYG6u3O citbu3Kj92ZudMtq29hF2+TAI6zbWR2rihgxfZj12/t+GELDyJZL5QM5pn4+sFy68s jSAhr016mO+5Q4n8VopD0jw+0vXC05yj/uGFMxqJ0bZAaIv91lsNd2EOZzJN0zKqbZ wojjZTKULSnXn9qsHydH51oNOsKsSDcX0z4AySUdZnWpfGYXmpYkDcDeYaElNqwoUm fDyrqI3Dh+/AM0IZUtkVTxj9/etHLrezkT1Njoag134IfyjJkyEnadj3gEet8kE0KI 9fjWUlPhjHTsw== Received: by mail-qk1-f197.google.com with SMTP id b189-20020a3799c6000000b0045eb0c29072so5214471qke.12 for ; Mon, 04 Oct 2021 06:35:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BXc34x1nj9ZqIzv5xjMNLa/u9dXVPF40z6sOmZhwhE4=; b=y+ALdu3MrudatDGuCnB28h5qrMxvGIGoP2KUSpKxd3iXr0/x9EoFO62sTEjSAwp7o1 soZFb1DgOSW7UE45kHrr6D/EBrtrVqH+V89YhVg8pAYGBimdFptake+puj/qI8jaf2/p UMJLeahw5buCarllKmQavgnvw2++aPYRKvh6nx1vduyCbyqJkX4WwsBjq6CcTYGBMB+U 7jFuiOUQszoPIAeT0ho2gAvn6nqDpLM2JcgcJ/scOB0LQuoa1vnToSIjhTTUDRLSK2XA 5x/Ea9GsxX+3/nWPL4FFJKrYFQA5TXLN+CxYic1q8ujirQe2ryLj030YS8vyQ6pajDEa KZoA== X-Gm-Message-State: AOAM530f7R5yPogyldN8aBbsPHqT2sldWWzkFzrqdgPjUgfbbyvynS3F Exi4uugqpMLLdAZZihChpu3hHTEbezB/E4k1HGupF9/DACe+4ItrlOT78ykdREcC4R8TY/kBWTg yHoikLTFepUAOBHpaFPOEqiU6zxp4UzOmlg916Jhs X-Received: by 2002:aed:27d9:: with SMTP id m25mr13583500qtg.85.1633354555728; Mon, 04 Oct 2021 06:35:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQgKlNgCmolYQOXuNINgzgOZrYs4Xao/RucHGTD1wW3UquZkYd55WjledEPzFRhD2rLhKnFQ== X-Received: by 2002:aed:27d9:: with SMTP id m25mr13583469qtg.85.1633354555439; Mon, 04 Oct 2021 06:35:55 -0700 (PDT) Received: from valinor.lan ([177.95.46.212]) by smtp.gmail.com with ESMTPSA id f5sm8437400qtp.44.2021.10.04.06.35.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 06:35:54 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [B][PATCH 2/2] UBUNTU: [Packaging] Add fips-checks as part of finalchecks Date: Mon, 4 Oct 2021 10:35:47 -0300 Message-Id: <20211004133548.2168392-3-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004133548.2168392-1-marcelo.cerri@canonical.com> References: <20211004133548.2168392-1-marcelo.cerri@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/1945989 Call fips-checks as part of the debian target "finalchecks". That will ensure the checks are executed during build and during cranky close. Kernels need to enable this check via do_fips_checks. Signed-off-by: Marcelo Henrique Cerri --- debian/rules.d/0-common-vars.mk | 3 +++ debian/rules.d/1-maintainer.mk | 3 +++ 2 files changed, 6 insertions(+) diff --git a/debian/rules.d/0-common-vars.mk b/debian/rules.d/0-common-vars.mk index 2e3ed3818c98..84057c37d378 100644 --- a/debian/rules.d/0-common-vars.mk +++ b/debian/rules.d/0-common-vars.mk @@ -205,6 +205,9 @@ do_flavour_header_package=true # DTBs do_dtbs=false +# FIPS check +do_fips_checks=false + # Support parallel= in DEB_BUILD_OPTIONS (see #209008) # # These 2 environment variables set the -j value of the kernel build. For example, diff --git a/debian/rules.d/1-maintainer.mk b/debian/rules.d/1-maintainer.mk index b32efbfc4f29..6d8700d8143d 100644 --- a/debian/rules.d/1-maintainer.mk +++ b/debian/rules.d/1-maintainer.mk @@ -125,6 +125,9 @@ autoreconstruct: $(DROOT)/scripts/misc/gen-auto-reconstruct $(upstream_tag) $(DEBIAN)/reconstruct $(DROOT)/source/options finalchecks: +ifeq ($(do_fips_checks),true) + $(DROOT)/scripts/misc/fips-checks +endif $(DROOT)/scripts/misc/final-checks "$(DEBIAN)" "$(prev_fullver)" diffupstream: