cifs_close: NULL pointer dereference
Hello,
I just hit a NULL pointer dereference in cifs_close while accessing a file on a remote Samba shared directory. The bug is reproducible, a simple:
touch foo; cat foo
is suffient to cause the OOPS. The machine is running kernel from git (1d80cac
- almost rc6), SMP w/ PREEMP. The remote server is running Samba 3.3.3. I don't use CIFS frequently, but at some point it was certainly working; I can try a bisection if you want.
BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [<ffffffffa05f105c>] cifs_close+0x1c1/0x2e8 [cifs] PGD 9205f067 PUD 8f56c067 PMD 0 Oops: 0002 [#1] PREEMPT SMP last sysfs file: /sys/devices/platform/coretemp.0/temp1_input CPU 0 Modules linked in: nls_iso8859_1 cifs radeon drm i2c_core af_packet binfmt_misc rfcomm l2cap kvm_intel kvm ipv6 acpi_cpufreq cpufreq_userspace cpufreq_stats cpufreq_conservative cpufreq_powersave cpufreq_ondemand freq_table deflate zlib_deflate twofish_x86_64 twofish_common aes_x86_64 aes_generic blowfish des_generic cbc sha256_generic sha1_generic af_key ext3 jbd coretemp hwmon microcode loop arc4 snd_hda_codec_realtek ecb btusb snd_hda_intel snd_hda_codec iwlagn bluetooth snd_hwdep iwlcore snd_pcm snd_seq rfkill snd_timer snd_seq_device mac80211 snd video soundcore snd_page_alloc psmouse cfg80211 pcspkr evdev asus_laptop output rtc_cmos rtc_core rtc_lib processor battery ac button ext4 mbcache jbd2 crc16 usbhid hid dm_mod sg sd_mod sr_mod cdrom ahci ata_piix ohci1394 sdhci_pci sdhci ieee1394 mmc_core led_class uhci_hcd libata scsi_mod ehci_hcd intel_agp usbcore thermal fan unix Pid: 17851, comm: cat Not tainted 2.6.30-rc5-00112-g1d80cac #110 F3Sa RIP: 0010:[<ffffffffa05f105c>] [<ffffffffa05f105c>] cifs_close+0x1c1/0x2e8 [cifs] RSP: 0018:ffff880098537e88 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff8800bdbe7100 RCX: ffff880098537e08 RDX: 0000000000000000 RSI: 00000000fffffff7 RDI: ffffffffa0616bc4 RBP: ffff880098537ec8 R08: ffff88009573c870 R09: ffff88009227c940 R10: ffff880098537c58 R11: ffff88008f65dad0 R12: 0000000000000000 R13: 000000000000000a R14: 0000000000000000 R15: ffff8800bdbe7170 FS: 00007f7e12bba6f0(0000) GS:ffff88000101c000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: 0000000000000008 CR3: 000000008f589000 CR4: 00000000000026e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process cat (pid: 17851, threadinfo ffff880098536000, task ffff88008f4c2b80) Stack: ffff8800922b5900 ffff88006e019008 00000c216e0191f0 0000000000000010 ffff88006e019008 ffff8800922b5900 ffff88006e019008 ffff8800be725100 ffff880098537f08 ffffffff802ad55f ffff88006e0cdc00 ffff8800922b5900 Call Trace: [<ffffffff802ad55f>] __fput+0xeb/0x1ac [<ffffffff802ad638>] fput+0x18/0x1a [<ffffffff802aa94c>] filp_close+0x67/0x72 [<ffffffff802aa9fc>] sys_close+0xa5/0xe4 [<ffffffff8020bbab>] system_call_fastpath+0x16/0x1b Code: 89 ef 45 31 e4 e8 f3 63 e7 df 41 bd 0a 00 00 00 48 c7 c7 c4 6b 61 a0 e8 b3 7f e7 df 48 8b 53 10 48 8b 43 18 48 c7 c7 c4 6b 61 a0 <48> 89 42 08 48 89 10 48 c7 43 18 00 02 20 00 48 8b 13 48 8b 43 RIP [<ffffffffa05f105c>] cifs_close+0x1c1/0x2e8 [cifs] RSP <ffff880098537e88> CR2: 0000000000000008 ---[ end trace c92994e7fd5bf7a2 ]---
note: cat[17851] exited with preempt_count 1
Quoted 3 lines · Luca Tettamanti
Hello,
I just hit a NULL pointer dereference incifs_closewhile accessing a file on a remote Samba shared directory.
[...]
Quoted 2 lines
BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [<ffffffffa05f105c>] cifs_close+0x1c1/0x2e8 [cifs]
Ok, I've reproduced this on a machine with a serial port :)
0xffffffff803574e0 in list_del (entry=0xffff8800ac184210) at /home/kronos/src/linux-2.6.git/lib/list_debug.c:46
46 WARN(entry->prev->next != entry,
(gdb) bt
#0 0xffffffff803574e0 in list_del (entry=0xffff8800ac184210)
at /home/kronos/src/linux-2.6.git/lib/list_debug.c:46
#1 0xffffffff80319588 in cifs_close (inode=0xffff8800b8d5f088, file=0xffff8800ad8f6d00)
at /home/kronos/src/linux-2.6.git/fs/cifs/file.c:670
#2 0xffffffff8029d95e in __fput (file=0xffff8800ad8f6d00)
at /home/kronos/src/linux-2.6.git/fs/file_table.c:281
#3 0xffffffff8029da32 in fput (file=0xffff8800ac184210)
at /home/kronos/src/linux-2.6.git/fs/file_table.c:227
#4 0xffffffff8029ad30 in filp_close (filp=0xffff8800ad8f6d00, id=0xffff880037a3e080)
at /home/kronos/src/linux-2.6.git/fs/open.c:1108
#5 0xffffffff8029ade0 in sys_close (fd=0)
at /home/kronos/src/linux-2.6.git/fs/open.c:1137
#6 0xffffffff802271e4 in sysenter_dispatch ()
at /home/kronos/src/linux-2.6.git/arch/x86/ia32/ia32entry.S:161#7 0x0000000000000000 in ?? ()
(gdb) f 1
#1 0xffffffff80319588 in cifs_close (inode=0xffff8800b8d5f088, file=0xffff8800ad8f6d00)
at /home/kronos/src/linux-2.6.git/fs/cifs/file.c:670
670 list_del(&pSMBFile->flist);
(gdb) p *&pSMBFile->flist
$2 = {next = 0x0, prev = 0x0}
(gdb) p *&pSMBFile->tlist
$5 = {next = 0x0, prev = 0x0}
So both flist and tlist were not initilized in cifs_open.
The content of the whole pSMBFile structure:
(gdb) p *pSMBFile
$6 = {tlist = {next = 0x0, prev = 0x0}, flist = {next = 0x0, prev = 0x0}, uid = 0, pid = 5322, netfid = 13880,
pfile = 0xffff8800ad8f6d00, pInode = 0xffff8800b8d5f088, lock_mutex = {count = {counter = 1}, wait_lock = {raw_lock = {
slock = 514}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = {
key = 0xffffffff806a5c98, class_cache = 0x0, name = 0xffffffff80537308 "&lock->wait_lock"}}, wait_list = {
next = 0xffff8800ac184278, prev = 0xffff8800ac184278}, owner = 0x0, name = 0x0, magic = 0xffff8800ac184240, dep_map = {
key = 0xffffffff80d7ff50, class_cache = 0xffffffff80835400, name = 0xffffffff8054cdfa "&private_data->lock_mutex"}},
llist = {next = 0xffff8800ac1842b8, prev = 0xffff8800ac1842b8}, closePend = true, invalidHandle = false,
messageMode = false, wrtPending = {counter = 0}, fh_mutex = {count = {counter = 1}, wait_lock = {raw_lock = {slock = 0},
magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = {key = 0xffffffff806a5c98,
class_cache = 0x0, name = 0xffffffff80537308 "&lock->wait_lock"}}, wait_list = {next = 0xffff8800ac184308,
prev = 0xffff8800ac184308}, owner = 0x0, name = 0x0, magic = 0xffff8800ac1842d0, dep_map = {key = 0xffffffff80d7ff58,
class_cache = 0x0, name = 0xffffffff8054cde2 "&private_data->fh_mutex"}}, srch_inf = {index_of_last_entry = 0,
entries_in_buffer = 0, info_level = 0, resume_key = 0, ntwrk_buf_start = 0x0, srch_entries_start = 0x0, last_entry = 0x0,
presume_name = 0x0, resume_name_len = 0, endOfSearch = false, emptyDir = false, unicode = false, smallBuf = false}}Luca
Quoted 47 lines · On Sat, 16 May 2009 22:55:58 +0200 Luca Tettamanti <[email protected]> wrote:
Quoted 3 lines · Luca Tettamanti
Hello,
I just hit a NULL pointer dereference incifs_closewhile accessing a file on a remote Samba shared directory.[...]
Quoted 2 lines
BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [<ffffffffa05f105c>] cifs_close+0x1c1/0x2e8 [cifs]Ok, I've reproduced this on a machine with a serial port :)
0xffffffff803574e0inlist_del(entry=0xffff8800ac184210) at/home/kronos/src/linux-2.6.git/lib/list_debug.c:46
46 WARN(entry->prev->next != entry,
(gdb) bt
#00xffffffff803574e0inlist_del(entry=0xffff8800ac184210)at /home/kronos/src/linux-2.6.git/lib/list_debug.c:46 #1 0xffffffff80319588 in cifs_close (inode=0xffff8800b8d5f088, file=0xffff8800ad8f6d00) at /home/kronos/src/linux-2.6.git/fs/cifs/file.c:670 #2 0xffffffff8029d95e in __fput (file=0xffff8800ad8f6d00) at /home/kronos/src/linux-2.6.git/fs/file_table.c:281 #3 0xffffffff8029da32 in fput (file=0xffff8800ac184210) at /home/kronos/src/linux-2.6.git/fs/file_table.c:227 #4 0xffffffff8029ad30 in filp_close (filp=0xffff8800ad8f6d00, id=0xffff880037a3e080) at /home/kronos/src/linux-2.6.git/fs/open.c:1108 #5 0xffffffff8029ade0 in sys_close (fd=0) at /home/kronos/src/linux-2.6.git/fs/open.c:1137 #6 0xffffffff802271e4 in sysenter_dispatch () at /home/kronos/src/linux-2.6.git/arch/x86/ia32/ia32entry.S:161#7
0x0000000000000000in ?? ()(gdb) f 1
#10xffffffff80319588incifs_close(inode=0xffff8800b8d5f088, file=0xffff8800ad8f6d00)at /home/kronos/src/linux-2.6.git/fs/cifs/file.c:670670
list_del(&pSMBFile->flist);(gdb) p *&pSMBFile->flist
$2 = {next =0x0, prev =0x0}(gdb) p *&pSMBFile->tlist
$5 = {next =0x0, prev =0x0}So both flist and tlist were not initilized in
cifs_open.The content of the whole pSMBFile structure:
(gdb) p *pSMBFile
$6 = {tlist = {next =0x0, prev =0x0}, flist = {next =0x0, prev =0x0}, uid = 0, pid = 5322, netfid = 13880,
Quoted 14 lines
pfile = 0xffff8800ad8f6d00, pInode = 0xffff8800b8d5f088, lock_mutex = {count = {counter = 1}, wait_lock = {raw_lock = {
slock = 514}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = {
key = 0xffffffff806a5c98, class_cache = 0x0, name = 0xffffffff80537308 "&lock->wait_lock"}}, wait_list = {
next = 0xffff8800ac184278, prev = 0xffff8800ac184278}, owner = 0x0, name = 0x0, magic = 0xffff8800ac184240, dep_map = {
key = 0xffffffff80d7ff50, class_cache = 0xffffffff80835400, name = 0xffffffff8054cdfa "&private_data->lock_mutex"}},
llist = {next = 0xffff8800ac1842b8, prev = 0xffff8800ac1842b8}, closePend = true, invalidHandle = false,
messageMode = false, wrtPending = {counter = 0}, fh_mutex = {count = {counter = 1}, wait_lock = {raw_lock = {slock = 0},
magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = {key = 0xffffffff806a5c98,
class_cache = 0x0, name = 0xffffffff80537308 "&lock->wait_lock"}}, wait_list = {next = 0xffff8800ac184308,
prev = 0xffff8800ac184308}, owner = 0x0, name = 0x0, magic = 0xffff8800ac1842d0, dep_map = {key = 0xffffffff80d7ff58,
class_cache = 0x0, name = 0xffffffff8054cde2 "&private_data->fh_mutex"}}, srch_inf = {index_of_last_entry = 0,
entries_in_buffer = 0, info_level = 0, resume_key = 0, ntwrk_buf_start = 0x0, srch_entries_start = 0x0, last_entry = 0x0,
presume_name = 0x0, resume_name_len = 0, endOfSearch = false, emptyDir = false, unicode = false, smallBuf = false}}Luca...thanks for the bug report and analysis. I've been able to reproduce this too against 3.3.2. The attached patch reverts the open with lookup intent functionality that was added at the beginning of the 2.6.30 cycle. This fixes the problem for me.
Steve and Shirish...given that we've already seen a couple of regressions from these patches, I'd like to see them reverted until they have been better tested.
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 1 line
From
90e4ee5d311d4e0729daa676b1d7f754265b5874Mon Sep 17 00:00:00 2001
From: Steve French <[email protected]>
Date: Fri, 8 May 2009 03:04:30 +0000
Subject: [PATCH] [CIFS] Fix double list addition in cifs posix open code
Remove adding open file entry twice to lists in the file Do not fill file info twice in case of posix opens and creates
--- fs/cifs/dir.c | 15 +++++++++------ fs/cifs/file.c | 14 -------------- 2 files changed, 9 insertions(+), 20 deletions(-)
fs/cifs/dir.c +9 -6
@@ -281,6 +281,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,int create_options =CREATE_NOT_DIR ;int oplock =0 ;int oflags; +bool posix_create = false;/* * BB below access is probably too much for mknod to request * but we have to do query and setpathinfo so requesting
@@ -328,11 +329,13 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,negotation. EREMOTE indicates DFS junction, which is not handled in posix open */ -if ((rc ==0 ) && (newinode ==NULL )) - goto cifs_create_get_file_info;/* query inode info */ -else if (rc ==0 )/* success, no need to query */ - goto cifs_create_set_dentry; -else if ((rc != -EIO ) && (rc != -EREMOTE ) && +if (rc ==0 ) { + posix_create = true; +if (newinode ==NULL )/* query inode info */ + goto cifs_create_get_file_info; +else /* success, no need to query */ + goto cifs_create_set_dentry; + }else if ((rc != -EIO ) && (rc != -EREMOTE ) && (rc != -EOPNOTSUPP ))/* path not found or net err */ goto cifs_create_out;/* else fallthrough to retry, using older open call, this is
@@ -464,7 +467,7 @@ cifs_create_set_dentry:if ((nd ==NULL ) || (!(nd->flags &LOOKUP_OPEN ))) {/* mknod case - do not leave file open */ CIFSSMBClose (xid, tcon, fileHandle); - }else if (newinode) { + }else if (!(posix_create) && (newinode)) {cifs_fill_fileinfo (newinode, fileHandle, cifs_sb->tcon, write_only); }
fs/cifs/file.c +0 -14
@@ -129,15 +129,12 @@ static inline int cifs_posix_open_inode_helper(struct inode *inode, struct file *file, struct cifsInodeInfo *pCifsInode, struct cifsFileInfo *pCifsFile, int oplock, u16 netfid) { - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); -/* struct timespec temp; */ /* BB REMOVEME BB */ file->private_data = kmalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);if (file->private_data ==NULL )return -ENOMEM ; pCifsFile =cifs_init_private (file->private_data, inode, file, netfid);write_lock (&GlobalSMBSeslock); -list_add (&pCifsFile->tlist, &cifs_sb->tcon->openFileList); pCifsInode =CIFS_I (file->f_path.dentry->d_inode);if (pCifsInode ==NULL ) {
@@ -145,17 +142,6 @@ static inline int cifs_posix_open_inode_helper(struct inode *inode,return -EINVAL ; } -/* want handles we can use to read with first -in the list so we do not have to walk the -list to search for one in write_begin */ -if ((file->f_flags &O_ACCMODE ) ==O_WRONLY ) { -list_add_tail (&pCifsFile->flist, - &pCifsInode->openFileList); - }else { -list_add (&pCifsFile->flist, - &pCifsInode->openFileList); - } -if (pCifsInode->clientCanCacheRead) {/* we have the inode open somewhere else no need to discard cache data */
Signature · 1 line
1.6.0.6
Quoted 65 lines · On Sat, 16 May 2009 22:13:31 -0400 Jeff Layton <[email protected]> wrote:
Quoted 47 lines · On Sat, 16 May 2009 22:55:58 +0200 Luca Tettamanti <[email protected]> wrote:
Quoted 3 lines · Luca Tettamanti
Hello,
I just hit a NULL pointer dereference incifs_closewhile accessing a file on a remote Samba shared directory.[...]
Quoted 2 lines
BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [<ffffffffa05f105c>] cifs_close+0x1c1/0x2e8 [cifs]Ok, I've reproduced this on a machine with a serial port :)
0xffffffff803574e0inlist_del(entry=0xffff8800ac184210) at/home/kronos/src/linux-2.6.git/lib/list_debug.c:46
46 WARN(entry->prev->next != entry,
(gdb) bt
#00xffffffff803574e0inlist_del(entry=0xffff8800ac184210)at /home/kronos/src/linux-2.6.git/lib/list_debug.c:46 #1 0xffffffff80319588 in cifs_close (inode=0xffff8800b8d5f088, file=0xffff8800ad8f6d00) at /home/kronos/src/linux-2.6.git/fs/cifs/file.c:670 #2 0xffffffff8029d95e in __fput (file=0xffff8800ad8f6d00) at /home/kronos/src/linux-2.6.git/fs/file_table.c:281 #3 0xffffffff8029da32 in fput (file=0xffff8800ac184210) at /home/kronos/src/linux-2.6.git/fs/file_table.c:227 #4 0xffffffff8029ad30 in filp_close (filp=0xffff8800ad8f6d00, id=0xffff880037a3e080) at /home/kronos/src/linux-2.6.git/fs/open.c:1108 #5 0xffffffff8029ade0 in sys_close (fd=0) at /home/kronos/src/linux-2.6.git/fs/open.c:1137 #6 0xffffffff802271e4 in sysenter_dispatch () at /home/kronos/src/linux-2.6.git/arch/x86/ia32/ia32entry.S:161#7
0x0000000000000000in ?? ()(gdb) f 1
#10xffffffff80319588incifs_close(inode=0xffff8800b8d5f088, file=0xffff8800ad8f6d00)at /home/kronos/src/linux-2.6.git/fs/cifs/file.c:670670
list_del(&pSMBFile->flist);(gdb) p *&pSMBFile->flist
$2 = {next =0x0, prev =0x0}(gdb) p *&pSMBFile->tlist
$5 = {next =0x0, prev =0x0}So both flist and tlist were not initilized in
cifs_open.The content of the whole pSMBFile structure:
(gdb) p *pSMBFile
$6 = {tlist = {next =0x0, prev =0x0}, flist = {next =0x0, prev =0x0}, uid = 0, pid = 5322, netfid = 13880,Quoted 14 lines
pfile = 0xffff8800ad8f6d00, pInode = 0xffff8800b8d5f088, lock_mutex = {count = {counter = 1}, wait_lock = {raw_lock = { slock = 514}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = { key = 0xffffffff806a5c98, class_cache = 0x0, name = 0xffffffff80537308 "&lock->wait_lock"}}, wait_list = { next = 0xffff8800ac184278, prev = 0xffff8800ac184278}, owner = 0x0, name = 0x0, magic = 0xffff8800ac184240, dep_map = { key = 0xffffffff80d7ff50, class_cache = 0xffffffff80835400, name = 0xffffffff8054cdfa "&private_data->lock_mutex"}}, llist = {next = 0xffff8800ac1842b8, prev = 0xffff8800ac1842b8}, closePend = true, invalidHandle = false, messageMode = false, wrtPending = {counter = 0}, fh_mutex = {count = {counter = 1}, wait_lock = {raw_lock = {slock = 0}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = {key = 0xffffffff806a5c98, class_cache = 0x0, name = 0xffffffff80537308 "&lock->wait_lock"}}, wait_list = {next = 0xffff8800ac184308, prev = 0xffff8800ac184308}, owner = 0x0, name = 0x0, magic = 0xffff8800ac1842d0, dep_map = {key = 0xffffffff80d7ff58, class_cache = 0x0, name = 0xffffffff8054cde2 "&private_data->fh_mutex"}}, srch_inf = {index_of_last_entry = 0, entries_in_buffer = 0, info_level = 0, resume_key = 0, ntwrk_buf_start = 0x0, srch_entries_start = 0x0, last_entry = 0x0, presume_name = 0x0, resume_name_len = 0, endOfSearch = false, emptyDir = false, unicode = false, smallBuf = false}}
Quoted 9 lines
Luca...thanks for the bug report and analysis. I've been able to reproduce this too against 3.3.2. The attached patch reverts the open with lookup intent functionality that was added at the beginning of the 2.6.30 cycle. This fixes the problem for me.
Steve and Shirish...given that we've already seen a couple of regressions from these patches, I'd like to see them reverted until they have been better tested.
Oops, wrong patch...this is the right one.
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 1 line
From
7ae9cf299fd28d23d3850ee4a4337e40139a63d7Mon Sep 17 00:00:00 2001
From: Jeff Layton <[email protected]>
Date: Sat, 16 May 2009 22:08:54 -0400
Subject: [PATCH] cifs: revert patches to add open on lookup
This patch reverts the patches for open on lookup functionality that was added at the beginning of the 2.6.30 cycle. Specifically, these commits:
a6ce4932fbdbcd8f8e8c6df76812014351c32892bc8cd4390c9129fbd286b10fa99972dfb68cd06988dd47fff4891545bfcfdf39146dde838077176690e4ee5d311d4e0729daa676b1d7f754265b5874
--- fs/cifs/cifsglob.h | 2 +- fs/cifs/dir.c | 154 ++++++++++++++++++---------------------------------- fs/cifs/file.c | 77 ++++++++++++++++---------- 3 files changed, 100 insertions(+), 133 deletions(-)
fs/cifs/cifsglob.h +1 -1
@@ -350,7 +350,7 @@ struct cifsFileInfo { bool invalidHandle:1; /* file closed via session abend */ bool messageMode:1; /* for pipes: message vs byte mode */atomic_t wrtPending;/* handle in use - defer close */ -struct mutex fh_mutex;/* prevents reopen race after dead ses*/ +struct semaphore fh_sem;/* prevents reopen race after dead ses*/ struct cifs_search_info srch_inf; };
fs/cifs/dir.c +52 -102
231 lines not on this page · raw message
fs/cifs/file.c +47 -30
134 lines not on this page · raw message
Signature · 1 line
1.6.2.2
Quoted 44 lines · Jeff Layton
Quoted 41 lines · On Sat, 16 May 2009 22:55:58 +0200 Luca Tettamanti <[email protected]> wrote:
Quoted 3 lines · Luca Tettamanti
Hello,
I just hit a NULL pointer dereference incifs_closewhile accessing a file on a remote Samba shared directory.[...]
Quoted 2 lines
BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [<ffffffffa05f105c>] cifs_close+0x1c1/0x2e8 [cifs]Ok, I've reproduced this on a machine with a serial port :)
0xffffffff803574e0inlist_del(entry=0xffff8800ac184210)
at/home/kronos/src/linux-2.6.git/lib/list_debug.c:46
46 WARN(entry->prev->next != entry,
(gdb) bt
#0 0xffffffff803574e0 inlist_del(entry=0xffff8800ac184210)
at/home/kronos/src/linux-2.6.git/lib/list_debug.c:46
#1 0xffffffff80319588 incifs_close(inode=0xffff8800b8d5f088, file=0xffff8800ad8f6d00) at/home/kronos/src/linux-2.6.git/fs/cifs/file.c:670
#2 0xffffffff8029d95e in__fput(file=0xffff8800ad8f6d00)
at/home/kronos/src/linux-2.6.git/fs/file_table.c:281
#3 0xffffffff8029da32 in fput (file=0xffff8800ac184210)
at/home/kronos/src/linux-2.6.git/fs/file_table.c:227
#4 0xffffffff8029ad30 infilp_close(filp=0xffff8800ad8f6d00, id=0xffff880037a3e080) at/home/kronos/src/linux-2.6.git/fs/open.c:1108
#5 0xffffffff8029ade0 insys_close(fd=0)
at/home/kronos/src/linux-2.6.git/fs/open.c:1137
#6 0xffffffff802271e4 insysenter_dispatch()
at/home/kronos/src/linux-2.6.git/arch/x86/ia32/ia32entry.S:161
#7 0x0000000000000000 in ?? ()(gdb) f 1
#1 0xffffffff80319588 incifs_close(inode=0xffff8800b8d5f088, file=0xffff8800ad8f6d00) at/home/kronos/src/linux-2.6.git/fs/cifs/file.c:670
670list_del(&pSMBFile->flist);(gdb) p *&pSMBFile->flist
$2 = {next =0x0, prev =0x0}(gdb) p *&pSMBFile->tlist
$5 = {next =0x0, prev =0x0}
Quoted 7 lines
Quoted 4 lines
So both flist and tlist were not initilized in
cifs_open.The content of the whole pSMBFile structure:
Luca...thanks for the bug report and analysis. I've been able to reproduce this too against 3.3.2.
After reproducing the problem, I just looked at this in more detail:
the flist and tlist look like they were initialized, but the problem is instead that they are being deleted from the wrong cifs file struct.
Tthe create adds them to the 1st pSMBFile, the close deletes them from the 1st pSMBFile, the subsequent open added them to the 2nd pSMBFile, the close deleted them from the 1st pSMBfile (which oopses).
This should be straightforward to fix, but I want to talk with Shirish about it.
Signature · 3 lines
Thanks, Steve
Quoted 70 lines · Jeff Layton
Quoted 47 lines · On Sat, 16 May 2009 22:55:58 +0200 Luca Tettamanti <[email protected]> wrote:
Quoted 3 lines · Luca Tettamanti
Hello,
I just hit a NULL pointer dereference incifs_closewhile accessing a file on a remote Samba shared directory.[...]
Quoted 2 lines
BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [<ffffffffa05f105c>] cifs_close+0x1c1/0x2e8 [cifs]Ok, I've reproduced this on a machine with a serial port :)
0xffffffff803574e0inlist_del(entry=0xffff8800ac184210) at/home/kronos/src/linux-2.6.git/lib/list_debug.c:46
46 WARN(entry->prev->next != entry,
(gdb) bt
#00xffffffff803574e0inlist_del(entry=0xffff8800ac184210)at /home/kronos/src/linux-2.6.git/lib/list_debug.c:46 #1 0xffffffff80319588 in cifs_close (inode=0xffff8800b8d5f088, file=0xffff8800ad8f6d00) at /home/kronos/src/linux-2.6.git/fs/cifs/file.c:670 #2 0xffffffff8029d95e in __fput (file=0xffff8800ad8f6d00) at /home/kronos/src/linux-2.6.git/fs/file_table.c:281 #3 0xffffffff8029da32 in fput (file=0xffff8800ac184210) at /home/kronos/src/linux-2.6.git/fs/file_table.c:227 #4 0xffffffff8029ad30 in filp_close (filp=0xffff8800ad8f6d00, id=0xffff880037a3e080) at /home/kronos/src/linux-2.6.git/fs/open.c:1108 #5 0xffffffff8029ade0 in sys_close (fd=0) at /home/kronos/src/linux-2.6.git/fs/open.c:1137 #6 0xffffffff802271e4 in sysenter_dispatch () at /home/kronos/src/linux-2.6.git/arch/x86/ia32/ia32entry.S:161#7
0x0000000000000000in ?? ()(gdb) f 1
#10xffffffff80319588incifs_close(inode=0xffff8800b8d5f088, file=0xffff8800ad8f6d00)at /home/kronos/src/linux-2.6.git/fs/cifs/file.c:670670
list_del(&pSMBFile->flist);(gdb) p *&pSMBFile->flist
$2 = {next =0x0, prev =0x0}(gdb) p *&pSMBFile->tlist
$5 = {next =0x0, prev =0x0}So both flist and tlist were not initilized in
cifs_open.The content of the whole pSMBFile structure:
(gdb) p *pSMBFile
$6 = {tlist = {next =0x0, prev =0x0}, flist = {next =0x0, prev =0x0}, uid = 0, pid = 5322, netfid = 13880,Quoted 14 lines
pfile = 0xffff8800ad8f6d00, pInode = 0xffff8800b8d5f088, lock_mutex = {count = {counter = 1}, wait_lock = {raw_lock = { slock = 514}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = { key = 0xffffffff806a5c98, class_cache = 0x0, name = 0xffffffff80537308 "&lock->wait_lock"}}, wait_list = { next = 0xffff8800ac184278, prev = 0xffff8800ac184278}, owner = 0x0, name = 0x0, magic = 0xffff8800ac184240, dep_map = { key = 0xffffffff80d7ff50, class_cache = 0xffffffff80835400, name = 0xffffffff8054cdfa "&private_data->lock_mutex"}}, llist = {next = 0xffff8800ac1842b8, prev = 0xffff8800ac1842b8}, closePend = true, invalidHandle = false, messageMode = false, wrtPending = {counter = 0}, fh_mutex = {count = {counter = 1}, wait_lock = {raw_lock = {slock = 0}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = {key = 0xffffffff806a5c98, class_cache = 0x0, name = 0xffffffff80537308 "&lock->wait_lock"}}, wait_list = {next = 0xffff8800ac184308, prev = 0xffff8800ac184308}, owner = 0x0, name = 0x0, magic = 0xffff8800ac1842d0, dep_map = {key = 0xffffffff80d7ff58, class_cache = 0x0, name = 0xffffffff8054cde2 "&private_data->fh_mutex"}}, srch_inf = {index_of_last_entry = 0, entries_in_buffer = 0, info_level = 0, resume_key = 0, ntwrk_buf_start = 0x0, srch_entries_start = 0x0, last_entry = 0x0, presume_name = 0x0, resume_name_len = 0, endOfSearch = false, emptyDir = false, unicode = false, smallBuf = false}}Luca...thanks for the bug report and analysis. I've been able to reproduce this too against 3.3.2. The attached patch reverts the open with lookup intent functionality that was added at the beginning of the 2.6.30 cycle. This fixes the problem for me.
Quoted 7 lines
Steve and Shirish...given that we've already seen a couple of regressions from these patches, I'd like to see them reverted until they have been better tested.
--
Jeff Layton <[email protected]>
Does this happen inspite of the patch 90e4ee5d311d4e0729daa676b1d7f754265b5874
Quoted 75 lines · On Sun, 17 May 2009 09:40:44 -0500 Shirish Pargaonkar…
Quoted 74 lines · Jeff Layton
Quoted 47 lines · On Sat, 16 May 2009 22:55:58 +0200 Luca Tettamanti <[email protected]> wrote:
Quoted 3 lines · Luca Tettamanti
Hello,
I just hit a NULL pointer dereference incifs_closewhile accessing a file on a remote Samba shared directory.[...]
Quoted 2 lines
BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [<ffffffffa05f105c>] cifs_close+0x1c1/0x2e8 [cifs]Ok, I've reproduced this on a machine with a serial port :)
0xffffffff803574e0inlist_del(entry=0xffff8800ac184210) at/home/kronos/src/linux-2.6.git/lib/list_debug.c:46
46 WARN(entry->prev->next != entry,
(gdb) bt
#00xffffffff803574e0inlist_del(entry=0xffff8800ac184210)at /home/kronos/src/linux-2.6.git/lib/list_debug.c:46 #1 0xffffffff80319588 in cifs_close (inode=0xffff8800b8d5f088, file=0xffff8800ad8f6d00) at /home/kronos/src/linux-2.6.git/fs/cifs/file.c:670 #2 0xffffffff8029d95e in __fput (file=0xffff8800ad8f6d00) at /home/kronos/src/linux-2.6.git/fs/file_table.c:281 #3 0xffffffff8029da32 in fput (file=0xffff8800ac184210) at /home/kronos/src/linux-2.6.git/fs/file_table.c:227 #4 0xffffffff8029ad30 in filp_close (filp=0xffff8800ad8f6d00, id=0xffff880037a3e080) at /home/kronos/src/linux-2.6.git/fs/open.c:1108 #5 0xffffffff8029ade0 in sys_close (fd=0) at /home/kronos/src/linux-2.6.git/fs/open.c:1137 #6 0xffffffff802271e4 in sysenter_dispatch () at /home/kronos/src/linux-2.6.git/arch/x86/ia32/ia32entry.S:161#7
0x0000000000000000in ?? ()(gdb) f 1
#10xffffffff80319588incifs_close(inode=0xffff8800b8d5f088, file=0xffff8800ad8f6d00)at /home/kronos/src/linux-2.6.git/fs/cifs/file.c:670670
list_del(&pSMBFile->flist);(gdb) p *&pSMBFile->flist
$2 = {next =0x0, prev =0x0}(gdb) p *&pSMBFile->tlist
$5 = {next =0x0, prev =0x0}So both flist and tlist were not initilized in
cifs_open.The content of the whole pSMBFile structure:
(gdb) p *pSMBFile
$6 = {tlist = {next =0x0, prev =0x0}, flist = {next =0x0, prev =0x0}, uid = 0, pid = 5322, netfid = 13880,Quoted 14 lines
pfile = 0xffff8800ad8f6d00, pInode = 0xffff8800b8d5f088, lock_mutex = {count = {counter = 1}, wait_lock = {raw_lock = { slock = 514}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = { key = 0xffffffff806a5c98, class_cache = 0x0, name = 0xffffffff80537308 "&lock->wait_lock"}}, wait_list = { next = 0xffff8800ac184278, prev = 0xffff8800ac184278}, owner = 0x0, name = 0x0, magic = 0xffff8800ac184240, dep_map = { key = 0xffffffff80d7ff50, class_cache = 0xffffffff80835400, name = 0xffffffff8054cdfa "&private_data->lock_mutex"}}, llist = {next = 0xffff8800ac1842b8, prev = 0xffff8800ac1842b8}, closePend = true, invalidHandle = false, messageMode = false, wrtPending = {counter = 0}, fh_mutex = {count = {counter = 1}, wait_lock = {raw_lock = {slock = 0}, magic = 3735899821, owner_cpu = 4294967295, owner = 0xffffffffffffffff, dep_map = {key = 0xffffffff806a5c98, class_cache = 0x0, name = 0xffffffff80537308 "&lock->wait_lock"}}, wait_list = {next = 0xffff8800ac184308, prev = 0xffff8800ac184308}, owner = 0x0, name = 0x0, magic = 0xffff8800ac1842d0, dep_map = {key = 0xffffffff80d7ff58, class_cache = 0x0, name = 0xffffffff8054cde2 "&private_data->fh_mutex"}}, srch_inf = {index_of_last_entry = 0, entries_in_buffer = 0, info_level = 0, resume_key = 0, ntwrk_buf_start = 0x0, srch_entries_start = 0x0, last_entry = 0x0, presume_name = 0x0, resume_name_len = 0, endOfSearch = false, emptyDir = false, unicode = false, smallBuf = false}}Luca...thanks for the bug report and analysis. I've been able to reproduce this too against 3.3.2. The attached patch reverts the open with lookup intent functionality that was added at the beginning of the 2.6.30 cycle. This fixes the problem for me.
Steve and Shirish...given that we've already seen a couple of regressions from these patches, I'd like to see them reverted until they have been better tested.
Quoted 5 lines
Quoted 3 lines
--
Jeff Layton <[email protected]>Does this happen inspite of the patch
90e4ee5d311d4e0729daa676b1d7f754265b5874
Yes. It's trivial to reproduce against a samba 3.3.2 server.
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 11 lines · Shirish Pargaonkar
Quoted 10 lines · Jeff Layton
Quoted 7 lines · On Sat, 16 May 2009 22:55:58 +0200 Luca Tettamanti <[email protected]> wrote:
Quoted 3 lines · Luca Tettamanti
Hello,
I just hit a NULL pointer dereference incifs_closewhile accessing a file on a remote Samba shared directory.[...]
Quoted 2 lines
BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [<ffffffffa05f105c>] cifs_close+0x1c1/0x2e8 [cifs]
[...]
Quoted 1 line
Does this happen inspite of the patch
90e4ee5d311d4e0729daa676b1d7f754265b5874
Yes, I was running 2.6.30-rc6, which contains that commit.
Luca