Skip to content

Commit 8b4bc20

Browse files
James Bottomleyardbiesheuvel
authored andcommitted
efivarfs: prevent setting of zero size on the inodes in the cache
Current efivarfs uses simple_setattr which allows the setting of any size in the inode cache. This is wrong because a zero size file is used to indicate an "uncommitted" variable, so by simple means of truncating the file (as root) any variable may be turned to look like it's uncommitted. Fix by adding an efivarfs_setattr routine which does not allow updating of the cached inode size (which now only comes from the underlying variable). Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent 19fdc68 commit 8b4bc20

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

fs/efivarfs/inode.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,24 @@ efivarfs_fileattr_set(struct mnt_idmap *idmap,
187187
return 0;
188188
}
189189

190+
/* copy of simple_setattr except that it doesn't do i_size updates */
191+
static int efivarfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
192+
struct iattr *iattr)
193+
{
194+
struct inode *inode = d_inode(dentry);
195+
int error;
196+
197+
error = setattr_prepare(idmap, dentry, iattr);
198+
if (error)
199+
return error;
200+
201+
setattr_copy(idmap, inode, iattr);
202+
mark_inode_dirty(inode);
203+
return 0;
204+
}
205+
190206
static const struct inode_operations efivarfs_file_inode_operations = {
191207
.fileattr_get = efivarfs_fileattr_get,
192208
.fileattr_set = efivarfs_fileattr_set,
209+
.setattr = efivarfs_setattr,
193210
};

0 commit comments

Comments
 (0)