LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] fs/ntfs3: Check for NULL if ATTR_EA_INFO is incorrect
@ 2021-09-29 16:35 Konstantin Komarov
  2021-09-29 17:44 ` Kari Argillander
  2021-10-03 17:50 ` Kari Argillander
  0 siblings, 2 replies; 8+ messages in thread
From: Konstantin Komarov @ 2021-09-29 16:35 UTC (permalink / raw)
  To: ntfs3; +Cc: linux-kernel, linux-fsdevel

This can be reason for reported panic.
Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
 fs/ntfs3/frecord.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 9a53f809576d..007602badd90 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -3080,7 +3080,9 @@ static bool ni_update_parent(struct ntfs_inode *ni, struct NTFS_DUP_INFO *dup,
                        const struct EA_INFO *info;
 
                        info = resident_data_ex(attr, sizeof(struct EA_INFO));
-                       dup->ea_size = info->size_pack;
+                       /* If ATTR_EA_INFO exists 'info' can't be NULL. */
+                       if (info)
+                               dup->ea_size = info->size_pack;
                }
        }
 
-- 
2.33.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/ntfs3: Check for NULL if ATTR_EA_INFO is incorrect
  2021-09-29 16:35 [PATCH] fs/ntfs3: Check for NULL if ATTR_EA_INFO is incorrect Konstantin Komarov
@ 2021-09-29 17:44 ` Kari Argillander
  2021-10-03 17:50 ` Kari Argillander
  1 sibling, 0 replies; 8+ messages in thread
From: Kari Argillander @ 2021-09-29 17:44 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: ntfs3, linux-kernel, linux-fsdevel

On Wed, Sep 29, 2021 at 07:35:43PM +0300, Konstantin Komarov wrote:
> This can be reason for reported panic.

Is this public panic? If it is then put link here. If you have report
from panic you can put it here also. Patch itself looks correct.

> Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")
> 
> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
> ---
>  fs/ntfs3/frecord.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
> index 9a53f809576d..007602badd90 100644
> --- a/fs/ntfs3/frecord.c
> +++ b/fs/ntfs3/frecord.c
> @@ -3080,7 +3080,9 @@ static bool ni_update_parent(struct ntfs_inode *ni, struct NTFS_DUP_INFO *dup,
>                         const struct EA_INFO *info;
>  
>                         info = resident_data_ex(attr, sizeof(struct EA_INFO));
> -                       dup->ea_size = info->size_pack;
> +                       /* If ATTR_EA_INFO exists 'info' can't be NULL. */
> +                       if (info)
> +                               dup->ea_size = info->size_pack;
>                 }
>         }
>  
> -- 
> 2.33.0
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/ntfs3: Check for NULL if ATTR_EA_INFO is incorrect
  2021-09-29 16:35 [PATCH] fs/ntfs3: Check for NULL if ATTR_EA_INFO is incorrect Konstantin Komarov
  2021-09-29 17:44 ` Kari Argillander
@ 2021-10-03 17:50 ` Kari Argillander
  2021-10-04 20:39   ` Mohammad Rasim
  2021-10-06 14:51   ` Konstantin Komarov
  1 sibling, 2 replies; 8+ messages in thread
From: Kari Argillander @ 2021-10-03 17:50 UTC (permalink / raw)
  To: Konstantin Komarov, Mohammad Rasim; +Cc: ntfs3, linux-kernel, linux-fsdevel

On Wed, Sep 29, 2021 at 07:35:43PM +0300, Konstantin Komarov wrote:
> This can be reason for reported panic.
> Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")

I see that you have include this to devel branch but you did not send V2
[1]. I also included Mohammad Rasim to this thread. Maybe they can test
this patch. Rasim can you test [2] if your problem will be fixed with
this tree. Or just test this patch if you prefer that way.

[1]: github.com/Paragon-Software-Group/linux-ntfs3/commit/35afb70dcfe4eb445060dd955e5b67d962869ce5
[2]: github.com/Paragon-Software-Group/linux-ntfs3/tree/devel

> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
> ---
>  fs/ntfs3/frecord.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
> index 9a53f809576d..007602badd90 100644
> --- a/fs/ntfs3/frecord.c
> +++ b/fs/ntfs3/frecord.c
> @@ -3080,7 +3080,9 @@ static bool ni_update_parent(struct ntfs_inode *ni, struct NTFS_DUP_INFO *dup,
>                         const struct EA_INFO *info;
>  
>                         info = resident_data_ex(attr, sizeof(struct EA_INFO));
> -                       dup->ea_size = info->size_pack;
> +                       /* If ATTR_EA_INFO exists 'info' can't be NULL. */
> +                       if (info)
> +                               dup->ea_size = info->size_pack;
>                 }
>         }
>  
> -- 
> 2.33.0
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/ntfs3: Check for NULL if ATTR_EA_INFO is incorrect
  2021-10-03 17:50 ` Kari Argillander
@ 2021-10-04 20:39   ` Mohammad Rasim
  2021-10-06 14:47     ` Konstantin Komarov
  2021-10-06 14:51   ` Konstantin Komarov
  1 sibling, 1 reply; 8+ messages in thread
From: Mohammad Rasim @ 2021-10-04 20:39 UTC (permalink / raw)
  To: Kari Argillander, Konstantin Komarov; +Cc: ntfs3, linux-kernel, linux-fsdevel


On 10/3/21 20:50, Kari Argillander wrote:
> On Wed, Sep 29, 2021 at 07:35:43PM +0300, Konstantin Komarov wrote:
>> This can be reason for reported panic.
>> Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")
> I see that you have include this to devel branch but you did not send V2
> [1]. I also included Mohammad Rasim to this thread. Maybe they can test
> this patch. Rasim can you test [2] if your problem will be fixed with
> this tree. Or just test this patch if you prefer that way.
>
> [1]: github.com/Paragon-Software-Group/linux-ntfs3/commit/35afb70dcfe4eb445060dd955e5b67d962869ce5
> [2]: github.com/Paragon-Software-Group/linux-ntfs3/tree/devel

Yeah unfortunately the problem still exist, moving the buildroot git 
tree from my nvme ext4 partition to my wd ntfs partition still causes 
the panic.

Note that i used the master branch if that matters but it contains the 
same commit


Regards

>> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
>> ---
>>   fs/ntfs3/frecord.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
>> index 9a53f809576d..007602badd90 100644
>> --- a/fs/ntfs3/frecord.c
>> +++ b/fs/ntfs3/frecord.c
>> @@ -3080,7 +3080,9 @@ static bool ni_update_parent(struct ntfs_inode *ni, struct NTFS_DUP_INFO *dup,
>>                          const struct EA_INFO *info;
>>   
>>                          info = resident_data_ex(attr, sizeof(struct EA_INFO));
>> -                       dup->ea_size = info->size_pack;
>> +                       /* If ATTR_EA_INFO exists 'info' can't be NULL. */
>> +                       if (info)
>> +                               dup->ea_size = info->size_pack;
>>                  }
>>          }
>>   
>> -- 
>> 2.33.0
>>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/ntfs3: Check for NULL if ATTR_EA_INFO is incorrect
  2021-10-04 20:39   ` Mohammad Rasim
@ 2021-10-06 14:47     ` Konstantin Komarov
       [not found]       ` <2998a9b9-8ea0-6a44-7093-66c7a08dcab2@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread
From: Konstantin Komarov @ 2021-10-06 14:47 UTC (permalink / raw)
  To: Mohammad Rasim, Kari Argillander; +Cc: ntfs3, linux-kernel, linux-fsdevel



On 04.10.2021 23:39, Mohammad Rasim wrote:
> 
> On 10/3/21 20:50, Kari Argillander wrote:
>> On Wed, Sep 29, 2021 at 07:35:43PM +0300, Konstantin Komarov wrote:
>>> This can be reason for reported panic.
>>> Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")
>> I see that you have include this to devel branch but you did not send V2
>> [1]. I also included Mohammad Rasim to this thread. Maybe they can test
>> this patch. Rasim can you test [2] if your problem will be fixed with
>> this tree. Or just test this patch if you prefer that way.
>>
>> [1]: github.com/Paragon-Software-Group/linux-ntfs3/commit/35afb70dcfe4eb445060dd955e5b67d962869ce5
>> [2]: github.com/Paragon-Software-Group/linux-ntfs3/tree/devel
> 
> Yeah unfortunately the problem still exist, moving the buildroot git tree from my nvme ext4 partition to my wd ntfs partition still causes the panic.
> 
> Note that i used the master branch if that matters but it contains the same commit
> 
> 
> Regards
> 

Is panic the same as old one?

BUG: kernel NULL pointer dereference, address: 000000000000000e
RIP: 0010:ni_write_inode+0xe6b/0xed0 [ntfs3]
etc.

>>> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
>>> ---
>>>   fs/ntfs3/frecord.c | 4 +++-
>>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
>>> index 9a53f809576d..007602badd90 100644
>>> --- a/fs/ntfs3/frecord.c
>>> +++ b/fs/ntfs3/frecord.c
>>> @@ -3080,7 +3080,9 @@ static bool ni_update_parent(struct ntfs_inode *ni, struct NTFS_DUP_INFO *dup,
>>>                          const struct EA_INFO *info;
>>>                            info = resident_data_ex(attr, sizeof(struct EA_INFO));
>>> -                       dup->ea_size = info->size_pack;
>>> +                       /* If ATTR_EA_INFO exists 'info' can't be NULL. */
>>> +                       if (info)
>>> +                               dup->ea_size = info->size_pack;
>>>                  }
>>>          }
>>>   -- 
>>> 2.33.0
>>>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/ntfs3: Check for NULL if ATTR_EA_INFO is incorrect
  2021-10-03 17:50 ` Kari Argillander
  2021-10-04 20:39   ` Mohammad Rasim
@ 2021-10-06 14:51   ` Konstantin Komarov
  1 sibling, 0 replies; 8+ messages in thread
From: Konstantin Komarov @ 2021-10-06 14:51 UTC (permalink / raw)
  To: Kari Argillander, Mohammad Rasim; +Cc: ntfs3, linux-kernel, linux-fsdevel



On 03.10.2021 20:50, Kari Argillander wrote:
> On Wed, Sep 29, 2021 at 07:35:43PM +0300, Konstantin Komarov wrote:
>> This can be reason for reported panic.
>> Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")
> 
> I see that you have include this to devel branch but you did not send V2
> [1]. 

From patch thread:
"Is this public panic? If it is then put link here. If you have report
from panic you can put it here also. Patch itself looks correct."

I was thinking, that after adding link / Reported-by the patch is
good to commit.

> I also included Mohammad Rasim to this thread. Maybe they can test
> this patch. Rasim can you test [2] if your problem will be fixed with
> this tree. Or just test this patch if you prefer that way.
> 
> [1]: github.com/Paragon-Software-Group/linux-ntfs3/commit/35afb70dcfe4eb445060dd955e5b67d962869ce5
> [2]: github.com/Paragon-Software-Group/linux-ntfs3/tree/devel
> 
>> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
>> ---
>>  fs/ntfs3/frecord.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
>> index 9a53f809576d..007602badd90 100644
>> --- a/fs/ntfs3/frecord.c
>> +++ b/fs/ntfs3/frecord.c
>> @@ -3080,7 +3080,9 @@ static bool ni_update_parent(struct ntfs_inode *ni, struct NTFS_DUP_INFO *dup,
>>                         const struct EA_INFO *info;
>>  
>>                         info = resident_data_ex(attr, sizeof(struct EA_INFO));
>> -                       dup->ea_size = info->size_pack;
>> +                       /* If ATTR_EA_INFO exists 'info' can't be NULL. */
>> +                       if (info)
>> +                               dup->ea_size = info->size_pack;
>>                 }
>>         }
>>  
>> -- 
>> 2.33.0
>>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/ntfs3: Check for NULL if ATTR_EA_INFO is incorrect
       [not found]       ` <2998a9b9-8ea0-6a44-7093-66c7a08dcab2@gmail.com>
@ 2021-10-11 16:55         ` Konstantin Komarov
  2021-10-11 20:56           ` Mohammad Rasim
  0 siblings, 1 reply; 8+ messages in thread
From: Konstantin Komarov @ 2021-10-11 16:55 UTC (permalink / raw)
  To: Mohammad Rasim; +Cc: ntfs3, linux-kernel, linux-fsdevel, Kari Argillander

Hello.

Presumably we found the code, that panics.
But it panics in place, where pointer must be always not NULL.
Please try patch provided below.
If it helps (there is no panic), then check dmesg for
message "Looks like internal error".
And please compare copied folders.
This way it will be clear what file / folder cause this logic error.

Thanks for all your help so far.

[PATCH] fs/ntfs3: Check for NULL pointers in ni_try_remove_attr_list

All these checks must be redundant.
If this commit helps, then there is bug in code.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
 fs/ntfs3/frecord.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index ecb965e4afd0..37e19fe7d496 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -705,18 +705,35 @@ static int ni_try_remove_attr_list(struct ntfs_inode *ni)
 			continue;
 
 		mi = ni_find_mi(ni, ino_get(&le->ref));
+		if (!mi) {
+			/* Should never happened, 'cause already checked. */
+			goto bad;
+		}
 
 		attr = mi_find_attr(mi, NULL, le->type, le_name(le),
 				    le->name_len, &le->id);
+		if (!attr) {
+			/* Should never happened, 'cause already checked. */
+			goto bad;
+		}
 		asize = le32_to_cpu(attr->size);
 
 		/* Insert into primary record. */
 		attr_ins = mi_insert_attr(&ni->mi, le->type, le_name(le),
 					  le->name_len, asize,
 					  le16_to_cpu(attr->name_off));
-		id = attr_ins->id;
+		if (!attr_ins) {
+			/*
+			 * Internal error.
+			 * Either no space in primary record (already checked).
+			 * Either tried to insert another
+			 * non indexed attribute (logic error).
+			 */
+			goto bad;
+		}
 
 		/* Copy all except id. */
+		id = attr_ins->id;
 		memcpy(attr_ins, attr, asize);
 		attr_ins->id = id;
 
@@ -732,6 +749,10 @@ static int ni_try_remove_attr_list(struct ntfs_inode *ni)
 	ni->attr_list.dirty = false;
 
 	return 0;
+bad:
+	ntfs_inode_err(&ni->vfs_inode, "Looks like internal error");
+	make_bad_inode(&ni->vfs_inode);
+	return -EINVAL;
 }
 
 /*
-- 
2.33.0



On 06.10.2021 20:42, Mohammad Rasim wrote:
> 
> On 10/6/21 17:47, Konstantin Komarov wrote:
>>
>> On 04.10.2021 23:39, Mohammad Rasim wrote:
>>> On 10/3/21 20:50, Kari Argillander wrote:
>>>> On Wed, Sep 29, 2021 at 07:35:43PM +0300, Konstantin Komarov wrote:
>>>>> This can be reason for reported panic.
>>>>> Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")
>>>> I see that you have include this to devel branch but you did not send V2
>>>> [1]. I also included Mohammad Rasim to this thread. Maybe they can test
>>>> this patch. Rasim can you test [2] if your problem will be fixed with
>>>> this tree. Or just test this patch if you prefer that way.
>>>>
>>>> [1]: github.com/Paragon-Software-Group/linux-ntfs3/commit/35afb70dcfe4eb445060dd955e5b67d962869ce5
>>>> [2]: github.com/Paragon-Software-Group/linux-ntfs3/tree/devel
>>> Yeah unfortunately the problem still exist, moving the buildroot git tree from my nvme ext4 partition to my wd ntfs partition still causes the panic.
>>>
>>> Note that i used the master branch if that matters but it contains the same commit
>>>
>>>
>>> Regards
>>>
>> Is panic the same as old one?
>>
>> BUG: kernel NULL pointer dereference, address: 000000000000000e
>> RIP: 0010:ni_write_inode+0xe6b/0xed0 [ntfs3]
>> etc.
> 
> This is the complete panic log:
> 
> [  241.985898] ntfs3: sdb1: ino=724a0, "buildroot-raw" add mount option "acl" to use acl
> [  241.985905] ntfs3: sdb1: ino=724a0, "buildroot-raw" add mount option "acl" to use acl
> [  241.987109] ntfs3: sdb1: ino=724a1, ".git" add mount option "acl" to use acl
> [  241.987114] ntfs3: sdb1: ino=724a1, ".git" add mount option "acl" to use acl
> [  241.987630] ntfs3: sdb1: ino=724af, "branches" add mount option "acl" to use acl
> [  241.987634] ntfs3: sdb1: ino=724af, "branches" add mount option "acl" to use acl
> [  241.987645] ntfs3: sdb1: ino=724b0, "hooks" add mount option "acl" to use acl
> [  241.987647] ntfs3: sdb1: ino=724b0, "hooks" add mount option "acl" to use acl
> [  241.987670] ntfs3: sdb1: ino=724b1, "info" add mount option "acl" to use acl
> [  241.987672] ntfs3: sdb1: ino=724b1, "info" add mount option "acl" to use acl
> [  246.614529] BUG: kernel NULL pointer dereference, address: 000000000000000e
> [  246.614531] #PF: supervisor read access in kernel mode
> [  246.614532] #PF: error_code(0x0000) - not-present page
> [  246.614533] PGD 0 P4D 0
> [  246.614535] Oops: 0000 [#1] PREEMPT SMP NOPTI
> [  246.614536] CPU: 8 PID: 196 Comm: kworker/u64:7 Not tainted 5.14.0-rc7-MANJARO+ #51
> [  246.614538] Hardware name: Micro-Star International Co., Ltd MS-7C02/B450 TOMAHAWK MAX (MS-7C02), BIOS 3.B0 05/12/2021
> [  246.614539] Workqueue: writeback wb_workfn (flush-8:16)
> [  246.614543] RIP: 0010:ni_write_inode+0xd69/0xe40
> [  246.614545] Code: 4f 06 44 8b 40 04 41 8b 37 48 89 c3 44 0f b7 48 0a 48 8b 7c 24 18 4c 01 fa 44 89 44 24 30 e8 ae 32 01 00 8b 54 24 30 48 89 de <44> 0f b7 48 0e 48 89 c7 44 89 4c 24 28 e8 85 fc 97 00 44 8b 4c 24
> [  246.614546] RSP: 0018:ffffac2dc09cbac8 EFLAGS: 00010286
> [  246.614548] RAX: 0000000000000000 RBX: ffff98b0d08ac430 RCX: 0000000000000000
> [  246.614548] RDX: 0000000000000050 RSI: ffff98b0d08ac430 RDI: ffff98b0d88b31a4
> [  246.614549] RBP: ffff98b0d654f7a0 R08: ffff98b0d5be0000 R09: 0000000000000001
> [  246.614550] R10: 0000000000000002 R11: 0000000000000002 R12: 0000000000000000
> [  246.614550] R13: ffff98b0d4f6a000 R14: ffff98b0da2fcc80 R15: ffff98b0d08ab060
> [  246.614551] FS:  0000000000000000(0000) GS:ffff98b7dea00000(0000) knlGS:0000000000000000
> [  246.614552] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [  246.614553] CR2: 000000000000000e CR3: 00008001011f8000 CR4: 0000000000350ee0
> [  246.614554] Call Trace:
> [  246.614558]  __writeback_single_inode+0x25a/0x310
> [  246.614560]  writeback_sb_inodes+0x1fc/0x480
> [  246.614562]  __writeback_inodes_wb+0x4c/0xe0
> [  246.614563]  wb_writeback+0x1ff/0x2f0
> [  246.614564]  wb_workfn+0x2f8/0x510
> [  246.614566]  ? psi_task_switch+0xb9/0x1e0
> [  246.614567]  ? _raw_spin_unlock+0x16/0x30
> [  246.614570]  process_one_work+0x1e3/0x3b0
> [  246.614573]  worker_thread+0x50/0x3b0
> [  246.614574]  ? process_one_work+0x3b0/0x3b0
> [  246.614575]  kthread+0x141/0x170
> [  246.614577]  ? set_kthread_struct+0x40/0x40
> [  246.614579]  ret_from_fork+0x22/0x30
> [  246.614582] Modules linked in:
> [  246.614584] CR2: 000000000000000e
> [  246.614585] ---[ end trace 7c7c742732266d51 ]---
> [  246.614585] RIP: 0010:ni_write_inode+0xd69/0xe40
> [  246.614587] Code: 4f 06 44 8b 40 04 41 8b 37 48 89 c3 44 0f b7 48 0a 48 8b 7c 24 18 4c 01 fa 44 89 44 24 30 e8 ae 32 01 00 8b 54 24 30 48 89 de <44> 0f b7 48 0e 48 89 c7 44 89 4c 24 28 e8 85 fc 97 00 44 8b 4c 24
> [  246.614587] RSP: 0018:ffffac2dc09cbac8 EFLAGS: 00010286
> [  246.614588] RAX: 0000000000000000 RBX: ffff98b0d08ac430 RCX: 0000000000000000
> [  246.614589] RDX: 0000000000000050 RSI: ffff98b0d08ac430 RDI: ffff98b0d88b31a4
> [  246.614589] RBP: ffff98b0d654f7a0 R08: ffff98b0d5be0000 R09: 0000000000000001
> [  246.614590] R10: 0000000000000002 R11: 0000000000000002 R12: 0000000000000000
> [  246.614590] R13: ffff98b0d4f6a000 R14: ffff98b0da2fcc80 R15: ffff98b0d08ab060
> [  246.614591] FS:  0000000000000000(0000) GS:ffff98b7dea00000(0000) knlGS:0000000000000000
> [  246.614592] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [  246.614592] CR2: 000000000000000e CR3: 00008001011f8000 CR4: 0000000000350ee0
> [  246.991844] ntfs3: 6354 callbacks suppressed
> [  246.991846] ntfs3: sdb1: ino=73f4b, ".gstreamer1-mm.mk.SxnMfX" add mount option "acl" to use acl
> [  246.993111] ntfs3: sdb1: ino=73f4c, ".Config.in.2oeC7E" add mount option "acl" to use acl
> [  246.993135] ntfs3: sdb1: ino=73f4d, ".gstreamer1.hash.MS4lZ2" add mount option "acl" to use acl
> [  246.993159] ntfs3: sdb1: ino=73f4e, ".gstreamer1.mk.YFKaZf" add mount option "acl" to use acl
> [  246.993189] ntfs3: sdb1: ino=73f4f, ".Config.in.KMudor" add mount option "acl" to use acl
> [  246.993360] ntfs3: sdb1: ino=73f50, ".gtest.hash.2RTkJH" add mount option "acl" to use acl
> [  246.993383] ntfs3: sdb1: ino=73f51, ".gtest.mk.KTCGz4" add mount option "acl" to use acl
> [  246.993403] ntfs3: sdb1: ino=73f52, ".Config.in.8W4t5y" add mount option "acl" to use acl
> [  246.993423] ntfs3: sdb1: ino=73f53, ".gtk2-engines.hash.AOVwL1" add mount option "acl" to use acl
> [  246.994082] ntfs3: sdb1: ino=73f54, ".gtk2-engines.mk.WB8hM4" add mount option "acl" to use acl
> 
> 
>>>>> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
>>>>> ---
>>>>>    fs/ntfs3/frecord.c | 4 +++-
>>>>>    1 file changed, 3 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
>>>>> index 9a53f809576d..007602badd90 100644
>>>>> --- a/fs/ntfs3/frecord.c
>>>>> +++ b/fs/ntfs3/frecord.c
>>>>> @@ -3080,7 +3080,9 @@ static bool ni_update_parent(struct ntfs_inode *ni, struct NTFS_DUP_INFO *dup,
>>>>>                           const struct EA_INFO *info;
>>>>>                             info = resident_data_ex(attr, sizeof(struct EA_INFO));
>>>>> -                       dup->ea_size = info->size_pack;
>>>>> +                       /* If ATTR_EA_INFO exists 'info' can't be NULL. */
>>>>> +                       if (info)
>>>>> +                               dup->ea_size = info->size_pack;
>>>>>                   }
>>>>>           }
>>>>>    --
>>>>> 2.33.0
>>>>>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fs/ntfs3: Check for NULL if ATTR_EA_INFO is incorrect
  2021-10-11 16:55         ` Konstantin Komarov
@ 2021-10-11 20:56           ` Mohammad Rasim
  0 siblings, 0 replies; 8+ messages in thread
From: Mohammad Rasim @ 2021-10-11 20:56 UTC (permalink / raw)
  To: Konstantin Komarov; +Cc: ntfs3, linux-kernel, linux-fsdevel, Kari Argillander


On 10/11/21 19:55, Konstantin Komarov wrote:
> Hello.
>
> Presumably we found the code, that panics.
> But it panics in place, where pointer must be always not NULL.
> Please try patch provided below.
> If it helps (there is no panic), then check dmesg for
> message "Looks like internal error".
> And please compare copied folders.
> This way it will be clear what file / folder cause this logic error.
>
> Thanks for all your help so far.

Ok,

This helped, unfortunately the error is sporadic and i can't easily 
track down which file caused the crash .

In one test it seemd it was caused by files in three directories 
"package", "system" , "support" (all these directories are from the 
"buildroot" tree, most of the files that failed to copy were symlinks, 
don't know if that makes a difference)  but after rebooting and loading 
the unpatched ntfs3.ko i was able to copy these files without a crash!

It seems that the crash happens when copying large number of files so 
even a failed file can be copied if it was copied alone (I might be very 
wrong in my conclusion here)

anyways, i did multiple tests. in the first a few it copied without a 
crash and skipped a few files( the dmesg didn't contain the "Looks like 
internal error" message).

on subsequent tests i did get that message like so:

[  186.295722] ntfs3: sdb1: ino=1a, Looks like internal error
[  186.296219] ntfs3: sdb1: ntfs3_write_inode r=1a failed, -22

That "ino=1a" looks wrong to me !

  I will try to do more tests if i can but it's a bit annoying because 
each crash causes the file system to be corrupted and "ntfsfix" can't 
fix these errors so i have to reboot to windows os to be able to use 
"chkdsk" to fix the filesystem before doing the next test.

It would be nice if Paragon  releases "fsck.ntfs" that works well in 
these situations so we don't need to boot to windows to fix them


Regards


>
> [PATCH] fs/ntfs3: Check for NULL pointers in ni_try_remove_attr_list
>
> All these checks must be redundant.
> If this commit helps, then there is bug in code.
>
> Signed-off-by: Konstantin 
> Komarov<almaz.alexandrovich@paragon-software.com>
> ---
> fs/ntfs3/frecord.c | 23 ++++++++++++++++++++++-
> 1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
> index ecb965e4afd0..37e19fe7d496 100644
> --- a/fs/ntfs3/frecord.c
> +++ b/fs/ntfs3/frecord.c
> @@ -705,18 +705,35 @@ static int ni_try_remove_attr_list(struct 
> ntfs_inode *ni)
> continue;
> mi = ni_find_mi(ni, ino_get(&le->ref));
> + if (!mi) {
> + /* Should never happened, 'cause already checked. */
> + goto bad;
> + }
> attr = mi_find_attr(mi, NULL, le->type, le_name(le),
> le->name_len, &le->id);
> + if (!attr) {
> + /* Should never happened, 'cause already checked. */
> + goto bad;
> + }
> asize = le32_to_cpu(attr->size);
> /* Insert into primary record. */
> attr_ins = mi_insert_attr(&ni->mi, le->type, le_name(le),
> le->name_len, asize,
> le16_to_cpu(attr->name_off));
> - id = attr_ins->id;
> + if (!attr_ins) {
> + /*
> + * Internal error.
> + * Either no space in primary record (already checked).
> + * Either tried to insert another
> + * non indexed attribute (logic error).
> + */
> + goto bad;
> + }
> /* Copy all except id. */
> + id = attr_ins->id;
> memcpy(attr_ins, attr, asize);
> attr_ins->id = id;
> @@ -732,6 +749,10 @@ static int ni_try_remove_attr_list(struct 
> ntfs_inode *ni)
> ni->attr_list.dirty = false;
> return 0;
> +bad:
> + ntfs_inode_err(&ni->vfs_inode, "Looks like internal error");
> + make_bad_inode(&ni->vfs_inode);
> + return -EINVAL;
> }
> /*

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-10-11 20:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-29 16:35 [PATCH] fs/ntfs3: Check for NULL if ATTR_EA_INFO is incorrect Konstantin Komarov
2021-09-29 17:44 ` Kari Argillander
2021-10-03 17:50 ` Kari Argillander
2021-10-04 20:39   ` Mohammad Rasim
2021-10-06 14:47     ` Konstantin Komarov
     [not found]       ` <2998a9b9-8ea0-6a44-7093-66c7a08dcab2@gmail.com>
2021-10-11 16:55         ` Konstantin Komarov
2021-10-11 20:56           ` Mohammad Rasim
2021-10-06 14:51   ` Konstantin Komarov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).