Kernel oops: NULL pointer dereference in cifs_ioctl on 2.6.37-rc1
Subsystems (2)
After upgrading from 2.6.36 for other reasons, starting certain apps like wine utorrent.exe will cause a kernel oops. I run the x86_64 version of Ubuntu 10.10 with various modified packages all around and the 2.6.37-rc1 kernel from the kernel PPA team. I experienced the same with a kernel I tried compiling myself too.
Nov 7 17:25:50 wodan kernel: [77498.450787] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 Nov 7 17:25:50 wodan kernel: [77498.450883] IP: [<ffffffffa0395729>] cifs_ioctl+0x39/0x2f0 [cifs] Nov 7 17:25:50 wodan kernel: [77498.450987] PGD 1836a067 PUD 5bfac067 PMD 17d2b067 PTE 0 Nov 7 17:25:50 wodan kernel: [77498.451234] CPU 4 Nov 7 17:25:50 wodan kernel: [77498.451264] Modules linked in: binfmt_misc vboxnetadp vboxnetflt vboxdrv snd_hda_codec_hdmi snd_hda_codec_realtek nls_cp437 cifs snd_hda_intel snd_hda_codec snd_seq_midi snd_rawmidi snd_hwdep snd_pcm snd_seq_midi_event snd_seq snd_timer snd_seq_device ppdev lp parport_pc serio_raw snd shpchp soundcore parport joydev snd_page_alloc sha256_generic cryptd aes_x86_64 aes_generic dm_crypt radeon ttm usbhid ahci hid drm_kms_helper r8169 libahci pata_jmicron drm mii floppy i2c_algo_bit Nov 7 17:25:50 wodan kernel: [77498.451845] Nov 7 17:25:50 wodan kernel: [77498.451865] Pid: 4386, comm: utorrent.exe Not tainted 2.6.37-020637rc1-generic #201011020905 P55-UD3R/P55-UD3R Nov 7 17:25:50 wodan kernel: [77498.451971] RIP: 0010:[<ffffffffa0395729>] [<ffffffffa0395729>] cifs_ioctl+0x39/0x2f0 [cifs] Nov 7 17:25:50 wodan kernel: [77498.452074] RSP: 0018:ffff880018899e98 EFLAGS: 00010282 Nov 7 17:25:50 wodan kernel: [77498.452131] RAX: ffff880207a08300 RBX: ffff88005c884780 RCX: 0000000000222000 Nov 7 17:25:50 wodan kernel: [77498.452207] RDX: 0000000000222000 RSI: 0000000082187201 RDI: ffff88005c884780 Nov 7 17:25:50 wodan kernel: [77498.452282] RBP: ffff880018899ee8 R08: 000000000000001c R09: 00000000007bf700 Nov 7 17:25:50 wodan kernel: [77498.452358] R10: ffff880018898000 R11: 0000000000000000 R12: 0000000082187201 Nov 7 17:25:50 wodan kernel: [77498.452433] R13: 0000000000000000 R14: 0000000000222000 R15: ffff880207a4c2c0 Nov 7 17:25:50 wodan kernel: [77498.452510] FS: 000000007ffd8000(0063) GS:ffff8800df900000(006b) knlGS:00000000f74426c0 Nov 7 17:25:50 wodan kernel: [77498.452595] CS: 0010 DS: 002b ES: 002b CR0: 000000008005003b Nov 7 17:25:50 wodan kernel: [77498.452656] CR2: 0000000000000040 CR3: 000000005b77e000 CR4: 00000000000026e0 Nov 7 17:25:50 wodan kernel: [77498.452732] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 Nov 7 17:25:50 wodan kernel: [77498.452808] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Nov 7 17:25:50 wodan kernel: [77498.452884] Process utorrent.exe (pid: 4386, threadinfo ffff880018898000, task ffff8800188bdb00) Nov 7 17:25:50 wodan kernel: [77498.452999] 00000000fffffff7 ffff880018899ef8 0000000000000000 0000000000000000 Nov 7 17:25:50 wodan kernel: [77498.453084] ffff880018899ee8 0000000000000000 0000000000222000 ffff88005c884780 Nov 7 17:25:50 wodan kernel: [77498.453169] 0000000000222000 000000000000001c ffff880018899ef8 ffffffff8116e94d Nov 7 17:25:50 wodan kernel: [77498.453287] [<ffffffff8116e94d>] vfs_ioctl+0x1d/0x50 Nov 7 17:25:50 wodan kernel: [77498.453343] [<ffffffff8116f52d>] do_vfs_ioctl+0x7d/0x1f0 Nov 7 17:25:50 wodan kernel: [77498.453405] [<ffffffff811a5c62>] compat_sys_ioctl+0x122/0x200 Nov 7 17:25:50 wodan kernel: [77498.453470] [<ffffffff81048560>] sysenter_dispatch+0x7/0x2e Nov 7 17:25:50 wodan kernel: [77498.454010] RSP <ffff880018899e98> Nov 7 17:25:50 wodan kernel: [77498.478707] ---[ end trace 4e689dcb8ba02a93 ]---
Hopefully this makes more sense to someone than it does to me :)
Regards,
Kjell Rune
A message that is not in the archive (sent off-list or not yet received): 484246.91210.qm-ZxlQ8pIuIvXGRxTy+Q50vsz6deESKz/[email protected]
Quoted 32 lines · On Sun, 7 Nov 2010 16:44:46 +0000 (GMT) Kjell Rune Skaaraas…
After upgrading from 2.6.36 for other reasons, starting certain apps like wine utorrent.exe will cause a kernel oops. I run the
x86_64version of Ubuntu 10.10 with various modified packages all around and the 2.6.37-rc1 kernel from the kernel PPA team. I experienced the same with a kernel I tried compiling myself too.Nov 7 17:25:50 wodan kernel: [77498.450787] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 Nov 7 17:25:50 wodan kernel: [77498.450883] IP: [<ffffffffa0395729>] cifs_ioctl+0x39/0x2f0 [cifs] Nov 7 17:25:50 wodan kernel: [77498.450987] PGD 1836a067 PUD 5bfac067 PMD 17d2b067 PTE 0 Nov 7 17:25:50 wodan kernel: [77498.451234] CPU 4 Nov 7 17:25:50 wodan kernel: [77498.451264] Modules linked in: binfmt_misc vboxnetadp vboxnetflt vboxdrv snd_hda_codec_hdmi snd_hda_codec_realtek nls_cp437 cifs snd_hda_intel snd_hda_codec snd_seq_midi snd_rawmidi snd_hwdep snd_pcm snd_seq_midi_event snd_seq snd_timer snd_seq_device ppdev lp parport_pc serio_raw snd shpchp soundcore parport joydev snd_page_alloc sha256_generic cryptd aes_x86_64 aes_generic dm_crypt radeon ttm usbhid ahci hid drm_kms_helper r8169 libahci pata_jmicron drm mii floppy i2c_algo_bit Nov 7 17:25:50 wodan kernel: [77498.451845] Nov 7 17:25:50 wodan kernel: [77498.451865] Pid: 4386, comm: utorrent.exe Not tainted 2.6.37-020637rc1-generic #201011020905 P55-UD3R/P55-UD3R Nov 7 17:25:50 wodan kernel: [77498.451971] RIP: 0010:[<ffffffffa0395729>] [<ffffffffa0395729>] cifs_ioctl+0x39/0x2f0 [cifs] Nov 7 17:25:50 wodan kernel: [77498.452074] RSP: 0018:ffff880018899e98 EFLAGS: 00010282 Nov 7 17:25:50 wodan kernel: [77498.452131] RAX: ffff880207a08300 RBX: ffff88005c884780 RCX: 0000000000222000 Nov 7 17:25:50 wodan kernel: [77498.452207] RDX: 0000000000222000 RSI: 0000000082187201 RDI: ffff88005c884780 Nov 7 17:25:50 wodan kernel: [77498.452282] RBP: ffff880018899ee8 R08: 000000000000001c R09: 00000000007bf700 Nov 7 17:25:50 wodan kernel: [77498.452358] R10: ffff880018898000 R11: 0000000000000000 R12: 0000000082187201 Nov 7 17:25:50 wodan kernel: [77498.452433] R13: 0000000000000000 R14: 0000000000222000 R15: ffff880207a4c2c0 Nov 7 17:25:50 wodan kernel: [77498.452510] FS: 000000007ffd8000(0063) GS:ffff8800df900000(006b) knlGS:00000000f74426c0 Nov 7 17:25:50 wodan kernel: [77498.452595] CS: 0010 DS: 002b ES: 002b CR0: 000000008005003b Nov 7 17:25:50 wodan kernel: [77498.452656] CR2: 0000000000000040 CR3: 000000005b77e000 CR4: 00000000000026e0 Nov 7 17:25:50 wodan kernel: [77498.452732] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 Nov 7 17:25:50 wodan kernel: [77498.452808] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Nov 7 17:25:50 wodan kernel: [77498.452884] Process utorrent.exe (pid: 4386, threadinfo ffff880018898000, task ffff8800188bdb00) Nov 7 17:25:50 wodan kernel: [77498.452999] 00000000fffffff7 ffff880018899ef8 0000000000000000 0000000000000000 Nov 7 17:25:50 wodan kernel: [77498.453084] ffff880018899ee8 0000000000000000 0000000000222000 ffff88005c884780 Nov 7 17:25:50 wodan kernel: [77498.453169] 0000000000222000 000000000000001c ffff880018899ef8 ffffffff8116e94d Nov 7 17:25:50 wodan kernel: [77498.453287] [<ffffffff8116e94d>] vfs_ioctl+0x1d/0x50 Nov 7 17:25:50 wodan kernel: [77498.453343] [<ffffffff8116f52d>] do_vfs_ioctl+0x7d/0x1f0 Nov 7 17:25:50 wodan kernel: [77498.453405] [<ffffffff811a5c62>] compat_sys_ioctl+0x122/0x200 Nov 7 17:25:50 wodan kernel: [77498.453470] [<ffffffff81048560>] sysenter_dispatch+0x7/0x2e Nov 7 17:25:50 wodan kernel: [77498.454010] RSP <ffff880018899e98> Nov 7 17:25:50 wodan kernel: [77498.478707] ---[ end trace 4e689dcb8ba02a93 ]---
Quoted 2 lines
Hopefully this makes more sense to someone than it does to me :)
Could you follow the directions here and send along the output? That will tell us where it's panicing:
http://wiki.samba.org/index.php/LinuxCIFS_troubleshooting#Oopses
Many Thanks,
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20101107211202.3b3468dd-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org
3 Changesets affected this function in 2.6.37, but nothing particularly obvious. From a quick glance at objdump it may be around the line:
cifs_sb = CIFS_SB(inode->i_sb);
Quoted 51 lines · Jeff Layton
Quoted 32 lines · On Sun, 7 Nov 2010 16:44:46 +0000 (GMT) Kjell Rune Skaaraas…
After upgrading from 2.6.36 for other reasons, starting certain apps like wine utorrent.exe will cause a kernel oops. I run the
x86_64version of Ubuntu 10.10 with various modified packages all around and the 2.6.37-rc1 kernel from the kernel PPA team. I experienced the same with a kernel I tried compiling myself too.Nov 7 17:25:50 wodan kernel: [77498.450787] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040
Nov 7 17:25:50 wodan kernel: [77498.450883] IP: [<ffffffffa0395729>]cifs_ioctl+0x39/0x2f0[cifs]
Nov 7 17:25:50 wodan kernel: [77498.450987] PGD1836a067PUD5bfac067PMD17d2b067PTE 0
Nov 7 17:25:50 wodan kernel: [77498.451234] CPU 4
Nov 7 17:25:50 wodan kernel: [77498.451264] Modules linked in:binfmt_miscvboxnetadp vboxnetflt vboxdrvsnd_hda_codec_hdmisnd_hda_codec_realteknls_cp437cifssnd_hda_intelsnd_hda_codecsnd_seq_midisnd_rawmidisnd_hwdepsnd_pcmsnd_seq_midi_eventsnd_seqsnd_timersnd_seq_deviceppdev lpparport_pcserio_rawsnd shpchp soundcore parport joydevsnd_page_allocsha256_genericcryptdaes_x86_64aes_genericdm_cryptradeon ttm usbhid ahci hiddrm_kms_helperr8169 libahcipata_jmicrondrm mii floppyi2c_algo_bitNov 7 17:25:50 wodan kernel: [77498.451845]
Nov 7 17:25:50 wodan kernel: [77498.451865] Pid: 4386, comm: utorrent.exe Not tainted 2.6.37-020637rc1-generic #201011020905 P55-UD3R/P55-UD3R
Nov 7 17:25:50 wodan kernel: [77498.451971] RIP: 0010:[<ffffffffa0395729>] [<ffffffffa0395729>]cifs_ioctl+0x39/0x2f0[cifs]
Nov 7 17:25:50 wodan kernel: [77498.452074] RSP: 0018:ffff880018899e98 EFLAGS: 00010282
Nov 7 17:25:50 wodan kernel: [77498.452131] RAX:ffff880207a08300RBX:ffff88005c884780RCX: 0000000000222000
Nov 7 17:25:50 wodan kernel: [77498.452207] RDX: 0000000000222000 RSI: 0000000082187201 RDI:ffff88005c884780
Nov 7 17:25:50 wodan kernel: [77498.452282] RBP:ffff880018899ee8R08:000000000000001cR09:00000000007bf700
Nov 7 17:25:50 wodan kernel: [77498.452358] R10:ffff880018898000R11: 0000000000000000 R12: 0000000082187201
Nov 7 17:25:50 wodan kernel: [77498.452433] R13: 0000000000000000 R14: 0000000000222000 R15:ffff880207a4c2c0
Nov 7 17:25:50 wodan kernel: [77498.452510] FS: 000000007ffd8000(0063) GS:ffff8800df900000(006b) knlGS:00000000f74426c0
Nov 7 17:25:50 wodan kernel: [77498.452595] CS: 0010 DS: 002b ES: 002b CR0:000000008005003b
Nov 7 17:25:50 wodan kernel: [77498.452656] CR2: 0000000000000040 CR3:000000005b77e000CR4:00000000000026e0
Nov 7 17:25:50 wodan kernel: [77498.452732] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
Nov 7 17:25:50 wodan kernel: [77498.452808] DR3: 0000000000000000 DR6:00000000ffff0ff0DR7: 0000000000000400
Nov 7 17:25:50 wodan kernel: [77498.452884] Process utorrent.exe (pid: 4386, threadinfoffff880018898000, taskffff8800188bdb00)
Nov 7 17:25:50 wodan kernel: [77498.452999] 00000000fffffff7ffff880018899ef80000000000000000 0000000000000000
Nov 7 17:25:50 wodan kernel: [77498.453084] ffff880018899ee8 0000000000000000 0000000000222000ffff88005c884780
Nov 7 17:25:50 wodan kernel: [77498.453169] 0000000000222000000000000000001cffff880018899ef8ffffffff8116e94d
Nov 7 17:25:50 wodan kernel: [77498.453287] [<ffffffff8116e94d>]vfs_ioctl+0x1d/0x50
Nov 7 17:25:50 wodan kernel: [77498.453343] [<ffffffff8116f52d>]do_vfs_ioctl+0x7d/0x1f0
Nov 7 17:25:50 wodan kernel: [77498.453405] [<ffffffff811a5c62>]compat_sys_ioctl+0x122/0x200
Nov 7 17:25:50 wodan kernel: [77498.453470] [<ffffffff81048560>]sysenter_dispatch+0x7/0x2e
Nov 7 17:25:50 wodan kernel: [77498.454010] RSP <ffff880018899e98>
Nov 7 17:25:50 wodan kernel: [77498.478707] ---[ end trace4e689dcb8ba02a93]---Quoted 2 lines
Hopefully this makes more sense to someone than it does to me :)
Could you follow the directions here and send along the output? That will tell us where it's panicing:
http://wiki.samba.org/index.php/LinuxCIFS_troubleshooting#Oopses
Many Thanks,
--
Jeff Layton <[email protected]> --
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Thanks, Steve
A message that is not in the archive (sent off-list or not yet received): AANLkTikzTztJUP5-zHCKr4nzuG=bSzmZ+ga7dU0r3QPU-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 8 lines · Steve French
Quoted 7 lines · Jeff Layton
Quoted 4 lines · On Sun, 7 Nov 2010 16:44:46 +0000 (GMT) Kjell Rune Skaaraas…
After upgrading from 2.6.36 for other reasons, starting certain apps like wine utorrent.exe will cause a kernel oops. I run the
x86_64version of Ubuntu 10.10 with various modified packages all around and the 2.6.37-rc1 kernel from the kernel PPA team. I experienced the same with a kernel I tried compiling myself too.Nov ý7 17:25:50 wodan kernel: [77498.450787] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 Nov ý7 17:25:50 wodan kernel: [77498.450883] IP: [<
ffffffffa0395729>]cifs_ioctl+0x39/0x2f0[cifs]
Does the below patch fixes your problem?
From: Suresh Jayaraman <[email protected]>
Subject: [PATCH] cifs: fix a NULL pointer dereference in cifs_ioctl() when the fd is bad
The commit ba00ba modified cifs_ioctl() to use tcon pointer in cifsFileInfo via tlink instead of cifs_sb->tcon. When the file handle is not valid the cifsFileInfo->tlink will be NULL. Fix this by getting the tcon pointer by calling cifs_sb_master_tcon().
Here's a hackish reproducer:
#include <fcntl.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h>
#define CIFS_IOC_CHECKUMOUNT _IO(0xCF, 2)
int main (int argc, char* argv[])
{
int fd = open (argv[1], O_RDWR);
ioctl(fd, CIFS_IOC_CHECKUMOUNT);
close(fd);
return 0;
}This program will cause an oops when called with cifs mount point as an argument. I have tested the fix with the reproducer and it no longer oopses.
--- fs/cifs/ioctl.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
fs/cifs/ioctl.c +2 -4
@@ -35,10 +35,10 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)struct inode *inode = filep->f_dentry->d_inode;int rc = -ENOTTY ;/* strange error - but the precedent */ int xid; -struct cifs_sb_info *cifs_sb; +struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb);#ifdef CONFIG_CIFS_POSIX struct cifsFileInfo *pSMBFile = filep->private_data; -struct cifsTconInfo *tcon =tlink_tcon (pSMBFile->tlink); +struct cifsTconInfo *tcon =cifs_sb_master_tcon (cifs_sb);__u64 ExtAttrBits =0 ;__u64 ExtAttrMask =0 ;__u64 caps =le64_to_cpu (tcon->fsUnixInfo.Capability);
@@ -48,8 +48,6 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)cFYI (1 ,"ioctl file %p cmd %u arg %lu" , filep, command, arg); - cifs_sb =CIFS_SB (inode->i_sb); -switch (command) {case CIFS_IOC_CHECKUMOUNT :cFYI (1 ,"User unmount attempted" );
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 70 lines · On Mon, 08 Nov 2010 14:05:03 +0530 Suresh Jayaraman…
Quoted 8 lines · Steve French
Quoted 7 lines · Jeff Layton
Quoted 4 lines · On Sun, 7 Nov 2010 16:44:46 +0000 (GMT) Kjell Rune Skaaraas…
After upgrading from 2.6.36 for other reasons, starting certain apps like wine utorrent.exe will cause a kernel oops. I run the
x86_64version of Ubuntu 10.10 with various modified packages all around and the 2.6.37-rc1 kernel from the kernel PPA team. I experienced the same with a kernel I tried compiling myself too.Nov ý7 17:25:50 wodan kernel: [77498.450787] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 Nov ý7 17:25:50 wodan kernel: [77498.450883] IP: [<
ffffffffa0395729>]cifs_ioctl+0x39/0x2f0[cifs]Does the below patch fixes your problem?
From: Suresh Jayaraman <[email protected]>
Subject: [PATCH] cifs: fix a NULL pointer dereference incifs_ioctl()when the fd is badThe commit ba00ba modified
cifs_ioctl()to use tcon pointer in cifsFileInfo via tlink instead ofcifs_sb->tcon. When the file handle is not valid thecifsFileInfo->tlinkwill be NULL. Fix this by getting the tcon pointer by callingcifs_sb_master_tcon().Here's a hackish reproducer:
#include <fcntl.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h>#define
CIFS_IOC_CHECKUMOUNT_IO(0xCF, 2)int main (int argc, char* argv[])
{ int fd = open (argv[1], O_RDWR); ioctl(fd, CIFS_IOC_CHECKUMOUNT); close(fd); return 0; }This program will cause an oops when called with cifs mount point as an argument. I have tested the fix with the reproducer and it no longer oopses.
Reported-by Kjell Rune <[email protected]>Cc Jeff Layton <[email protected]>Signed-off-by Suresh Jayaraman <[email protected]>--- fs/cifs/ioctl.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)fs/cifs/ioctl.c +2
-2@@ -35,10 +35,10 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)struct inode *inode = filep->f_dentry->d_inode;int rc = -ENOTTY ;/* strange error - but the precedent */ int xid; -struct cifs_sb_info *cifs_sb; +struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb);#ifdef CONFIG_CIFS_POSIX struct cifsFileInfo *pSMBFile = filep->private_data; -struct cifsTconInfo *tcon =tlink_tcon (pSMBFile->tlink); +struct cifsTconInfo *tcon =cifs_sb_master_tcon (cifs_sb);__u64 ExtAttrBits =0 ;__u64 ExtAttrMask =0 ;__u64 caps =le64_to_cpu (tcon->fsUnixInfo.Capability);
fs/cifs/ioctl.c long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) · line 53
Quoted 8 lines
fs/cifs/ioctl.c +0
-2@@ -48,8 +48,6 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)cFYI (1 ,"ioctl file %p cmd %u arg %lu" , filep, command, arg); - cifs_sb =CIFS_SB (inode->i_sb); -switch (command) {case CIFS_IOC_CHECKUMOUNT :cFYI (1 ,"User unmount attempted" );
NAK. This will mean that you're allowing people to do ioctls against files using other people's credentials. If this is the problem then the correct fix is to make sure that a cifsFileInfo is allocated during the open.
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20101108061227.051706ff-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Quoted 76 lines · Jeff Layton
Quoted 73 lines · On Mon, 08 Nov 2010 14:05:03 +0530 Suresh Jayaraman…
Quoted 8 lines · Steve French
Quoted 7 lines · Jeff Layton
Quoted 4 lines · On Sun, 7 Nov 2010 16:44:46 +0000 (GMT) Kjell Rune Skaaraas…
After upgrading from 2.6.36 for other reasons, starting certain apps like wine utorrent.exe will cause a kernel oops. I run the
x86_64version of Ubuntu 10.10 with various modified packages all around and the 2.6.37-rc1 kernel from the kernel PPA team. I experienced the same with a kernel I tried compiling myself too.Nov �7 17:25:50 wodan kernel: [77498.450787] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 Nov �7 17:25:50 wodan kernel: [77498.450883] IP: [<
ffffffffa0395729>]cifs_ioctl+0x39/0x2f0[cifs]Does the below patch fixes your problem?
From: Suresh Jayaraman <[email protected]>
Subject: [PATCH] cifs: fix a NULL pointer dereference incifs_ioctl()when the fd is badThe commit ba00ba modified
cifs_ioctl()to use tcon pointer in cifsFileInfo via tlink instead ofcifs_sb->tcon. When the file handle is not valid thecifsFileInfo->tlinkwill be NULL. Fix this by getting the tcon pointer by callingcifs_sb_master_tcon().Here's a hackish reproducer:
#include <fcntl.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h>#define
CIFS_IOC_CHECKUMOUNT_IO(0xCF, 2)int main (int argc, char* argv[])
{ int fd = open (argv[1], O_RDWR); ioctl(fd, CIFS_IOC_CHECKUMOUNT); close(fd); return 0; }This program will cause an oops when called with cifs mount point as an argument. I have tested the fix with the reproducer and it no longer oopses.
Reported-by Kjell Rune <[email protected]>Cc Jeff Layton <[email protected]>Signed-off-by Suresh Jayaraman <[email protected]>--- fs/cifs/ioctl.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)fs/cifs/ioctl.c +2
-2@@ -35,10 +35,10 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)struct inode *inode = filep->f_dentry->d_inode;int rc = -ENOTTY ;/* strange error - but the precedent */ int xid; -struct cifs_sb_info *cifs_sb; +struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb);#ifdef CONFIG_CIFS_POSIX struct cifsFileInfo *pSMBFile = filep->private_data; -struct cifsTconInfo *tcon =tlink_tcon (pSMBFile->tlink); +struct cifsTconInfo *tcon =cifs_sb_master_tcon (cifs_sb);__u64 ExtAttrBits =0 ;__u64 ExtAttrMask =0 ;__u64 caps =le64_to_cpu (tcon->fsUnixInfo.Capability);@@ -48,8 +48,6 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)cFYI (1 ,"ioctl file %p cmd %u arg %lu" , filep, command, arg);
Quoted 7 lines
fs/cifs/ioctl.c long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) · line 53
Quoted 5 lines
fs/cifs/ioctl.c +0
-2- cifs_sb =CIFS_SB (inode->i_sb); -switch (command) {case CIFS_IOC_CHECKUMOUNT :cFYI (1 ,"User unmount attempted" );NAK. This will mean that you're allowing people to do ioctls against
I missed this.. though I was not quite sure about this patch..
Quoted 1 line
files using other people's credentials. If this is the problem then the
I'm sure the problem is pSMBFile->tlink is NULL. And this is because open() fails and the test program didn't check for the error and continues using the return value (in this case -1 which will be UNSIGNED_INT_MAX) in the ioctl. Since the file is actually not open, cifs_new_fileinfo() won't have a chance to setup pSMBFile->tlink properly.
Signature · 1 line
Suresh Jayaraman
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 87 lines · On Mon, 08 Nov 2010 16:51:02 +0530 Suresh Jayaraman…
Quoted 76 lines · Jeff Layton
Quoted 73 lines · On Mon, 08 Nov 2010 14:05:03 +0530 Suresh Jayaraman…
Quoted 8 lines · Steve French
Quoted 7 lines · Jeff Layton
Quoted 4 lines · On Sun, 7 Nov 2010 16:44:46 +0000 (GMT) Kjell Rune Skaaraas…
After upgrading from 2.6.36 for other reasons, starting certain apps like wine utorrent.exe will cause a kernel oops. I run the
x86_64version of Ubuntu 10.10 with various modified packages all around and the 2.6.37-rc1 kernel from the kernel PPA team. I experienced the same with a kernel I tried compiling myself too.Nov �7 17:25:50 wodan kernel: [77498.450787] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 Nov �7 17:25:50 wodan kernel: [77498.450883] IP: [<
ffffffffa0395729>]cifs_ioctl+0x39/0x2f0[cifs]Does the below patch fixes your problem?
From: Suresh Jayaraman <[email protected]>
Subject: [PATCH] cifs: fix a NULL pointer dereference incifs_ioctl()when the fd is badThe commit ba00ba modified
cifs_ioctl()to use tcon pointer in cifsFileInfo via tlink instead ofcifs_sb->tcon. When the file handle is not valid thecifsFileInfo->tlinkwill be NULL. Fix this by getting the tcon pointer by callingcifs_sb_master_tcon().Here's a hackish reproducer:
#include <fcntl.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h>#define
CIFS_IOC_CHECKUMOUNT_IO(0xCF, 2)int main (int argc, char* argv[])
{ int fd = open (argv[1], O_RDWR); ioctl(fd, CIFS_IOC_CHECKUMOUNT); close(fd); return 0; }This program will cause an oops when called with cifs mount point as an argument. I have tested the fix with the reproducer and it no longer oopses.
Reported-by Kjell Rune <[email protected]>Cc Jeff Layton <[email protected]>Signed-off-by Suresh Jayaraman <[email protected]>--- fs/cifs/ioctl.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)fs/cifs/ioctl.c +2
-2@@ -35,10 +35,10 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)struct inode *inode = filep->f_dentry->d_inode;int rc = -ENOTTY ;/* strange error - but the precedent */ int xid; -struct cifs_sb_info *cifs_sb; +struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb);#ifdef CONFIG_CIFS_POSIX struct cifsFileInfo *pSMBFile = filep->private_data; -struct cifsTconInfo *tcon =tlink_tcon (pSMBFile->tlink); +struct cifsTconInfo *tcon =cifs_sb_master_tcon (cifs_sb);__u64 ExtAttrBits =0 ;__u64 ExtAttrMask =0 ;__u64 caps =le64_to_cpu (tcon->fsUnixInfo.Capability);@@ -48,8 +48,6 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)cFYI (1 ,"ioctl file %p cmd %u arg %lu" , filep, command, arg);Quoted 7 lines
fs/cifs/ioctl.c long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) · line 53
Quoted 5 lines
fs/cifs/ioctl.c +0
-2- cifs_sb =CIFS_SB (inode->i_sb); -switch (command) {case CIFS_IOC_CHECKUMOUNT :cFYI (1 ,"User unmount attempted" );NAK. This will mean that you're allowing people to do ioctls against
I missed this.. though I was not quite sure about this patch..
Quoted 8 lines
Quoted 1 line
files using other people's credentials. If this is the problem then the
I'm sure the problem is
pSMBFile->tlinkis NULL. And this is becauseopen()fails and the test program didn't check for the error and continues using the return value (in this case -1 which will beUNSIGNED_INT_MAX) in the ioctl. Since the file is actually not open,cifs_new_fileinfo()won't have a chance to setuppSMBFile->tlinkproperly.
That doesn't sound right. The VFS shouldn't allow an ioctl on an invalid file descriptor...
It seems more likely that pSMBFile is actually NULL here. cifs doesn't have f_op->open routine for directories, so that's entirely handled at the VFS layer. The right fix is probably to add one, and make sure that filp->private_data is appropriately populated on the open call for directories.
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 32 lines · On Sun, 7 Nov 2010 16:44:46 +0000 (GMT) Kjell Rune Skaaraas…
After upgrading from 2.6.36 for other reasons, starting certain apps like wine utorrent.exe will cause a kernel oops. I run the
x86_64version of Ubuntu 10.10 with various modified packages all around and the 2.6.37-rc1 kernel from the kernel PPA team. I experienced the same with a kernel I tried compiling myself too.Nov 7 17:25:50 wodan kernel: [77498.450787] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 Nov 7 17:25:50 wodan kernel: [77498.450883] IP: [<ffffffffa0395729>] cifs_ioctl+0x39/0x2f0 [cifs] Nov 7 17:25:50 wodan kernel: [77498.450987] PGD 1836a067 PUD 5bfac067 PMD 17d2b067 PTE 0 Nov 7 17:25:50 wodan kernel: [77498.451234] CPU 4 Nov 7 17:25:50 wodan kernel: [77498.451264] Modules linked in: binfmt_misc vboxnetadp vboxnetflt vboxdrv snd_hda_codec_hdmi snd_hda_codec_realtek nls_cp437 cifs snd_hda_intel snd_hda_codec snd_seq_midi snd_rawmidi snd_hwdep snd_pcm snd_seq_midi_event snd_seq snd_timer snd_seq_device ppdev lp parport_pc serio_raw snd shpchp soundcore parport joydev snd_page_alloc sha256_generic cryptd aes_x86_64 aes_generic dm_crypt radeon ttm usbhid ahci hid drm_kms_helper r8169 libahci pata_jmicron drm mii floppy i2c_algo_bit Nov 7 17:25:50 wodan kernel: [77498.451845] Nov 7 17:25:50 wodan kernel: [77498.451865] Pid: 4386, comm: utorrent.exe Not tainted 2.6.37-020637rc1-generic #201011020905 P55-UD3R/P55-UD3R Nov 7 17:25:50 wodan kernel: [77498.451971] RIP: 0010:[<ffffffffa0395729>] [<ffffffffa0395729>] cifs_ioctl+0x39/0x2f0 [cifs] Nov 7 17:25:50 wodan kernel: [77498.452074] RSP: 0018:ffff880018899e98 EFLAGS: 00010282 Nov 7 17:25:50 wodan kernel: [77498.452131] RAX: ffff880207a08300 RBX: ffff88005c884780 RCX: 0000000000222000 Nov 7 17:25:50 wodan kernel: [77498.452207] RDX: 0000000000222000 RSI: 0000000082187201 RDI: ffff88005c884780 Nov 7 17:25:50 wodan kernel: [77498.452282] RBP: ffff880018899ee8 R08: 000000000000001c R09: 00000000007bf700 Nov 7 17:25:50 wodan kernel: [77498.452358] R10: ffff880018898000 R11: 0000000000000000 R12: 0000000082187201 Nov 7 17:25:50 wodan kernel: [77498.452433] R13: 0000000000000000 R14: 0000000000222000 R15: ffff880207a4c2c0 Nov 7 17:25:50 wodan kernel: [77498.452510] FS: 000000007ffd8000(0063) GS:ffff8800df900000(006b) knlGS:00000000f74426c0 Nov 7 17:25:50 wodan kernel: [77498.452595] CS: 0010 DS: 002b ES: 002b CR0: 000000008005003b Nov 7 17:25:50 wodan kernel: [77498.452656] CR2: 0000000000000040 CR3: 000000005b77e000 CR4: 00000000000026e0 Nov 7 17:25:50 wodan kernel: [77498.452732] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 Nov 7 17:25:50 wodan kernel: [77498.452808] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Nov 7 17:25:50 wodan kernel: [77498.452884] Process utorrent.exe (pid: 4386, threadinfo ffff880018898000, task ffff8800188bdb00) Nov 7 17:25:50 wodan kernel: [77498.452999] 00000000fffffff7 ffff880018899ef8 0000000000000000 0000000000000000 Nov 7 17:25:50 wodan kernel: [77498.453084] ffff880018899ee8 0000000000000000 0000000000222000 ffff88005c884780 Nov 7 17:25:50 wodan kernel: [77498.453169] 0000000000222000 000000000000001c ffff880018899ef8 ffffffff8116e94d Nov 7 17:25:50 wodan kernel: [77498.453287] [<ffffffff8116e94d>] vfs_ioctl+0x1d/0x50 Nov 7 17:25:50 wodan kernel: [77498.453343] [<ffffffff8116f52d>] do_vfs_ioctl+0x7d/0x1f0 Nov 7 17:25:50 wodan kernel: [77498.453405] [<ffffffff811a5c62>] compat_sys_ioctl+0x122/0x200 Nov 7 17:25:50 wodan kernel: [77498.453470] [<ffffffff81048560>] sysenter_dispatch+0x7/0x2e Nov 7 17:25:50 wodan kernel: [77498.454010] RSP <ffff880018899e98> Nov 7 17:25:50 wodan kernel: [77498.478707] ---[ end trace 4e689dcb8ba02a93 ]---
Quoted 2 lines
Hopefully this makes more sense to someone than it does to me :)
Ok, the patch I just sent to the list seems to fix this for me and this is clearly our bug. But, I have to wonder -- what is wine doing running ioctls against files?
Signature · 1 line
Jeff Layton <[email protected]>