Skip to contentSkip to conversation

Initramfs and IMA Appraisal

Linux-ima-user Mimi Zohar 3 participants 8 messages Dec 29, 2014 – Dec 30, 2014 5 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Mimi Zohar

author
#5 lore raw
Quoted 9 lines · Christophe Fillot
Quoted 3 lines

Are you using an initrd not an initramfs? According to Documentation/filesystems/ramfs-rootfs-initramfs.txt, "If

CONFIG_TMPFS

Quoted 2 lines

is enabled, rootfs will use tmpfs instead of ramfs by default".

Yes, that what I thought too, but it seems that it is not really the case because of this test:

Quoted 7 lines
     if (IS_ENABLED(CONFIG_TMPFS) && !saved_root_name[0] &&
         (!root_fs_names || strstr(root_fs_names, "tmpfs"))) {
         err = shmem_init();
         is_tmpfs = true;
     } else {
         err = init_ramfs_fs();
     }

[CC'ing Rob Landley, lsm, lkml]

Thanks! "saved_root_name" is set to the boot command line "root=" option, which in my case is the UUID. I'm not sure why real root should impact the initramfs tmpfs/ramfs decision.

Unless there is a good explanation, did you want to post a patch to remove the test?

Mimi

#6 lore raw
Quoted 18 lines · Mimi Zohar
Quoted 9 lines · Christophe Fillot
Quoted 3 lines

Are you using an initrd not an initramfs? According to Documentation/filesystems/ramfs-rootfs-initramfs.txt, "If

CONFIG_TMPFS

Quoted 2 lines

is enabled, rootfs will use tmpfs instead of ramfs by default".

Yes, that what I thought too, but it seems that it is not really the case because of this test:

Quoted 7 lines
     if (IS_ENABLED(CONFIG_TMPFS) && !saved_root_name[0] &&
         (!root_fs_names || strstr(root_fs_names, "tmpfs"))) {
         err = shmem_init();
         is_tmpfs = true;
     } else {
         err = init_ramfs_fs();
     }
Quoted 8 lines

[CC'ing Rob Landley, lsm, lkml]

Thanks! "saved_root_name" is set to the boot command line "root=" option, which in my case is the UUID. I'm not sure why real root should impact the initramfs tmpfs/ramfs decision.

Unless there is a good explanation, did you want to post a patch to remove the test?

I added support last year, here's the start of the patch series:

https://lkml.org/lkml/2013/6/29/101

The logic is that if you specify a fallback root via root=, then you're not staying on rootfs (that's what root= _means_, "here is the root filesystem the kernel is to mount over rootfs"), and thus the extra infrastructure for tmpfs instead of ramfs is unnecessary.

I keep encountering people who set root=/dev/ram0 because they think that means initrd (it doesn't), and then they feed in a cpio archive (that's a third state even before you get to the ramfs/tmpfs distinction), and they always want to change the code to make what they asked it to do not be crazy...

Possibly the documentation needs to elaborate, but I expect what we really need is a CONFIG_VERBOSE_ROOT_SETUP that sticks in a bunch of printfs so the /dev/console output explains what it's doing. ("could not exec /init out of initramfs (errno %d, file %s), falling back to root=\nAdd blather=1 to kernel cmdline to see cpio filenames/permissions.", and so on. Where "actual exec" shows where your dynamic linker is when that's what wasn't there.)

Rob

author
#7 lore raw
Quoted 28 lines · Rob Landley
Quoted 18 lines · Mimi Zohar
Quoted 9 lines · Christophe Fillot
Quoted 3 lines

Are you using an initrd not an initramfs? According to Documentation/filesystems/ramfs-rootfs-initramfs.txt, "If

CONFIG_TMPFS

Quoted 2 lines

is enabled, rootfs will use tmpfs instead of ramfs by default".

Yes, that what I thought too, but it seems that it is not really the case because of this test:

Quoted 7 lines
     if (IS_ENABLED(CONFIG_TMPFS) && !saved_root_name[0] &&
         (!root_fs_names || strstr(root_fs_names, "tmpfs"))) {
         err = shmem_init();
         is_tmpfs = true;
     } else {
         err = init_ramfs_fs();
     }
Quoted 8 lines

[CC'ing Rob Landley, lsm, lkml]

Thanks! "saved_root_name" is set to the boot command line "root=" option, which in my case is the UUID. I'm not sure why real root should impact the initramfs tmpfs/ramfs decision.

Unless there is a good explanation, did you want to post a patch to remove the test?

Quoted 8 lines

I added support last year, here's the start of the patch series:

https://lkml.org/lkml/2013/6/29/101

The logic is that if you specify a fallback root via root=, then you're not staying on rootfs (that's what root= _means_, "here is the root filesystem the kernel is to mount over rootfs"), and thus the extra infrastructure for tmpfs instead of ramfs is unnecessary.

Thanks Rob for the explanation. The problem is that ramfs does not support extended attributes, while tmpfs does. The boot loader could "measure" (trusted boot) the initramfs, but as the initramfs is generated on the target system, the initramfs is not signed, preventing it from being appraised (secure Boot). To close the initramfs integrity appraisal gap requires verifying the individual initramfs file signatures, which are stored as extended attributes.

Quoted 6 lines

I keep encountering people who set root=/dev/ram0 because they think that means initrd (it doesn't), and then they feed in a cpio archive (that's a third state even before you get to the ramfs/tmpfs distinction), and they always want to change the code to make what they asked it to do not be crazy...

Quoted 7 lines

Possibly the documentation needs to elaborate, but I expect what we really need is a CONFIG_VERBOSE_ROOT_SETUP that sticks in a bunch of printfs so the /dev/console output explains what it's doing. ("could not exec /init out of initramfs (errno %d, file %s), falling back to root=\nAdd blather=1 to kernel cmdline to see cpio filenames/permissions.", and so on. Where "actual exec" shows where your dynamic linker is when that's what wasn't there.)

To add to the confusion Documentation/filesystems/ramfs-rootfs-initramfs.txt says, "If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by default." This statement should be modified to reflect the actual code.

Mimi

#8 lore raw
Quoted 33 lines · Mimi Zohar
Quoted 32 lines · Rob Landley
Quoted 18 lines · Mimi Zohar
Quoted 9 lines · Christophe Fillot
Quoted 3 lines

Are you using an initrd not an initramfs? According to Documentation/filesystems/ramfs-rootfs-initramfs.txt, "If

CONFIG_TMPFS

Quoted 2 lines

is enabled, rootfs will use tmpfs instead of ramfs by default".

Yes, that what I thought too, but it seems that it is not really the case because of this test:

Quoted 7 lines
     if (IS_ENABLED(CONFIG_TMPFS) && !saved_root_name[0] &&
         (!root_fs_names || strstr(root_fs_names, "tmpfs"))) {
         err = shmem_init();
         is_tmpfs = true;
     } else {
         err = init_ramfs_fs();
     }
Quoted 8 lines

[CC'ing Rob Landley, lsm, lkml]

Thanks! "saved_root_name" is set to the boot command line "root=" option, which in my case is the UUID. I'm not sure why real root should impact the initramfs tmpfs/ramfs decision.

Unless there is a good explanation, did you want to post a patch to remove the test?

I added support last year, here's the start of the patch series:

https://lkml.org/lkml/2013/6/29/101

Quoted 7 lines
Quoted 4 lines

The logic is that if you specify a fallback root via root=, then you're not staying on rootfs (that's what root= _means_, "here is the root filesystem the kernel is to mount over rootfs"), and thus the extra infrastructure for tmpfs instead of ramfs is unnecessary.

Thanks Rob for the explanation. The problem is that ramfs does not support extended attributes, while tmpfs does.

If you're _using_ initramfs/initmpfs, there's no reason to specify a root=.

Quoted 6 lines

The boot loader could
"measure" (trusted boot) the initramfs, but as the initramfs is generated on the target system, the initramfs is not signed, preventing it from being appraised (secure Boot). To close the initramfs integrity appraisal gap requires verifying the individual initramfs file signatures, which are stored as extended attributes.

Faced with the phrases "trusted boot" and "integrity appraisal", I plead the third.

(In the wake of the Snowden infodump, people no longer want to use the elliptic curve cryptography the NSA designed, but they still happily base their system configuration on SELinux with a stack of thousands of rules you just have to take on faith. Possibly they're unaware the NSA designed and still maintains SELinux? Dunno...)

Quoted 8 lines
Quoted 7 lines

Possibly the documentation needs to elaborate, but I expect what we really need is a CONFIG_VERBOSE_ROOT_SETUP that sticks in a bunch of printfs so the /dev/console output explains what it's doing. ("could not exec /init out of initramfs (errno %d, file %s), falling back to root=\nAdd blather=1 to kernel cmdline to see cpio filenames/permissions.", and so on. Where "actual exec" shows where your dynamic linker is when that's what wasn't there.)

Quoted 4 lines

To add to the confusion Documentation/filesystems/ramfs-rootfs-initramfs.txt says, "If CONFIG_TMPFS is enabled, rootfs will use tmpfs instead of ramfs by default." This statement should be modified to reflect the actual code.

Actually I modified the code to reflect the documentation last year. (I wrote the docs in 2005, the initmpfs code in 2013.)

The rootfs code _does_ use tmpfs by default. Specifying root= disables it, because it indicates you aren't using ramfs but are requesting the kernel overmount it with another filesystem before launching PID 1.

That's what root= _means_.

I can add a paragraph describing what root= means and that it's inappropriate to use it with ramfs in general? (And that root=/dev/ram0 is a nonsensical option despite what some bits of the internet seem to think.)

Quoted 1 line

Mimi

Rob

author
#9 lore raw
Quoted 40 lines · Rob Landley
Quoted 38 lines · Mimi Zohar
Quoted 36 lines · Rob Landley
Quoted 18 lines · Mimi Zohar
Quoted 9 lines · Christophe Fillot
Quoted 3 lines

Are you using an initrd not an initramfs? According to Documentation/filesystems/ramfs-rootfs-initramfs.txt, "If

CONFIG_TMPFS

Quoted 2 lines

is enabled, rootfs will use tmpfs instead of ramfs by default".

Yes, that what I thought too, but it seems that it is not really the case because of this test:

Quoted 7 lines
     if (IS_ENABLED(CONFIG_TMPFS) && !saved_root_name[0] &&
         (!root_fs_names || strstr(root_fs_names, "tmpfs"))) {
         err = shmem_init();
         is_tmpfs = true;
     } else {
         err = init_ramfs_fs();
     }
Quoted 8 lines

[CC'ing Rob Landley, lsm, lkml]

Thanks! "saved_root_name" is set to the boot command line "root=" option, which in my case is the UUID. I'm not sure why real root should impact the initramfs tmpfs/ramfs decision.

Unless there is a good explanation, did you want to post a patch to remove the test?

I added support last year, here's the start of the patch series:

https://lkml.org/lkml/2013/6/29/101

The logic is that if you specify a fallback root via root=, then you're not staying on rootfs (that's what root= _means_, "here is the root filesystem the kernel is to mount over rootfs"), and thus the extra infrastructure for tmpfs instead of ramfs is unnecessary.

Quoted 4 lines
Quoted 2 lines

Thanks Rob for the explanation. The problem is that ramfs does not support extended attributes, while tmpfs does.

If you're _using_ initramfs/initmpfs, there's no reason to specify a root=.

The menu entry looks like:
linux /vmlinuz-3.17.0+ root=UUID=94595ff7-0fd4-4ea3-99f2-f7ddf8fbc91f
ro ...
initrd /initramfs-3.17.0+.img

Because "root=" is specified, rootfs is not using tmpfs.

Quoted 9 lines
Quoted 6 lines

The boot loader could
"measure" (trusted boot) the initramfs, but as the initramfs is generated on the target system, the initramfs is not signed, preventing it from being appraised (secure Boot). To close the initramfs integrity appraisal gap requires verifying the individual initramfs file signatures, which are stored as extended attributes.

Faced with the phrases "trusted boot" and "integrity appraisal", I plead the third.

Fine. Bottom line, rootfs needs to support extended attributes.

Quoted 1 line

(In the wake of the Snowden infodump,

All the more reason to allow only those files that are properly signed to be read/executed.

Mimi

#10 lore raw
Quoted 4 lines · Mimi Zohar
Quoted 3 lines · Rob Landley
Quoted 2 lines

Thanks Rob for the explanation. The problem is that ramfs does not support extended attributes, while tmpfs does.

Quoted 8 lines
Quoted 1 line

If you're _using_ initramfs/initmpfs, there's no reason to specify a root=.

The menu entry looks like:
linux /vmlinuz-3.17.0+ root=UUID=94595ff7-0fd4-4ea3-99f2-f7ddf8fbc91f
ro ...
initrd /initramfs-3.17.0+.img

Because "root=" is specified, rootfs is not using tmpfs.

Yes. Pilot error.

If you want tmpfs to switch to UUID $THINGY you can do ROOT= and have it use that. You're asking for something to be interpreted by the kernel sometimes and passed on to userspace other times and have no side effects even though it's interpeted by the kernel.

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines

The boot loader could
"measure" (trusted boot) the initramfs, but as the initramfs is generated on the target system, the initramfs is not signed, preventing it from being appraised (secure Boot). To close the initramfs integrity appraisal gap requires verifying the individual initramfs file signatures, which are stored as extended attributes.

Faced with the phrases "trusted boot" and "integrity appraisal", I plead the third.

Fine. Bottom line, rootfs needs to support extended attributes.

I added a patch to make it work as tmpfs a year ago. You now know what trivial configuration mistake you make that's preventing it from working. If you'd like me to submit a documentation update patch to make it easier to avoid in future, I can do that.

Quoted 4 lines
Quoted 1 line

(In the wake of the Snowden infodump,

All the more reason to allow only those files that are properly signed to be read/executed.

Using the infrastructure the NSA provided, which is intentionally so complicated that "you are not expected to understand this".

Good luck with that.

Quoted 1 line

Mimi

Rob

#11 lore raw
In reply to Mimi Zohar
Quoted 7 lines · Mimi Zohar

Thanks Rob for the explanation. The problem is that ramfs does not support extended attributes, while tmpfs does. The boot loader could "measure" (trusted boot) the initramfs, but as the initramfs is generated on the target system, the initramfs is not signed, preventing it from being appraised (secure Boot). To close the initramfs integrity appraisal gap requires verifying the individual initramfs file signatures, which are stored as extended attributes.

what's the point of checking the files on the filesystem against signatures stored on the same filesystem? If someone could alter the file contents they can alter the signatures as well.

David Lang

author
#12 lore raw
Quoted 10 lines · David Lang
Quoted 7 lines · Mimi Zohar

Thanks Rob for the explanation. The problem is that ramfs does not support extended attributes, while tmpfs does. The boot loader could "measure" (trusted boot) the initramfs, but as the initramfs is generated on the target system, the initramfs is not signed, preventing it from being appraised (secure Boot). To close the initramfs integrity appraisal gap requires verifying the individual initramfs file signatures, which are stored as extended attributes.

Quoted 3 lines

what's the point of checking the files on the filesystem against signatures stored on the same filesystem? If someone could alter the file contents they can alter the signatures as well.

It's all about limiting which public keys can be used to verify the file signatures. As of 3.17, only keys signed by a "trusted" key on the system keyring may be added to the IMA keyring.

Mimi