Comment 5 for bug 387073

Revision history for this message
Jeremy Kerr (jk-ozlabs) wrote :

Had a bit of time to look into this, hope this helps:

BUG: unable to handle kernel NULL pointer dereference at 0000000000000220
IP: [<ffffffff8112efd0>] touch_atime+0x20/0x150

ffffffff8102efb0 <touch_atime>:
ffffffff8112efb0: 55 push %rbp
ffffffff8112efb1: 48 89 e5 mov %rsp,%rbp
ffffffff8112efb4: 48 83 ec 30 sub $0x30,%rsp
ffffffff8112efb8: 48 89 5d f0 mov %rbx,-0x10(%rbp)
ffffffff8112efbc: 4c 89 65 f8 mov %r12,-0x8(%rbp)
ffffffff8112efc0: 48 89 fb mov %rdi,%rbx
ffffffff8112efc3: 4c 8b 66 10 mov 0x10(%rsi),%r12
ffffffff8112efc7: e8 94 36 00 00 callq 0xffffffff81132660
ffffffff8112efcc: 85 c0 test %eax,%eax
ffffffff8112efce: 75 13 jne 0xffffffff8112efe3
ffffffff8112efd0: 41 f6 84 24 20 02 00 testb $0x2,0x220(%r12)

From looking at the oops log, r12 is indeed 0. Referring to source of touch_atime:

void touch_atime(struct vfsmount *mnt, struct dentry *dentry)
{
 struct inode *inode = dentry->d_inode;
 struct timespec now;

 if (mnt_want_write(mnt))
  return;
 if (inode->i_flags & S_NOATIME)
  goto out;

We're oopsing on the ionode->i_flags dereference, so dentry->d_inode is NULL. I think it's safe to assume that this function should not be called on a negative dentry.

From a brief look at ecryptfs_read_update_atime, it seems that there is no reference on the "lower" dentry when it's added to d_fsdata, so perhaps we need a check for lower_dentry != NULL around that call to touch_atime. I'm not entirely sure that this is the correct solution, but we shouldn't be updating dentries for files that have been removed.