Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1638158rda; Mon, 23 Oct 2023 20:54:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElOLcEzZaz+vBNRWvlmB6S+YvR6Lo4atwRATQsVWEcwu1+MdrifIOJDJBZDPYQUdpHFkPW X-Received: by 2002:a05:6870:889f:b0:1ea:131f:5fb1 with SMTP id m31-20020a056870889f00b001ea131f5fb1mr12214681oam.34.1698119682323; Mon, 23 Oct 2023 20:54:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698119682; cv=none; d=google.com; s=arc-20160816; b=Vw8rsMVP63nPXsjfFjPoE8Gzxegp7yor+GFCKVGZoa45IgD0gITRT9lyXny7vl6ofX CQLZB6lztp4Dwb3i4WNfoy1YaeDtzUa7x+7xPnLHyJf0AFjM1cWdrumSfZ+qmm5ad6g0 oUv6VujC09Yz5okCnjQSYHqaDMFpuCoOrARK8SzUK+kFICJZhDogFU2NYlGP/Mf8N5Qb pH+LZyEZ4zj1kpURdL6Poq477j7NlLjb28lfrsqb/cnyT9pUdOff0yGi9mXr8aokotZo OyZBaQajT4aCM9hANgn2FNE8gIfKsqN+r3yy3XWteMq9jswfAVUd9TZaISCRUWMIQB6k Gi3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:subject:cc:to:from :message-id:date:dkim-signature; bh=rmddIeGleB+CvcksXIlwUEw0FkwTQo8xqUcvDqbnLkY=; fh=fHHNkGg+NzKoJxHGMh0JSMLpg18Ht1OPApOBL8ui3GA=; b=B7tQoBS2Tdtcdzi0NFeXqT96FeZ+N21EA/1tFoS5sW10A9HD0xtKERKB/u7HQUdycQ Gyynzeyj51Q33RPX2/2fE7ChLPVmb0sZpVQG9LMftAVpiOb6G0mvN59V7bKE8yraqr7d HPZZagKKv1/S3/sz1p4+HJMPinc6HqOeVyOOzCQxMYCym2gDVUTES40MOU3jcs5tLfJE njcYJDI+jN4IBplhKJfaKHhBMjUQ01c0ElTNJ/MJ9mzyoZNHTa6Nih+6VO0rjy1DVdhO A6w/G2na9K55LgicwZM/3Dcuiip2d0e/e/+D2keNRCime4hM9l4W+epAr5CrvSRLWT/g 6uFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=bwsnazR6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bx35-20020a056a02052300b005ae22729b09si8492363pgb.683.2023.10.23.20.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 20:54:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=bwsnazR6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9CFB3802F949; Mon, 23 Oct 2023 20:54:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233719AbjJXDy1 (ORCPT + 99 others); Mon, 23 Oct 2023 23:54:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232317AbjJXDxa (ORCPT ); Mon, 23 Oct 2023 23:53:30 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A79CD1716 for ; Mon, 23 Oct 2023 20:52:37 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-778a6c440faso210008685a.3 for ; Mon, 23 Oct 2023 20:52:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1698119556; x=1698724356; darn=vger.kernel.org; h=in-reply-to:references:subject:cc:to:from:message-id:date:from:to :cc:subject:date:message-id:reply-to; bh=rmddIeGleB+CvcksXIlwUEw0FkwTQo8xqUcvDqbnLkY=; b=bwsnazR6ZZuMwadnjERsh/NRnerpmP1Ec6vOkf/ySCmP5i8DEO0UptP0I/LLzU5T3+ x1kPSjZGsXyNwA061wBem1iZiloGh3A8niXMkTnRbfjozpezswvP5/PqxyBSHRj4o2WC 36MqS1SlWG/XlkdbT7I4GThRkxp9q44TEO9myX3Vcl1NfejNWTlDVL/K0IMjqNrLM3X6 8KWlcW5IN1C91m2ah5qji5G8Gca1EfRArip/Zey6w9gFGLm6ngIc+B+WKPZsRPLh2WWR c6bWEGq5AD2Xi/fRDYvM/HKx4CBFFk1wFEtfQkXy9p2z7Lm58jUklbQGDz8vjtJEYpEi j0ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698119556; x=1698724356; h=in-reply-to:references:subject:cc:to:from:message-id:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rmddIeGleB+CvcksXIlwUEw0FkwTQo8xqUcvDqbnLkY=; b=AuP8x2opQ/nhggMTD7jIoFCU3dxwyWttHvlgIT59gT+tPolYwclW2tVQWCiZv7OKAn S/6szuQNwCy16OHUeyK8wm5y48R8+8keaxZHB24CQdMW3sQUzVx0cwP1GSZGOFACHr/c fgtFUURoWaWAMQOHHTEI/aY1CebVZ3pwIDQLPCjX1MymcA9NTqP3UVgNrJdTZkepetWj xSVQhSj5Z0lmpXfV+OsP4BG1Kb1sPPYmCEv7c2s4198umWXgzSS8T3RQPsyxbnk5J0ZE TZ/+LvRVSULy2ilWfim4ZJ8MLlOkWQPZycX7c6XwM98lDLR8+X7ysPJAN2phU1GS8tkd RZaQ== X-Gm-Message-State: AOJu0Yyj5dDkkK3B2pPzFhSBKML5HmTuRE1TJcOn+Fg8H9Qsob+KT1Oe MHcihXTdQXvTbKfPLWebdahD X-Received: by 2002:a05:620a:172a:b0:775:9c22:e901 with SMTP id az42-20020a05620a172a00b007759c22e901mr12880926qkb.15.1698119556628; Mon, 23 Oct 2023 20:52:36 -0700 (PDT) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id t14-20020a05620a0b0e00b007757fefea79sm3144655qkg.130.2023.10.23.20.52.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 20:52:36 -0700 (PDT) Date: Mon, 23 Oct 2023 23:52:35 -0400 Message-ID: <0c3ac562e5b8ea82d962478459bc7047.paul@paul-moore.com> From: Paul Moore To: Fan Wu , corbet@lwn.net, zohar@linux.ibm.com, jmorris@namei.org, serge@hallyn.com, tytso@mit.edu, ebiggers@kernel.org, axboe@kernel.dk, agk@redhat.com, snitzer@kernel.org, eparis@redhat.com Cc: linux-doc@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, audit@vger.kernel.org, roberto.sassu@huawei.com, linux-kernel@vger.kernel.org, Deven Bowers , Fan Wu Subject: Re: [PATCH RFC v11 17/19] scripts: add boot policy generation program References: <1696457386-3010-18-git-send-email-wufan@linux.microsoft.com> In-Reply-To: <1696457386-3010-18-git-send-email-wufan@linux.microsoft.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 23 Oct 2023 20:54:39 -0700 (PDT) On Oct 4, 2023 Fan Wu wrote: > > Enables an IPE policy to be enforced from kernel start, enabling access > control based on trust from kernel startup. This is accomplished by > transforming an IPE policy indicated by CONFIG_IPE_BOOT_POLICY into a > c-string literal that is parsed at kernel startup as an unsigned policy. > > Signed-off-by: Deven Bowers > Signed-off-by: Fan Wu > --- > v2: > + No Changes > > v3: > + No Changes > > v4: > + No Changes > > v5: > + No Changes > > v6: > + No Changes > > v7: > + Move from 01/11 to 14/16 > + Don't return errno directly. > + Make output of script more user-friendly > + Add escaping for tab and '?' > + Mark argv pointer const > + Invert return code check in the boot policy parsing code path. > > v8: > + No significant changes. > > v9: > + No changes > > v10: > + Update the init part code for rcu changes in the eval loop patch > > v11: > + Fix code style issues > --- > MAINTAINERS | 1 + > scripts/Makefile | 1 + > scripts/ipe/Makefile | 2 + > scripts/ipe/polgen/.gitignore | 1 + > scripts/ipe/polgen/Makefile | 6 ++ > scripts/ipe/polgen/polgen.c | 145 ++++++++++++++++++++++++++++++++++ > security/ipe/.gitignore | 1 + > security/ipe/Kconfig | 10 +++ > security/ipe/Makefile | 11 +++ > security/ipe/fs.c | 8 ++ > security/ipe/ipe.c | 12 +++ > 11 files changed, 198 insertions(+) > create mode 100644 scripts/ipe/Makefile > create mode 100644 scripts/ipe/polgen/.gitignore > create mode 100644 scripts/ipe/polgen/Makefile > create mode 100644 scripts/ipe/polgen/polgen.c > create mode 100644 security/ipe/.gitignore ... > diff --git a/scripts/ipe/polgen/polgen.c b/scripts/ipe/polgen/polgen.c > new file mode 100644 > index 000000000000..40b6fe07f47b > --- /dev/null > +++ b/scripts/ipe/polgen/polgen.c > @@ -0,0 +1,145 @@ ... > +static int write_boot_policy(const char *pathname, const char *buf, size_t size) > +{ > + int rc = 0; > + FILE *fd; > + size_t i; > + > + fd = fopen(pathname, "w"); > + if (!fd) { > + rc = errno; > + goto err; > + } > + > + fprintf(fd, "/* This file is automatically generated."); > + fprintf(fd, " Do not edit. */\n"); > + fprintf(fd, "#include \n"); > + fprintf(fd, "\nextern const char *const ipe_boot_policy;\n\n"); > + fprintf(fd, "const char *const ipe_boot_policy =\n"); > + > + if (!buf || size == 0) { > + fprintf(fd, "\tNULL;\n"); > + fclose(fd); > + return 0; > + } > + > + fprintf(fd, "\t\""); > + > + for (i = 0; i < size; ++i) { > + switch (buf[i]) { > + case '"': > + fprintf(fd, "\\\""); > + break; > + case '\'': > + fprintf(fd, "'"); > + break; The revision of IPE proposed in this patchset doesn't support parsing single or double quotes, yes? > + case '\n': > + fprintf(fd, "\\n\"\n\t\""); > + break; > + case '\\': > + fprintf(fd, "\\\\"); > + break; > + case '\t': > + fprintf(fd, "\\t"); > + break; > + case '\?': > + fprintf(fd, "\\?"); > + break; Similar, are question marks supported by the parser? > + default: > + fprintf(fd, "%c", buf[i]); > + } > + } > + fprintf(fd, "\";\n"); > + fclose(fd); > + > + return 0; > + > +err: > + if (fd) > + fclose(fd); > + return rc; > +} ... > diff --git a/security/ipe/.gitignore b/security/ipe/.gitignore > new file mode 100644 > index 000000000000..eca22ad5ed22 > --- /dev/null > +++ b/security/ipe/.gitignore > @@ -0,0 +1 @@ > +boot-policy.c > \ No newline at end of file Add a newline please. -- paul-moore.com