From: Eugene Teo Date: Tue, 14 Oct 2008 07:04:08 +0000 (+0800) Subject: CVE-2008-3275 Linux kernel local filesystem DoS X-Git-Url: http://git.osdn.net/view?p=linux-kernel-docs%2Flinux-2.4.36.git;a=commitdiff_plain;h=f23e4db5d0462de3a3e74686d7e1a4b708bef002 CVE-2008-3275 Linux kernel local filesystem DoS This is a backport for CVE-2008-3275. "Lookup can install a child dentry for a deleted directory. This keeps the directory dentry alive, and the inode pinned in the cache and on disk, even after all external references have gone away. This isn't a big problem normally, since memory pressure or umount will clear out the directory dentry and its children, releasing the inode. But for UBIFS this causes problems because its orphan area can overflow. Fix this by returning ENOENT for all lookups on a S_DEAD directory before creating a child dentry." Signed-off-by: Eugene Teo [ WT: problem and fix confirmed on ramfs using method described at http://lkml.org/lkml/2008/7/2/83 ] Signed-off-by: Willy Tarreau --- diff --git a/fs/namei.c b/fs/namei.c index 374b767b..54331623 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -296,7 +296,14 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, i */ result = d_lookup(parent, name); if (!result) { - struct dentry * dentry = d_alloc(parent, name); + struct dentry *dentry; + + /* Don't create child dentry for a dead directory. */ + result = ERR_PTR(-ENOENT); + if (IS_DEADDIR(dir)) + goto out_unlock; + + dentry = d_alloc(parent, name); result = ERR_PTR(-ENOMEM); if (dentry) { lock_kernel(); @@ -307,6 +314,7 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, i else result = dentry; } + out_unlock: up(&dir->i_sem); return result; } @@ -798,7 +806,14 @@ struct dentry * lookup_hash(struct qstr *name, struct dentry * base) dentry = cached_lookup(base, name, 0); if (!dentry) { - struct dentry *new = d_alloc(base, name); + struct dentry *new; + + /* Don't create child dentry for a dead directory. */ + dentry = ERR_PTR(-ENOENT); + if (IS_DEADDIR(inode)) + goto out; + + new = d_alloc(base, name); dentry = ERR_PTR(-ENOMEM); if (!new) goto out;