Skip to content

Commit faf9948

Browse files
stefanbergermimizohar
authored andcommitted
evm: Use the metadata inode to calculate metadata hash
Changes to file attributes (mode bits, uid, gid) on the lower layer are not taken into account when d_backing_inode() is used when a file is accessed on the overlay layer and this file has not yet been copied up. This is because d_backing_inode() does not return the real inode of the lower layer but instead returns the backing inode which in this case holds wrong file attributes. Further, when CONFIG_OVERLAY_FS_METACOPY is enabled and a copy-up is triggered due to file metadata changes, then the metadata are held by the backing inode while the data are still held by the real inode. Therefore, use d_inode(d_real(dentry, D_REAL_METADATA)) to get to the file's metadata inode and use it to calculate the metadata hash with. Co-developed-by: Mimi Zohar <[email protected]> Signed-off-by: Stefan Berger <[email protected]> Acked-by: Amir Goldstein <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent f2b3fc4 commit faf9948

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

security/integrity/evm/evm_crypto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
223223
size_t req_xattr_value_len,
224224
uint8_t type, struct evm_digest *data)
225225
{
226-
struct inode *inode = d_backing_inode(dentry);
226+
struct inode *inode = d_inode(d_real(dentry, D_REAL_METADATA));
227227
struct xattr_list *xattr;
228228
struct shash_desc *desc;
229229
size_t xattr_size = 0;

0 commit comments

Comments
 (0)