Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2512690yba; Fri, 17 May 2019 19:32:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwo3iPuLrmAo7fCRyTIunqcSs5Cbhz0sjbo2JeID/aIt0WLdGRlEw2Bqh32ePRAj8dPxD3o X-Received: by 2002:a17:902:6b03:: with SMTP id o3mr10492138plk.85.1558146753410; Fri, 17 May 2019 19:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558146753; cv=none; d=google.com; s=arc-20160816; b=MrHFsfNTtc+6s7dNXtJCj5qr7tZ8/66O/FQecKtK0vbS5It0BZlzyiUvw0p4nnzxUE iJAP/PywLb7IstRdl8HyI6zo6tJO8tjiYMi70shI+8TOII2L8iRLnANaQYTCaqhmWL2f FDNr80Xf+HMSk4dFEz/YGFlS/Zx7QPqrXHkDtJUDzNDPnLU6Zt2URkM7HQJgBty+AIik 9ziBbNcAlTpffd4celyHUrbM28dBJvaOfRE3i0b0d+TWNB/dxpptIyXNukqkzZGLCaLb Z/FKzyfOKyA6xw1Kt8c77SDzUP0jB2tgLyuhHIwctB+jhTqYY03iufyYitQJD7ycaiHg /Ixw== 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:from:references:cc:to:subject:dkim-signature; bh=e/Re8JNkMMZS5vb+q48mFRH1gM+SXPJbTk6PEc7g9q4=; b=VZkjAcBzVNC3KjWCIUkyePjbw92k16DgJ5DTnWBE5EVcDU5UBuPMga7aaPkzlfMrMI SBOTBJ3vCHNr+tjEhGMkPfjDc6k7dsex21SnSS9D2XUk73BJdi9JPqwybfiJr53xPMPO Hahr6gEYzdZmjJCRkVR+GaTSySieWfE2Rqh7IwmbMqAuj51mspzrhOAJDvhVKAIRlDzk ZOasMcBq/V283sInqU238NesRRlrkTGMwdV0tAmX7RlsObjwMUHB+b7EOmp+WfP4cNnN c1Vg4z0Yo2SdLKZtymRTh65o01r8MfL4Cv6FrdilxjMM3HdkiGpgg2ZZdVwpPqpTfYti bzKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@landley-net.20150623.gappssmtp.com header.s=20150623 header.b=TaT9fKi7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c21si9558605pgh.321.2019.05.17.19.32.18; Fri, 17 May 2019 19:32:33 -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=@landley-net.20150623.gappssmtp.com header.s=20150623 header.b=TaT9fKi7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728813AbfERCPb (ORCPT + 99 others); Fri, 17 May 2019 22:15:31 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:44613 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727585AbfERCPb (ORCPT ); Fri, 17 May 2019 22:15:31 -0400 Received: by mail-yw1-f65.google.com with SMTP id e74so3473342ywe.11 for ; Fri, 17 May 2019 19:15:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landley-net.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=e/Re8JNkMMZS5vb+q48mFRH1gM+SXPJbTk6PEc7g9q4=; b=TaT9fKi7fztMIo4wYsgTLZDMnxKQdpEqwKs28V2zcIpqmFTLAKns45HPPfCE5WngUb /cjUP/dtAXmL/O2bc96thZrQHaWxU6ZtLzswD7p9cBMORrNKTnWGpz0PM1j9bBl69Lbz mujkZe1Ja74zvbfU2kEu2rit4TTS1EcCBAV+T5XByRj11EEwm7k4hj7NpeDumKkpXjYk Pof24nksP+mkg9BlqfvxkCflkBHCuKtRxV77HbRrclQZEzBnnAR5Zs8Uk/kK2wivODdS MPW/elYrHw4itfDNH92HuXJVCV+YcqPJ7f77k5+LhM8UqkUZt+NPYDfSScblabao+j28 xvKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=e/Re8JNkMMZS5vb+q48mFRH1gM+SXPJbTk6PEc7g9q4=; b=qoftq4L0JKnYn8V54zsA3MtURWgIhlWhG6jCRuE2a2U1UJdqZK7Ycua+OnMxUVU6il hTYZngfaDpp5bHSjaZsFAisakTHo3/QLS51V54HvyHN4I1OQCjMs2YmlNUGieABha8L2 DEPy9tLC8ZWmZUCgRZO+EI37aOzg+amQbsDbMbK++fa795eJJHbTRSQeiLAoNnw/W4jx Dv3xtdy175YlzQLvohCyKDdqVOZ5SIB9/mmiVfZE5wtOitmf28guzDAKaIiRKyd+/fQX rWFV2m5jy1n+CE8rEhFmIALS7o2tGl+Yrliv2vsnHwazhnD6m7KbsI6Ory6cVC9Y7jmC yZNQ== X-Gm-Message-State: APjAAAXUVXqTRLQdAlyCdkuzcuMLWlHx5YYvs03btcTxDOTP6t5N3uxr etxopB3vt06Htn+4k1zQ96us3w== X-Received: by 2002:a81:3bd5:: with SMTP id i204mr22821560ywa.254.1558145730321; Fri, 17 May 2019 19:15:30 -0700 (PDT) Received: from [192.168.43.9] ([172.56.6.82]) by smtp.googlemail.com with ESMTPSA id f129sm2902432ywe.35.2019.05.17.19.15.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 19:15:29 -0700 (PDT) Subject: Re: [PATCH v3 2/2] initramfs: introduce do_readxattrs() To: "H. Peter Anvin" , 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, james.w.mcmechan@gmail.com, niveditas98@gmail.com References: <20190517165519.11507-1-roberto.sassu@huawei.com> <20190517165519.11507-3-roberto.sassu@huawei.com> <69ef1f55-9fc1-7ee0-371f-3dbc77551dc0@zytor.com> From: Rob Landley Message-ID: Date: Fri, 17 May 2019 21:16:04 -0500 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: <69ef1f55-9fc1-7ee0-371f-3dbc77551dc0@zytor.com> 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 4:41 PM, H. Peter Anvin wrote: > 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!!!. We documented it as "TRAILER!!!" without leading !!!, and that its purpose is to flush hardlinks: https://www.kernel.org/doc/Documentation/early-userspace/buffer-format.txt That's what toybox cpio has been producing. Kernel consumes it just fine. Just checked busybox cpio and that's what they're producing as well... Rob