]> www.infradead.org Git - mtd-utils.git/commit
mkfs.ubifs: Optionally create extended attribute with inode number
authorSascha Hauer <s.hauer@pengutronix.de>
Thu, 12 Nov 2015 09:31:28 +0000 (10:31 +0100)
committerRichard Weinberger <richard@nod.at>
Thu, 12 Nov 2015 09:50:04 +0000 (10:50 +0100)
commit803b8ddbaea4f049cbf360682e80bc2f1aea12e2
treef9a3402d1260a84fd51cb46822fd89b0ea63db18
parent50044efbd6e713e86f705a60eddab0c034dffeba
mkfs.ubifs: Optionally create extended attribute with inode number

This is done to allow creating images suitable for IMA directory
appraisal. IMA creates a hash for directories and attaches this
hash to the directory itself as an extended attribute. Among other
things the inode numbers of the files are hashed. So, to create
a valid hash in the UBIFS image the evmctl tool needs to know
the inode numbers which the files in the UBIFS image will have.
evmctl will read the inode numbers from the user.image-inode-number
extended attribute. Since extended attributes are inodes themselves
the inode numbers for the generated image will change when the
extended attributes change, so to generate a correctly hashed
UBIFS image, both evmctl and mkfs.ubifs must be run twice:

1) execute evmctl to iterate over the directory tree. This will
   create the security.ima and security.evm extended attributes.
   The existence of the attributes makes sure that subsequent
   calls to mkfs.ubifs will use the same inode numbers. evmctl
   will use the inode numbers from the host filesystem in this
   step which makes the resulting image unusable
2) execute mkfs.ubifs -a. This will create the user.image-inode-number
   extended attributes on files/directories added to the image.
3) execture evmctl again. This time evmctl will pick the inode
   numbers from the user.image-inode-number extended attribute
   instead of the ones from the host filesystem
4) execute mkfs.ubifs again. This will create the correct image.
   The now existing user.image-inode-number extended attributes
   are ignored and not added to the image.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
ubifs-utils/mkfs.ubifs/mkfs.ubifs.c