Re: 2.6.23-rc7-mm1 - 'touch' command causes Oops.

Christoph Hellwig
2007-09-24T12:05:26Z

On Mon, Sep 24, 2007 at 06:35:50AM -0400, Valdis.Kletnieks@vt.edu wrote:
> On Mon, 24 Sep 2007 02:17:16 PDT, Andrew Morton said:
>
> > ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.23-rc7/2.6.23-rc7-mm1/
>
> It lived fast, it died young, it didn't leave a pretty corpse...
>
> Something in the startup scripts did a 'touch', and ker-blam.
> [ 15.668000] Call Trace:
> [ 15.668000] [<ffffffff802a4d20>] mnt_want_write+0x49/0xb5
> [ 15.668000] [<ffffffff802ad288>] do_utimes+0xd0/0x220
> [ 15.668000] [<ffffffff8035437b>] __up_read+0x7a/0x83
> [ 15.668000] [<ffffffff8024b1af>] up_read+0x9/0xb
> [ 15.668000] [<ffffffff8051977c>] do_page_fault+0x421/0x7d0
> [ 15.668000] [<ffffffff8028b370>] do_filp_open+0x36/0x46
> [ 15.668000] [<ffffffff802ad519>] sys_utimensat+0x8b/0xa5
> [ 15.668000] [<ffffffff80517a4d>] error_exit+0x0/0x84
> [ 15.668000] [<ffffffff8020c10e>] system_call+0x7e/0x83

do_times passes an unitialized vfsmount into mnt_want_write. Here's
the quick fix (untested), but the right fix is to restructure the complete
mess do_utimes is (never let a libc developer write your kernel code.. :)):

Index: linux-2.6.23-rc6/fs/utimes.c
===================================================================
--- linux-2.6.23-rc6.orig/fs/utimes.c 2007-09-24 14:02:24.000000000 +0200
+++ linux-2.6.23-rc6/fs/utimes.c 2007-09-24 14:03:57.000000000 +0200
@@ -59,6 +59,7 @@ long do_utimes(int dfd, char __user *fil
struct inode *inode;
struct iattr newattrs;
struct file *f = NULL;
+ struct vfsmount *mnt;

error = -EINVAL;
if (times && (!nsec_valid(times[0].tv_nsec) ||
@@ -79,17 +80,19 @@ long do_utimes(int dfd, char __user *fil
if (!f)
goto out;
dentry = f->f_path.dentry;
+ mnt = f->f_path.mnt;
} else {
error = __user_walk_fd(dfd, filename, (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW, &nd);
if (error)
goto out;

dentry = nd.dentry;
+ mnt = nd.mnt;
}

inode = dentry->d_inode;

- error = mnt_want_write(nd.mnt);
+ error = mnt_want_write(mnt);
if (error)
goto dput_and_out;