From patchwork Fri Feb 16 20:33:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 10225625 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F01C260231 for ; Fri, 16 Feb 2018 20:35:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1B9628AA0 for ; Fri, 16 Feb 2018 20:35:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D647D29670; Fri, 16 Feb 2018 20:35:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72DE628D9D for ; Fri, 16 Feb 2018 20:35:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751121AbeBPUeN (ORCPT ); Fri, 16 Feb 2018 15:34:13 -0500 Received: from alln-iport-1.cisco.com ([173.37.142.88]:6710 "EHLO alln-iport-1.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751058AbeBPUeH (ORCPT ); Fri, 16 Feb 2018 15:34:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=3480; q=dns/txt; s=iport; t=1518813247; x=1520022847; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=dQ7LLTRmN2q9Pmp/35oM3M+RAoO+z7MJHtmUq8U+j4Y=; b=Yn8beohqbGrQFVoXs1a5Tq9CcAfXXsP8TxZJ/RVHaBgbCovKtOwJ9Hkc eauEVIw8vJkvuCzEX99Rs66YoZN7RekfFUV2QF9SeOwALBT6zB8K8es9w xgV4CTnNSoMcyRaCOyHrHLtDOWVqN7CoSiJCtZFSa+m9GRcb7dGBcmJE5 o=; X-IronPort-AV: E=Sophos;i="5.46,520,1511827200"; d="scan'208";a="71904794" Received: from rcdn-core-6.cisco.com ([173.37.93.157]) by alln-iport-1.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Feb 2018 20:34:06 +0000 Received: from sjc-ads-7132.cisco.com (sjc-ads-7132.cisco.com [10.30.217.207]) (authenticated bits=0) by rcdn-core-6.cisco.com (8.14.5/8.14.5) with ESMTP id w1GKXsMc015412 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Fri, 16 Feb 2018 20:34:05 GMT From: Taras Kondratiuk To: "H. Peter Anvin" , Al Viro , Arnd Bergmann , Rob Landley , Mimi Zohar , Jonathan Corbet , James McMechan Cc: initramfs@vger.kernel.org, Victor Kamensky , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, xe-linux-external@cisco.com Subject: [PATCH v3 12/14] gen_initramfs_list.sh: add -x option to enable newcx format Date: Fri, 16 Feb 2018 20:33:49 +0000 Message-Id: <1518813234-5874-14-git-send-email-takondra@cisco.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518813234-5874-1-git-send-email-takondra@cisco.com> References: <1518813234-5874-1-git-send-email-takondra@cisco.com> X-Auto-Response-Suppress: DR, OOF, AutoReply X-Authenticated-User: takondra@cisco.com Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Mimi Zohar -x option populates extended attributes in cpio_list file passed to get_init_cpio and selects newcx CPIO format. Signed-off-by: Mimi Zohar Signed-off-by: Taras Kondratiuk --- scripts/gen_initramfs_list.sh | 13 ++++++++++++- usr/Kconfig | 11 +++++++++++ usr/Makefile | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh index 86a3c0e5cfbc..cddb82f093d9 100755 --- a/scripts/gen_initramfs_list.sh +++ b/scripts/gen_initramfs_list.sh @@ -24,6 +24,7 @@ $0 [-o ] [-u ] [-g ] {-d | } ... -g Group ID to map to group ID 0 (root). is only meaningful if is a directory. "squash" forces all files to gid 0. + -x include file extended attributes in cpio archive. File list or directory for cpio archive. If is a .cpio file it will be used as direct input to initramfs. @@ -146,6 +147,9 @@ parse() { ;; esac + $include_xattrs && \ + getfattr -h -d -m - -e hex --absolute-names ${location} | \ + sed -e '/^#/d' -e '/^$/d' -e 's/^/xattr /' >> ${output} echo "${str}" >> ${output} return 0 @@ -226,6 +230,8 @@ root_gid=0 dep_list= cpio_file= cpio_list= +cpio_opts= +include_xattrs=false output="/dev/stdout" output_file="" is_cpio_compressed= @@ -283,6 +289,10 @@ while [ $# -gt 0 ]; do default_list="$arg" ${dep_list}default_initramfs ;; + "-x") # include extended attributers + cpio_opts="-x" + include_xattrs=true + ;; "-h") usage exit 0 @@ -312,7 +322,8 @@ if [ ! -z ${output_file} ]; then fi fi cpio_tfile="$(mktemp ${TMPDIR:-/tmp}/cpiofile.XXXXXX)" - usr/gen_init_cpio $timestamp ${cpio_list} > ${cpio_tfile} + usr/gen_init_cpio $timestamp ${cpio_opts} ${cpio_list} \ + > ${cpio_tfile} else cpio_tfile=${cpio_file} fi diff --git a/usr/Kconfig b/usr/Kconfig index 43658b8a975e..0cc03bc4614c 100644 --- a/usr/Kconfig +++ b/usr/Kconfig @@ -52,6 +52,17 @@ config INITRAMFS_ROOT_GID If you are not sure, leave it set to "0". +config INITRAMFS_NEWCX + bool "Use newcx CPIO format for initramfs" + depends on INITRAMFS_SOURCE!="" + default n + help + If selected "usr/gen_init_cpio" will generate newcx CPIO archive + format that supports extended attributes. + + See for + more details. + config RD_GZIP bool "Support initial ramdisk/ramfs compressed using gzip" depends on BLK_DEV_INITRD diff --git a/usr/Makefile b/usr/Makefile index 237a028693ce..1106bfd61475 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -29,7 +29,8 @@ ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \ $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d) ramfs-args := \ $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \ - $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) + $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) \ + $(if $(CONFIG_INITRAMFS_NEWCX), -x) # $(datafile_d_y) is used to identify all files included # in initramfs and to detect if any files are added/removed.