From patchwork Thu Jan 25 03:27:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 10183557 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 9408160383 for ; Thu, 25 Jan 2018 03:38:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 861B92887F for ; Thu, 25 Jan 2018 03:38:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A55D28881; Thu, 25 Jan 2018 03:38:37 +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 24B962887F for ; Thu, 25 Jan 2018 03:38:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933551AbeAYDhj (ORCPT ); Wed, 24 Jan 2018 22:37:39 -0500 Received: from alln-iport-6.cisco.com ([173.37.142.93]:21061 "EHLO alln-iport-6.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933519AbeAYDhg (ORCPT ); Wed, 24 Jan 2018 22:37:36 -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=1516851455; x=1518061055; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=dQ7LLTRmN2q9Pmp/35oM3M+RAoO+z7MJHtmUq8U+j4Y=; b=UfO6U7kI857Ync87UPID1n492RLG9agJFU4IY2dd727gaPvpMIZGJ7yU iJEqb1PDmKKAN0BKs4r5PqqpflX2NFVFUOZ+4uaoyfgdiL6aZ4l/S1O74 0709XZnuYBqMBYQ6yv4D/GVElKJSurei1lCOX1RGpbVZLLJgHBvhnfzgZ c=; X-IronPort-AV: E=Sophos;i="5.46,409,1511827200"; d="scan'208";a="60774011" Received: from rcdn-core-6.cisco.com ([173.37.93.157]) by alln-iport-6.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jan 2018 03:28:08 +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 w0P3Ruj4007601 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Thu, 25 Jan 2018 03:28:08 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 v2 13/15] gen_initramfs_list.sh: add -x option to enable newcx format Date: Thu, 25 Jan 2018 03:27:53 +0000 Message-Id: <1516850875-25066-14-git-send-email-takondra@cisco.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516850875-25066-1-git-send-email-takondra@cisco.com> References: <1516850875-25066-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.