Received: by 10.223.185.116 with SMTP id b49csp1110353wrg; Fri, 16 Feb 2018 12:39:32 -0800 (PST) X-Google-Smtp-Source: AH8x224IUXqyTPlxSK01CYQxjM9u1kecd/TEiLkL3HXFLe4GwhSfPsxNPB7DR3elTewssnghPauv X-Received: by 10.99.126.75 with SMTP id o11mr6114865pgn.97.1518813572348; Fri, 16 Feb 2018 12:39:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518813572; cv=none; d=google.com; s=arc-20160816; b=GNn3nQm1eme2/nAYlryYhFrpJZHaehaxfY0JCL8wb4hbpn2wItFUgKPO3FtjsRqxhI BvlowpkRc1o2ilNU4zMf9BZccI6YBkxCNdOX3RP+6889N+wzCx222s4kYtaBNyvYku7n 4IWwPj84i/o4wyjYcJMGob43XSrYaDHN7HZOjeoVJ16bf2LT13UpWhqBubz3/Nd4ykVm azdnFlP3aKU1bt5Kogp4N3lp/6xM9Ey5jA2F91lrs8Z5l2CcU7n2CSKzMfvY0AIl9cCL +h67Z/0n/RV0WgU9/S9kcNEwofsK6h1PIiuZFCaTKwxPjNxmlB7hd/pK9H7qiNZwlfZO EdwQ== 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=VqhyafdcK9NDz8yT/Dj/RPT/kYOtWKGffQM4oQAejUI=; b=GkKmBcGWJv/M6jW1GnIrv0/YH6iE1n/qb1YY///HC0iKoOMxhbRL0CxdsDZbPp+tBP m+mxojeHRxvYkheQtW9UFmT/OjyQFdy++xxtlIV/nNG34gbisHxqd+hWsA1NuTgumlsQ bHBDkkxJ+Fm3J/154XCoPypjqZcgf6Gre1brMA+1cuG/z5wdoGxmAfv+BPVI8ytiSNz9 wxkgDCvf2K+gKmBhyUp0C3cnUhB6p1AqhDX2q8zBjGEgMGkSLiZIVjjRVWYhr1gMHCmA iOfVkXqYSBaA3RdP8X7mZ7hQ4W8/mz3ZxmPDqHLdtXeLmJhkbY7PL3hZhFNZE9sHJbEF 3doA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=ODU13T5j; 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 f89-v6si98907plf.807.2018.02.16.12.39.18; Fri, 16 Feb 2018 12:39:32 -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=ODU13T5j; 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 S1751280AbeBPUiE (ORCPT + 99 others); Fri, 16 Feb 2018 15:38:04 -0500 Received: from rcdn-iport-2.cisco.com ([173.37.86.73]:35645 "EHLO rcdn-iport-2.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750948AbeBPUeC (ORCPT ); Fri, 16 Feb 2018 15:34:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2224; q=dns/txt; s=iport; t=1518813242; x=1520022842; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=a+seLTc7b5r96aHoOplgXaf9fRRhQmOfR4/lqCZPL2Q=; b=ODU13T5jyJGqW6zFNgviGewxPOuE5ITTb/lGk9DjuQR5MIcywoBFhxH7 j6lw4e4PRNybUrb1XaJ/9aN2N9Mxd1jitqWSiqiHkyFHqBsj8wFNJp8cs 7YF07jdK7kDvat9xrelCYgPMMTAeGD2ud7v9Rb0euVmVSy4ElvjbGVIFI U=; X-IronPort-AV: E=Sophos;i="5.46,520,1511827200"; d="scan'208";a="359949665" Received: from rcdn-core-6.cisco.com ([173.37.93.157]) by rcdn-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Feb 2018 20:34:00 +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 w1GKXsMV015412 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Fri, 16 Feb 2018 20:34:00 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 06/15] initramfs: separate reading cpio method from header Date: Fri, 16 Feb 2018 20:33:42 +0000 Message-Id: <1518813234-5874-7-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 From: Mimi Zohar In preparation for adding xattr support, read the CPIO method separately from the rest of the header. Signed-off-by: Mimi Zohar Signed-off-by: Taras Kondratiuk --- init/initramfs.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index 2d5920c094e0..b3d39c8793be 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -168,7 +168,7 @@ static void __init parse_header(char *s) int i; buf[8] = '\0'; - for (i = 0, s += 6; i < 12; i++, s += 8) { + for (i = 0; i < 12; i++, s += 8) { memcpy(buf, s, 8); parsed[i] = simple_strtoul(buf, NULL, 16); } @@ -189,6 +189,7 @@ static void __init parse_header(char *s) static int __init do_start(void); static int __init do_collect(void); +static int __init do_format(void); static int __init do_header(void); static int __init do_skip(void); static int __init do_name(void); @@ -233,7 +234,7 @@ static __initdata char *header_buf, *symlink_buf, *name_buf; static int __init do_start(void) { - read_into(header_buf, 110, do_header); + read_into(header_buf, 6, do_format); return 0; } @@ -251,7 +252,7 @@ static int __init do_collect(void) return 0; } -static int __init do_header(void) +static int __init do_format(void) { if (memcmp(collected, "070707", 6)==0) { error("incorrect cpio method used: use -H newc option"); @@ -261,6 +262,12 @@ static int __init do_header(void) error("no cpio magic"); return 1; } + read_into(header_buf, 104, do_header); + return 0; +} + +static int __init do_header(void) +{ parse_header(collected); next_header = this_header + N_ALIGN(name_len) + body_len; next_header = (next_header + 3) & ~3; @@ -457,7 +464,7 @@ static char * __init unpack_to_rootfs(char *buf, unsigned long len) const char *compress_name; static __initdata char msg_buf[64]; - header_buf = kmalloc(110, GFP_KERNEL); + header_buf = kmalloc(104, GFP_KERNEL); symlink_buf = kmalloc(PATH_MAX + 1, GFP_KERNEL); name_buf = kmalloc(N_ALIGN(PATH_MAX), GFP_KERNEL); -- 2.10.3.dirty