Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2314406yba; Fri, 17 May 2019 14:44:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3Hr+eXhNrwZ6aVXqolsyR2eqSCDZ3eCeaOr8toESfGDQQuSn7ApAvTpmVt57pTQNvqqnO X-Received: by 2002:a17:902:a503:: with SMTP id s3mr58393801plq.16.1558129496676; Fri, 17 May 2019 14:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558129496; cv=none; d=google.com; s=arc-20160816; b=yAu4U7spAzhtSmU6V9QCZmJD0TOFvBepulSw+aCmUCboSYQkPjM9w0lDcyYKB36yZt lsgSoKwT8kRqxf+z+RNYLYsGFuFcbPpUgn9QsOszpt70yh4TihS5xSIclvSOyJOmM4z0 Gm12uiGbdY5/rWaR6faqkwy5Ov+oPM18j4djRfcdIqFV3uc5hOfG2CYMmhJhGaKOLH6A ycjK5Jg4RDhZOIXV4V+20roMRl4PL1Vp27JzTySn0xISZgLtDf8BIP+SBqvBLxwt3MVf IX/FzByySQwMHMqenyaY3EFLrH6Pea9+XlwRTSgzKMojrLocZ5XrgtN8D8x3EWQNsUtz GfNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature:dkim-filter; bh=bxXMxaG3yomMejfA38U/OeM6jHqv8J+5dyCwLKAF2FU=; b=cXEKzABdxSOS4BairBLoF/SiujXlA+cnfSQ3aFNuh21JQkUwm0OKQsDayvIsesE3mV Z/GRnLxtBBc3IaYTfwyJSNLPNC2DzW4Tk51JO7GSRkuqlVODxTBwg7vbrPlE2IHVD1Y1 /30+tZybhKEjYtHtWJxrRYJMIuk/pKy34jZnCaBFayTesSwoaJmiBL4CliXjOAQTTSFr NvwP7tXlgWWAEZtZi0NyGb9W/YR3Aw4POe+4OLXvGap6Lw6MZovjpUQyuCAHIwSYqudD KB2t/UtRAaVxghKa77pNCLcCuOqiKMiHQgzlY+CkXJcRtqzaHDB9amyPKjARboSmIaOw O+3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019041745 header.b=ZeS6bMg0; 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=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q14si8759880pgg.521.2019.05.17.14.44.41; Fri, 17 May 2019 14:44:56 -0700 (PDT) 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=@zytor.com header.s=2019041745 header.b=ZeS6bMg0; 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=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728592AbfEQVmd (ORCPT + 99 others); Fri, 17 May 2019 17:42:33 -0400 Received: from terminus.zytor.com ([198.137.202.136]:41435 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727215AbfEQVmc (ORCPT ); Fri, 17 May 2019 17:42:32 -0400 Received: from tazenda.hos.anvin.org ([IPv6:2601:646:8600:3280:e269:95ff:fe35:9f3c]) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id x4HLg1621520285 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Fri, 17 May 2019 14:42:01 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com x4HLg1621520285 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019041745; t=1558129337; bh=bxXMxaG3yomMejfA38U/OeM6jHqv8J+5dyCwLKAF2FU=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=ZeS6bMg0hxchVF1tgoFn6yE8wCqmZlRyMrHmk8o/e+pq/KQ5I/B28qqNjzVsoOD7U DQYWEaBiOgbf+0gG9ks4a8NmplJ4/LiSNS7RtU0cPhv+tMObN4J8JC9is2q+fjK3JI 2H5MtDUR3Ifj9jfSwsi87PCafjbWKoB7LTqU4iASOGQNlc8DQgB3Z41Vt+fZ7CKdi4 MCkfffGFcvnRHug/Wn4KidawPjicjifNXBnVAZsajxOzIS5KsOQwX7fvchRAxbNb1a UrSu0by2ylgKXiycuvnT/BS0HdTsmsVvePniRdbIAyXbBVomg6bAOlAEpEjRZBN8k0 fKHAeL6TgBvcg== Subject: Re: [PATCH v3 2/2] initramfs: introduce do_readxattrs() From: "H. Peter Anvin" To: Roberto Sassu , viro@zeniv.linux.org.uk Cc: linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, initramfs@vger.kernel.org, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, zohar@linux.vnet.ibm.com, silviu.vlasceanu@huawei.com, dmitry.kasatkin@huawei.com, takondra@cisco.com, kamensky@cisco.com, arnd@arndb.de, rob@landley.net, james.w.mcmechan@gmail.com, niveditas98@gmail.com References: <20190517165519.11507-1-roberto.sassu@huawei.com> <20190517165519.11507-3-roberto.sassu@huawei.com> Message-ID: <69ef1f55-9fc1-7ee0-371f-3dbc77551dc0@zytor.com> Date: Fri, 17 May 2019 14:41:56 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/17/19 1:18 PM, hpa@zytor.com wrote: > > Ok... I just realized this does not work for a modular initramfs, composed at load time from multiple files, which is a very real problem. Should be easy enough to deal with: instead of one large file, use one companion file per source file, perhaps something like filename..xattrs (suggesting double dots to make it less likely to conflict with a "real" file.) No leading dot, as it makes it more likely that archivers will sort them before the file proper. > > A side benefit is that the format can be simpler as there is no need to encode the filename. > > A technically cleaner solution still, but which would need archiver modifications, would be to encode the xattrs as an optionally nameless file (just an empty string) with a new file mode value, immediately following the original file. The advantage there is that the archiver itself could support xattrs and other extended metadata (which has been requested elsewhere); the disadvantage obviously is that that it requires new support in the archiver. However, at least it ought to be simpler since it is still a higher protocol level than the cpio archive itself. > > There's already one special case in cpio, which is the "!!!TRAILER!!!" filename; although I don't think it is part of the formal spec, to the extent there is one, I would expect that in practice it is always encoded with a mode of 0, which incidentally could be used to unbreak the case where such a filename actually exists. So one way to support such extended metadata would be to set mode to 0 and use the filename to encode the type of metadata. I wonder how existing GNU or BSD cpio (the BSD one is better maintained these days) would deal with reading such a file; it would at least not be a regression if it just read it still, possibly with warnings. It could also be possible to use bits 17:16 in the mode, which are traditionally always zero (mode_t being 16 bits), but I believe are present in most or all of the cpio formats for historical reasons. It might be accepted better by existing implementations to use one of these high bits combined with S_IFREG, I dont know. > Correction: it's just !!!TRAILER!!!. I tested with GNU cpio, BSD cpio, scpio and pax. With a mode of 0: - GNU cpio errors, but extracts all the other files. - BSD cpio extracts them as regular files. - scpio and pax abort. With a mode of 0x18000 (bit 16 + S_IFREG), all of them happily extracted the data as regular files. -hpa