Received: by 10.223.185.116 with SMTP id b49csp1110547wrg; Fri, 16 Feb 2018 12:39:45 -0800 (PST) X-Google-Smtp-Source: AH8x224RemISKfXBqZtDTG+RYExOs5ef2pGX2Jpp2sSCgFyIGC81HFKvFHtRsn1sLJiSvvQGGI0X X-Received: by 10.99.125.25 with SMTP id y25mr6139284pgc.227.1518813584996; Fri, 16 Feb 2018 12:39:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518813584; cv=none; d=google.com; s=arc-20160816; b=DVQ7efGreX8ytRaD11K/8ErhLnkWspMye8ibPQ7L6/dRFnfi8SO57T8ApXpg1e7D3u 2nv/k6+xvbDbDrPNEXx/lyTlnfAknQAiIM1/WsYcMuYSjgAtdg9nnqWV8uNK25Wqzm/h FxEISWuj+SUV/BesOmSkQBtvpmitgC+x+KIE/Sgv3QbpuxYPxH8ysQo7guqgHZ2NapCN +d4tMksAWrjC3mHQZQY9AP7qXP1ddpVnwgFlhe3UnxykzAVMquAaAOWfVqOyscXDLJN5 FcSUESZDYWlQoq9kB95fERoQ9bzrUOfRVSMKueR5AP9gxqPDw8q1nxrlKdxd8SBaMO1m nM8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=F0uDfPgJmcTkrjq01j4YiUN0tvr7u1igKpMdivmL/Mw=; b=UU2LD20qUOX3/81De9YyDEjAuNdpeaU+OM8HoVOF/SGc30L8V+TEncgaEZPARGKo1O e2gONxi4KIH7gXu95FAYvWozz89e4y9PEKFpPmMRWVZp4JOL/azSyUj90XIxNJx5QI8a M1tgzvKby/HpjIdmDwQkC2VBiKGZjzPFl7ISV4hVi2xfb0k623H2rbj3TRxLBexJ2RRR oRu6MDfNyfGXWWGUUGWHhekqQwXznvFfP2U1s2we3Jl4n6KEf+0aRVSnuuyGwDOmoumb sPQF9hCcwqzDrCdx7C+iavJbdgRnK7+uC3zxzjl6wg+oYxgIV32XYMk8Qzu+pAxS/Vf5 bYTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=bXDnpJN0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cisco.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e13-v6si1509791plo.242.2018.02.16.12.39.30; Fri, 16 Feb 2018 12:39:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=bXDnpJN0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cisco.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750980AbeBPUeD (ORCPT + 99 others); Fri, 16 Feb 2018 15:34:03 -0500 Received: from rcdn-iport-6.cisco.com ([173.37.86.77]:1571 "EHLO rcdn-iport-6.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750780AbeBPUd6 (ORCPT ); Fri, 16 Feb 2018 15:33:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=4410; q=dns/txt; s=iport; t=1518813238; x=1520022838; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=yMQhh7trjXx0Imjbz7ZM1gjvUXuDiSEGQ+gn+V9SJXM=; b=bXDnpJN0aXyijdpY17xsN/r7NbAEypIkzil/n7K88V4RCoL8rU4221yl EKHPIHiJD58kjJUbDpkUjGP1gFI9i/hUx3Dzmr7WIFkvotJOtsLSTvQ1y +3stV4kF5n9iTa3tHy0/r37w5NZWq0SfTW6vlpu7p1Nc3HjmOHpp4d9JI 8=; X-IronPort-AV: E=Sophos;i="5.46,520,1511827200"; d="scan'208";a="357044583" Received: from rcdn-core-6.cisco.com ([173.37.93.157]) by rcdn-iport-6.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Feb 2018 20:33:56 +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 w1GKXsMQ015412 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Fri, 16 Feb 2018 20:33:56 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 01/15] Documentation: add newcx initramfs format description Date: Fri, 16 Feb 2018 20:33:37 +0000 Message-Id: <1518813234-5874-2-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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Many of the Linux security/integrity features are dependent on file metadata, stored as extended attributes (xattrs), for making decisions. These features need to be initialized during initcall and enabled as early as possible for complete security coverage. Initramfs (tmpfs) supports xattrs, but newc CPIO archive format does not support including them into the archive. This patch describes "extended" newc format (newcx) that is based on newc and has following changes: - extended attributes support - increased size of filesize to support files >4GB - increased mtime field size to have 64 bits of seconds and added a field for nanoseconds - removed unused checksum field Signed-off-by: Taras Kondratiuk Signed-off-by: Mimi Zohar Signed-off-by: Victor Kamensky --- Documentation/early-userspace/buffer-format.txt | 46 ++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/Documentation/early-userspace/buffer-format.txt b/Documentation/early-userspace/buffer-format.txt index e1fd7f9dad16..8349b2f28b4b 100644 --- a/Documentation/early-userspace/buffer-format.txt +++ b/Documentation/early-userspace/buffer-format.txt @@ -24,6 +24,7 @@ grammar, where: + indicates concatenation GZIP() indicates the gzip(1) of the operand ALGN(n) means padding with null bytes to an n-byte boundary + [n] means size of field is n bytes initramfs := ("\0" | cpio_archive | cpio_gzip_archive)* @@ -31,20 +32,33 @@ grammar, where: cpio_archive := cpio_file* + ( | cpio_trailer) - cpio_file := ALGN(4) + cpio_header + filename + "\0" + ALGN(4) + data + cpio_file := (cpio_newc_file | cpio_newcx_file) + + cpio_newc_file := ALGN(4) + cpio_newc_header + filename + "\0" + \ + ALGN(4) + data + + cpio_newcx_file := ALGN(4) + cpio_newcx_header + filename + "\0" + \ + ALGN(4) + xattrs + ALGN(4) + data + + xattrs := xattr_entry* + + xattr_entry := xattr_size[8] + xattr_name + "\0" + xattr_value cpio_trailer := ALGN(4) + cpio_header + "TRAILER!!!\0" + ALGN(4) In human terms, the initramfs buffer contains a collection of -compressed and/or uncompressed cpio archives (in the "newc" or "crc" -formats); arbitrary amounts zero bytes (for padding) can be added -between members. +compressed and/or uncompressed cpio archives; arbitrary amounts +zero bytes (for padding) can be added between members. The cpio "TRAILER!!!" entry (cpio end-of-archive) is optional, but is not ignored; see "handling of hard links" below. -The structure of the cpio_header is as follows (all fields contain +xattr_size is a total size of xattr_entry including 8 bytes of +xattr_size. xattr_size has the same hexadecimal ASCII encoding as other +fields of cpio header (see below). + +The structure of the cpio_newc_header is as follows (all fields contain hexadecimal ASCII numbers fully padded with '0' on the left to the full width of the field, for example, the integer 4780 is represented by the ASCII string "000012ac"): @@ -81,6 +95,28 @@ algorithm used. If the filename is "TRAILER!!!" this is actually an end-of-archive marker; the c_filesize for an end-of-archive marker must be zero. +"Extended" newc format (newcx) +"newcx" cpio format extends "newc" by increasing size of some fields +and adding extended attributes support. cpio_newcx_header structure: + +Field name Field size Meaning +c_magic 6 bytes The string "070703" +c_ino 8 bytes File inode number +c_mode 8 bytes File mode and permissions +c_uid 8 bytes File uid +c_gid 8 bytes File gid +c_nlink 8 bytes Number of links +c_mtime 16 bytes Modification time (seconds) +c_mtime_nsec 8 bytes Modification time (nanoseconds) +c_filesize 16 bytes Size of data field +c_maj 8 bytes Major part of file device number +c_min 8 bytes Minor part of file device number +c_rmaj 8 bytes Major part of device node reference +c_rmin 8 bytes Minor part of device node reference +c_namesize 8 bytes Length of filename, including final \0 +c_xattrs_size 8 bytes Size of xattrs field + +Most of the fields match cpio_newc_header. c_chksum field is dropped. *** Handling of hard links -- 2.10.3.dirty