linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
	linux-kernel@vger.kernel.org, pali@kernel.org, dsterba@suse.cz,
	aaptel@suse.com, willy@infradead.org, rdunlap@infradead.org,
	joe@perches.com, mark@harmstone.com, nborisov@suse.com,
	linux-ntfs-dev@lists.sourceforge.net, anton@tuxera.com
Subject: Re: [PATCH v11 00/10] NTFS read-write driver GPL implementation by Paragon Software
Date: Fri, 30 Oct 2020 19:42:09 -0700	[thread overview]
Message-ID: <20201031024209.GB1097@sol.localdomain> (raw)
In-Reply-To: <20201030150239.3957156-1-almaz.alexandrovich@paragon-software.com>

Hi Konstantin,

On Fri, Oct 30, 2020 at 06:02:29PM +0300, Konstantin Komarov wrote:
> This patch adds NTFS Read-Write driver to fs/ntfs3.
> 
> Having decades of expertise in commercial file systems development and huge
> test coverage, we at Paragon Software GmbH want to make our contribution to
> the Open Source Community by providing implementation of NTFS Read-Write
> driver for the Linux Kernel.
> 
> This is fully functional NTFS Read-Write driver. Current version works with
> NTFS(including v3.1) and normal/compressed/sparse files and supports journal replaying.
> 
> We plan to support this version after the codebase once merged, and add new
> features and fix bugs. For example, full journaling support over JBD will be
> added in later updates.
> 

Have you tried testing this filesystem using some of the kernel debugging
options (lockdep, KASAN, etc.?).  I tried a basic test just for fun, and I
immediately got a lockdep report:

mkfs.ntfs -f /dev/vdb
mount /dev/vdb /mnt -t ntfs3
echo foo > /mnt/foo

======================================================
WARNING: possible circular locking dependency detected
5.10.0-rc1-00275-ga34a2c322380 #33 Not tainted
------------------------------------------------------
bash/160 is trying to acquire lock:
ffff888011e68108 (&ni->ni_lock){+.+.}-{3:3}, at: ni_lock fs/ntfs3/ntfs_fs.h:959 [inline]
ffff888011e68108 (&ni->ni_lock){+.+.}-{3:3}, at: ntfs_set_size+0xee/0x210 fs/ntfs3/inode.c:880

but task is already holding lock:
ffff888011e68370 (&sb->s_type->i_mutex_key#11){+.+.}-{3:3}, at: inode_trylock include/linux/fs.h:794 [inline]
ffff888011e68370 (&sb->s_type->i_mutex_key#11){+.+.}-{3:3}, at: ntfs_file_write_iter+0x1bc/0x4e0 fs/ntfs3/file.c:1040

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&sb->s_type->i_mutex_key#11){+.+.}-{3:3}:
       __lock_acquire+0x7b7/0x1060 kernel/locking/lockdep.c:4837
       lock_acquire.part.0+0x13b/0x2a0 kernel/locking/lockdep.c:5442
       lock_acquire+0xb4/0x1d0 kernel/locking/lockdep.c:5415
       down_write+0x93/0x150 kernel/locking/rwsem.c:1531
       inode_lock include/linux/fs.h:774 [inline]
       ntfs_set_state+0x192/0x650 fs/ntfs3/fsntfs.c:996
       ntfs_create_inode+0x318/0x4590 fs/ntfs3/inode.c:1254
       ntfs_atomic_open+0x350/0x450 fs/ntfs3/namei.c:521
       atomic_open+0x16b/0x420 fs/namei.c:2970
       lookup_open+0x7d1/0xdc0 fs/namei.c:3076
       open_last_lookups+0x277/0x1040 fs/namei.c:3178
       path_openat+0x161/0x310 fs/namei.c:3366
       do_filp_open+0x17d/0x3b0 fs/namei.c:3396
       do_sys_openat2+0x120/0x3d0 fs/open.c:1168
       do_sys_open fs/open.c:1184 [inline]
       __do_sys_openat fs/open.c:1200 [inline]
       __se_sys_openat fs/open.c:1195 [inline]
       __x64_sys_openat+0x124/0x200 fs/open.c:1195
       do_syscall_64+0x32/0x50 arch/x86/entry/common.c:46
       entry_SYSCALL_64_after_hwframe+0x44/0xa9

-> #0 (&ni->ni_lock){+.+.}-{3:3}:
       check_prev_add+0x162/0x20b0 kernel/locking/lockdep.c:2864
       check_prevs_add kernel/locking/lockdep.c:2989 [inline]
       validate_chain+0xbff/0x1620 kernel/locking/lockdep.c:3607
       __lock_acquire+0x7b7/0x1060 kernel/locking/lockdep.c:4837
       lock_acquire.part.0+0x13b/0x2a0 kernel/locking/lockdep.c:5442
       lock_acquire+0xb4/0x1d0 kernel/locking/lockdep.c:5415
       __mutex_lock_common kernel/locking/mutex.c:956 [inline]
       __mutex_lock+0x142/0x12d0 kernel/locking/mutex.c:1103
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1118
       ni_lock fs/ntfs3/ntfs_fs.h:959 [inline]
       ntfs_set_size+0xee/0x210 fs/ntfs3/inode.c:880
       ntfs_extend_ex+0x3b1/0x5c0 fs/ntfs3/file.c:466
       ntfs_file_write_iter+0x244/0x4e0 fs/ntfs3/file.c:1050
       call_write_iter include/linux/fs.h:1887 [inline]
       new_sync_write+0x348/0x6d0 fs/read_write.c:518
       vfs_write+0x408/0x5b0 fs/read_write.c:605
       ksys_write+0x11d/0x220 fs/read_write.c:658
       __do_sys_write fs/read_write.c:670 [inline]
       __se_sys_write fs/read_write.c:667 [inline]
       __x64_sys_write+0x6e/0xb0 fs/read_write.c:667
       do_syscall_64+0x32/0x50 arch/x86/entry/common.c:46
       entry_SYSCALL_64_after_hwframe+0x44/0xa9

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&sb->s_type->i_mutex_key#11);
                               lock(&ni->ni_lock);
                               lock(&sb->s_type->i_mutex_key#11);
  lock(&ni->ni_lock);

 *** DEADLOCK ***

2 locks held by bash/160:
 #0: ffff8880084ac458 (sb_writers#11){.+.+}-{0:0}, at: file_start_write include/linux/fs.h:2759 [inline]
 #0: ffff8880084ac458 (sb_writers#11){.+.+}-{0:0}, at: vfs_write+0x3bc/0x5b0 fs/read_write.c:601
 #1: ffff888011e68370 (&sb->s_type->i_mutex_key#11){+.+.}-{3:3}, at: inode_trylock include/linux/fs.h:794 [inline]
 #1: ffff888011e68370 (&sb->s_type->i_mutex_key#11){+.+.}-{3:3}, at: ntfs_file_write_iter+0x1bc/0x4e0 fs/ntfs3/file.c:1040

stack backtrace:
CPU: 1 PID: 160 Comm: bash Not tainted 5.10.0-rc1-00275-ga34a2c322380 #33
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ArchLinux 1.14.0-1 04/01/2014
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0xa4/0xd9 lib/dump_stack.c:118
 print_circular_bug.cold+0x34/0x39 kernel/locking/lockdep.c:1994
 check_noncircular+0x277/0x350 kernel/locking/lockdep.c:2115
 check_prev_add+0x162/0x20b0 kernel/locking/lockdep.c:2864
 check_prevs_add kernel/locking/lockdep.c:2989 [inline]
 validate_chain+0xbff/0x1620 kernel/locking/lockdep.c:3607
 __lock_acquire+0x7b7/0x1060 kernel/locking/lockdep.c:4837
 lock_acquire.part.0+0x13b/0x2a0 kernel/locking/lockdep.c:5442
 lock_acquire+0xb4/0x1d0 kernel/locking/lockdep.c:5415
 __mutex_lock_common kernel/locking/mutex.c:956 [inline]
 __mutex_lock+0x142/0x12d0 kernel/locking/mutex.c:1103
 mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1118
 ni_lock fs/ntfs3/ntfs_fs.h:959 [inline]
 ntfs_set_size+0xee/0x210 fs/ntfs3/inode.c:880
 ntfs_extend_ex+0x3b1/0x5c0 fs/ntfs3/file.c:466
 ntfs_file_write_iter+0x244/0x4e0 fs/ntfs3/file.c:1050
 call_write_iter include/linux/fs.h:1887 [inline]
 new_sync_write+0x348/0x6d0 fs/read_write.c:518
 vfs_write+0x408/0x5b0 fs/read_write.c:605
 ksys_write+0x11d/0x220 fs/read_write.c:658
 __do_sys_write fs/read_write.c:670 [inline]
 __se_sys_write fs/read_write.c:667 [inline]
 __x64_sys_write+0x6e/0xb0 fs/read_write.c:667
 do_syscall_64+0x32/0x50 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7fad69e95f67
Code: 0d 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24
RSP: 002b:00007ffc66bcfaa8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007fad69e95f67
RDX: 0000000000000004 RSI: 0000555d79dccba0 RDI: 0000000000000001
RBP: 0000555d79dccba0 R08: 000000000000000a R09: 00007fad69f67a60
R10: 0000000000000080 R11: 0000000000000246 R12: 0000000000000004
R13: 00007fad69f68520 R14: 0000000000000004 R15: 00007fad69f68720

  parent reply	other threads:[~2020-10-31  2:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-30 15:02 Konstantin Komarov
2020-10-30 15:02 ` [PATCH v11 01/10] fs/ntfs3: Add headers and misc files Konstantin Komarov
2020-10-30 15:02 ` [PATCH v11 02/10] fs/ntfs3: Add initialization of super block Konstantin Komarov
2020-10-30 15:02 ` [PATCH v11 03/10] fs/ntfs3: Add bitmap Konstantin Komarov
2020-10-30 15:02 ` [PATCH v11 04/10] fs/ntfs3: Add file operations and implementation Konstantin Komarov
2020-10-30 15:02 ` [PATCH v11 05/10] fs/ntfs3: Add attrib operations Konstantin Komarov
2020-10-30 15:02 ` [PATCH v11 06/10] fs/ntfs3: Add compression Konstantin Komarov
2020-10-30 15:02 ` [PATCH v11 07/10] fs/ntfs3: Add NTFS journal Konstantin Komarov
2020-10-30 15:02 ` [PATCH v11 08/10] fs/ntfs3: Add Kconfig, Makefile and doc Konstantin Komarov
2020-10-30 15:02 ` [PATCH v11 09/10] fs/ntfs3: Add NTFS3 in fs/Kconfig and fs/Makefile Konstantin Komarov
2020-10-31  1:23   ` kernel test robot
2020-11-02  8:36   ` [kbuild] " Dan Carpenter
2020-11-03  3:06   ` kernel test robot
2020-10-30 15:02 ` [PATCH v11 10/10] fs/ntfs3: Add MAINTAINERS Konstantin Komarov
2020-10-30 15:24 ` [PATCH v11 00/10] NTFS read-write driver GPL implementation by Paragon Software Pali Rohár
2020-10-30 15:51   ` Konstantin Komarov
2020-10-30 16:24     ` Pali Rohár
2020-10-30 16:41 ` Pali Rohár
2020-10-31  8:51   ` Christoph Hellwig
2020-10-31  2:42 ` Eric Biggers [this message]
2020-10-31  2:48   ` Eric Biggers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201031024209.GB1097@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=aaptel@suse.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=anton@tuxera.com \
    --cc=dsterba@suse.cz \
    --cc=joe@perches.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-ntfs-dev@lists.sourceforge.net \
    --cc=mark@harmstone.com \
    --cc=nborisov@suse.com \
    --cc=pali@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --subject='Re: [PATCH v11 00/10] NTFS read-write driver GPL implementation by Paragon Software' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox