From 51c9a1e662b08bdf53ffd0afa0d490595d96bac8 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 2 Nov 2003 17:44:08 -0800 Subject: [PATCH] Only truncate file types that can be truncated on minixfs. Only regular files, directories and symbolic links can have any blocks allocated to them - other types of files have different metadata in their inodes and should not get to the truncation paths. Enforce this in fs/minix/inode.c. Without this, deleting a block or character device can cause minix filesystem corruption. Noted by Konstantin Boldyshev. --- fs/minix/inode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/minix/inode.c b/fs/minix/inode.c index 946f5812efc1d..11dab7f1a0082 100644 --- a/fs/minix/inode.c +++ b/fs/minix/inode.c @@ -547,6 +547,8 @@ int minix_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *sta */ void minix_truncate(struct inode * inode) { + if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) + return; if (INODE_VERSION(inode) == MINIX_V1) V1_minix_truncate(inode); else -- 2.53.0