Messages in this thread Patch in this message | | | Date | Fri, 14 Nov 2008 02:37:22 +0000 (GMT) | From | Hugh Dickins <> | Subject | [PATCH 2.6.28?] don't unlink an active swapfile |
| |
Peter Cordes is sorry that he rm'ed his swapfiles while they were in use, he then had no pathname to swapoff. It's a curious little oversight, but not one worth a lot of hackery. Kudos to Willy Tarreau for turning this around from a discussion of synthetic pathnames to how to prevent unlink. Mimic immutable: prohibit unlinking an active swapfile in may_delete() (and don't worry my little head over the tiny race window).
Signed-off-by: Hugh Dickins <hugh@veritas.com> --- Perhaps this is too late for 2.6.28: your decision.
fs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
--- 2.6.28-rc4/fs/namei.c 2008-10-24 09:28:19.000000000 +0100 +++ linux/fs/namei.c 2008-11-12 11:52:44.000000000 +0000 @@ -1378,7 +1378,7 @@ static int may_delete(struct inode *dir, if (IS_APPEND(dir)) return -EPERM; if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)|| - IS_IMMUTABLE(victim->d_inode)) + IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode)) return -EPERM; if (isdir) { if (!S_ISDIR(victim->d_inode->i_mode))
| |