Re: [PATCH v2 0/3] initramfs: add support for xattrs in the initial ram disk
From: Roberto Sassu <roberto.sassu@huawei.com>
Date: 2019-05-16 11:42:57
Also in:
linux-fsdevel, linux-integrity, lkml
On 5/16/2019 7:29 AM, Arvind Sankar wrote:
On Wed, May 15, 2019 at 07:06:52PM +0200, Roberto Sassu wrote:quoted
On 5/15/2019 6:08 PM, Arvind Sankar wrote:quoted
On Wed, May 15, 2019 at 01:19:04PM +0200, Roberto Sassu wrote:quoted
On 5/15/2019 2:52 AM, Arvind Sankar wrote:I don't understand what you mean? The IMA hashes are signed by some key, but I don't see how what that key is needs to be different between the two proposals. If the only files used are from the distro, in my scheme as well you can use the signatures and key provided by the distro. If they're not, then in your scheme as well you would have to allow for a local signing key to be used. Both schemes are using the same .xattr-list file, no?I was referring to James's proposal to load an external initramfs from the embedded initramfs. If the embedded initramfs opens the external initramfs when IMA is enabled, the external initramfs needs to be signed with a local signing key. But I read your answer that this wouldn't be feasible. You have to specify all initramfs in the boot loader configuration. I think deferring IMA initialization is not the safest approach, as it cannot be guaranteed for all possible scenarios that there won't be any file read before /init is executed. But if IMA is enabled, there is the problem of who signs .xattr-list. There should be a local signing key that it is not necessary if the user only accesses distro files.I think that's a separate issue. If you want to allow people to be able to put files onto the system that will be IMA verified, they need to have some way to locally sign them whether it's inside an initramfs or on a real root filesystem.
Yes. But this shouldn't be a requirement. If I have only files signed by the distro, I should be able to do appraisal without a local signing key. I made an IMA extension called IMA Digest Lists, that extracts reference digests from RPM headers and performs appraisal based on the loaded white lists. The only keys that must be in the kernel for signature verification are the PGP keys of the distro (plus the public key for the RPM parser, which at the moment is different). .xattr-list is generated by my custom dracut module and contains the signature of the digest lists and the parser.
quoted
quoted
Right, I guess this would be sort of the minimal "modification" to the CPIO format to allow it to support xattrs.I would try to do it without modification of the CPIO format. However, at the time .xattr-list is parsed (in do_copy() before .xattr-list is closed), it is not guaranteed that all files are extracted. These must be created before xattrs are added, but the file type must be correct, otherwise clean_path() removes the existing file with xattrs. Roberto -- HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Bo PENG, Jian LI, Yanli SHIRight by "modification" in quotes I meant the format is actually the same, but the kernel now interprets it a bit differently. Regarding the order you don't have to handle that in the kernel. The kernel CPIO format is already restricted in that directories have to be specified before the files that contain them for example. It can very well be restricted so that an .xattr-list can only specify xattrs for files that were already extracted, else you bail out with an error. The archive creation tooling can easily handle that. If someone wants to shoot themselves in the foot by trying to add more files/replace existing files after the .xattr-list its ok, the IMA policy will prevent such files from being accessed and they can fix the archive for the next boot.
Unfortunately, dracut sorts the files before adding them to the CPIO image (.xattr-list is at the beginning). I could move xattrs from the existing file to the file with different mode, but this makes the code more complex. I think it is better to call do_readxattrs() after files are extracted, or when .xattr-list is going to be replaced by another one in the next initramfs. Roberto -- HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Bo PENG, Jian LI, Yanli SHI