Received: by 10.223.176.46 with SMTP id f43csp1572185wra; Wed, 24 Jan 2018 19:42:05 -0800 (PST) X-Google-Smtp-Source: AH8x227R923OVPKJsdfGAGVhiHJh3JjMJUVWrQkG1+QlW+EJTkiqlTRqm7eTbxbnfaVQ0n5mQg+X X-Received: by 2002:a17:902:9002:: with SMTP id a2-v6mr9830729plp.331.1516851725803; Wed, 24 Jan 2018 19:42:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516851725; cv=none; d=google.com; s=arc-20160816; b=axBrJ+qsRNdP0R41hYJ8evT+zMHNeN8T6/rYaMnPOM4gHHWY87lutpX4TmLHAGjg06 5kWMa9uWrM9s0e7rn9nQILrnJkcrLmJjL8Q1nhR78LDJka3oC4+R0VW8fi91aZ9b33DR yegmaxA8Czwmq+CHIW/4kbp689YlYSgHDgT6biZ5BOVEoPflSqIiz3U2qEC8lZGGFgc1 c4QxDF6PI1UPSIQ0XIPGy0YocCmKCOpDRQdrdks0hDECOZvSYRCMOt8RQgD/LANO+ejp Zf7+/wPDLElNbc9ppP2Ze2BZ4WUITqsNH/P2faWyKPzFyN9J0+TQCWhfMkDkvXPsm6PH ODVw== 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=pwDP6Kj13qo6rXY73CaFY1sHhxQ/7SlbvGduawWrEbcNC3rn5RlWyM3uzz2TLPKT/T 71GQsiteIf8Jff8nZCyT91n3OoR3R7KuBrvgPjhhU6ErXACVn7Yjgeeufm5s1gASgv9b CryXkivcDfKB9YkOYi0sKIkuROkFuIJi+db5gIRjIH+XtHvcbnx1zQPfJ3d8x5cmRT2k Y/GCFkPYXMKVpRX16Y+Kqe8olgzXD/o5GgGSr3oD7xQrJVLw7BZKZWGosQdd14bYPahm 69tRkU9eFOeFatAA3xbaURiPPGb2ThNAwzWNaLRc4ZyKZ0m3WKP3uROxBWn+lHXgJXt6 q+uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=Dmo5Y3D2; 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 65si984349pgh.98.2018.01.24.19.41.51; Wed, 24 Jan 2018 19:42:05 -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=Dmo5Y3D2; 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 S933551AbeAYDjv (ORCPT + 99 others); Wed, 24 Jan 2018 22:39:51 -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 S933440AbeAYDhb (ORCPT ); Wed, 24 Jan 2018 22:37:31 -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=1516851451; x=1518061051; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=a+seLTc7b5r96aHoOplgXaf9fRRhQmOfR4/lqCZPL2Q=; b=Dmo5Y3D2Fh9HiPyPDt9xM68Yc1urp096T9wM896RUr6ghl5LYT1fMTA7 PJWZZukZHjaBErB5uAxi/yhrnVtTw2UkqpjfXts1IMOBuLZz7eXH9k9oM 1aVBxyh1siOu6NnOWeyVuD1r61YD05foXA9Rb0aqosoTwVibadHith1Nc Q=; X-IronPort-AV: E=Sophos;i="5.46,409,1511827200"; d="scan'208";a="60773938" 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:02 +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 w0P3Ruiv007601 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NO); Thu, 25 Jan 2018 03:28:01 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 06/15] initramfs: separate reading cpio method from header Date: Thu, 25 Jan 2018 03:27:46 +0000 Message-Id: <1516850875-25066-7-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: 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