mbox series

[0/2] smb: client: fix "df: Resource temporarily unavailable" on 5.10 stable kernel

Message ID 20240126193143.245122-1-kovalev@altlinux.org
Headers show
Series smb: client: fix "df: Resource temporarily unavailable" on 5.10 stable kernel | expand

Message

kovalev@altlinux.org Jan. 26, 2024, 7:31 p.m. UTC
After mounting a remote cifs resource, it becomes unavailable:
df: /mnt/sambashare: Resource temporarily unavailable

It was tested on the following Linux kernels:
Linux altlinux 5.10.208-std-def-alt1
Linux fedora 5.10.208-200.el8.x86_64

The error appeared starting from kernel 5.10.206 after adding
the commit [1] "smb: client: fix OOB in SMB2_query_info_init()",
in which the buffer length increases by 1 as a result of changes:
...
-      iov[0].iov_len = total_len - 1 + input_len;
+      iov[0].iov_len = len;
...

[1] https://patchwork.kernel.org/project/cifs-client/patch/20231213152557.6634-2-pc@manguebit.com/

Error fixed by backported commits in next two patches  adapted for the 5.10 kernel:

[PATCH 1/2] stddef: Introduce DECLARE_FLEX_ARRAY() helper
[PATCH 2/2] smb3: Replace smb2pdu 1-element arrays with flex-arrays

Comments

Greg KH Jan. 27, 2024, 12:49 a.m. UTC | #1
On Fri, Jan 26, 2024 at 10:31:41PM +0300, kovalev@altlinux.org wrote:
> After mounting a remote cifs resource, it becomes unavailable:
> df: /mnt/sambashare: Resource temporarily unavailable
> 
> It was tested on the following Linux kernels:
> Linux altlinux 5.10.208-std-def-alt1
> Linux fedora 5.10.208-200.el8.x86_64
> 
> The error appeared starting from kernel 5.10.206 after adding
> the commit [1] "smb: client: fix OOB in SMB2_query_info_init()",
> in which the buffer length increases by 1 as a result of changes:
> ...
> -      iov[0].iov_len = total_len - 1 + input_len;
> +      iov[0].iov_len = len;
> ...
> 
> [1] https://patchwork.kernel.org/project/cifs-client/patch/20231213152557.6634-2-pc@manguebit.com/
> 
> Error fixed by backported commits in next two patches  adapted for the 5.10 kernel:
> 
> [PATCH 1/2] stddef: Introduce DECLARE_FLEX_ARRAY() helper
> [PATCH 2/2] smb3: Replace smb2pdu 1-element arrays with flex-arrays
> 
> 

Now queued up, thanks.

greg k-h
Harshit Mogalapalli Jan. 27, 2024, 6:42 a.m. UTC | #2
Hi,

Adding more people to CC.(who have looked at this issue)

On 27/01/24 6:19 am, Greg KH wrote:
> On Fri, Jan 26, 2024 at 10:31:41PM +0300, kovalev@altlinux.org wrote:
>> After mounting a remote cifs resource, it becomes unavailable:
>> df: /mnt/sambashare: Resource temporarily unavailable
>>
>> It was tested on the following Linux kernels:
>> Linux altlinux 5.10.208-std-def-alt1
>> Linux fedora 5.10.208-200.el8.x86_64
>>
>> The error appeared starting from kernel 5.10.206 after adding
>> the commit [1] "smb: client: fix OOB in SMB2_query_info_init()",
>> in which the buffer length increases by 1 as a result of changes:
>> ...
>> -      iov[0].iov_len = total_len - 1 + input_len;
>> +      iov[0].iov_len = len;
>> ...
>>

We can reproduce this on 5.15.148(latest 5.15.y) and Mohamed reported 
this on 6.1.y, so we need backports there as well.

https://lore.kernel.org/all/09738f0f-53a2-43f1-a09d-a2bef48e1344@oracle.com/


[root@vm1 xfstests-dev]# ./check -g quick -s smb3
TEST_DEV=//<SERVER_IP>/TEST is mounted but not a type cifs filesystem
[root@vm1 xfstests-dev]# df
df: /mnt/test: Resource temporarily unavailable


This two patch series doesn't cleanly apply to 5.15.y.

Also I am unsure, which is the better approach to go with

Approach 1 - suggested by Paulo:
https://lore.kernel.org/all/446860c571d0699ed664175262a9e84b@manguebit.com/

Approach 2 - this series
Pulling in [PATCH 2/2] smb3: Replace smb2pdu 1-element arrays with 
flex-arrays like this series did.

I think approach 1 is better as the changes are minimal, but please 
correct me if that seems wrong.

Thanks,
Harshit
>> [1] https://patchwork.kernel.org/project/cifs-client/patch/20231213152557.6634-2-pc@manguebit.com/
>>
>> Error fixed by backported commits in next two patches  adapted for the 5.10 kernel:
>>
>> [PATCH 1/2] stddef: Introduce DECLARE_FLEX_ARRAY() helper
>> [PATCH 2/2] smb3: Replace smb2pdu 1-element arrays with flex-arrays
>>
>>
> 
> Now queued up, thanks.
> 
> greg k-h
>
kovalev@altlinux.org Jan. 27, 2024, 8:02 a.m. UTC | #3
Hi,

27.01.2024 09:42, Harshit Mogalapalli wrote:
> We can reproduce this on 5.15.148(latest 5.15.y) and Mohamed reported 
> this on 6.1.y, so we need backports there as well.

in the 6.1.72 kernel, this problem was fixed by the commit [1] "smb3: 
Replace smb2pdu 1-element arrays with flex-arrays", which was proposed 
in this series of patches.


[1] https://lore.kernel.org/all/2024010937-eggplant-bauble-d556@gregkh/T/
Harshit Mogalapalli Jan. 27, 2024, 1:29 p.m. UTC | #4
Hi Kovalev,

On 27/01/24 1:32 pm, kovalev@altlinux.org wrote:
> Hi,
> 
> 27.01.2024 09:42, Harshit Mogalapalli wrote:
>> We can reproduce this on 5.15.148(latest 5.15.y) and Mohamed reported 
>> this on 6.1.y, so we need backports there as well.
> 
> in the 6.1.72 kernel, this problem was fixed by the commit [1] "smb3: 
> Replace smb2pdu 1-element arrays with flex-arrays", which was proposed 
> in this series of patches.
> 
Thanks for sharing this, I didnot notice that the above commit was 
backported to 6.1.72.

I think we still need fixing in 5.15.y as the commit eb3e28c1e89b 
("smb3: Replace smb2pdu 1-element arrays with flex-arrays") is not in 
5.15.148

Thanks,
Harshit
> 
> [1] https://lore.kernel.org/all/2024010937-eggplant-bauble-d556@gregkh/T/
>
Greg KH Jan. 27, 2024, 9:20 p.m. UTC | #5
On Sat, Jan 27, 2024 at 06:59:15PM +0530, Harshit Mogalapalli wrote:
> Hi Kovalev,
> 
> On 27/01/24 1:32 pm, kovalev@altlinux.org wrote:
> > Hi,
> > 
> > 27.01.2024 09:42, Harshit Mogalapalli wrote:
> > > We can reproduce this on 5.15.148(latest 5.15.y) and Mohamed
> > > reported this on 6.1.y, so we need backports there as well.
> > 
> > in the 6.1.72 kernel, this problem was fixed by the commit [1] "smb3:
> > Replace smb2pdu 1-element arrays with flex-arrays", which was proposed
> > in this series of patches.
> > 
> Thanks for sharing this, I didnot notice that the above commit was
> backported to 6.1.72.
> 
> I think we still need fixing in 5.15.y as the commit eb3e28c1e89b ("smb3:
> Replace smb2pdu 1-element arrays with flex-arrays") is not in 5.15.148

Patches gladly accepted :)
Steve French Jan. 27, 2024, 11:01 p.m. UTC | #6
On Sat, Jan 27, 2024 at 12:43 AM Harshit Mogalapalli
<harshit.m.mogalapalli@oracle.com> wrote:
>
> Hi,
>
> Adding more people to CC.(who have looked at this issue)
>
> On 27/01/24 6:19 am, Greg KH wrote:
> > On Fri, Jan 26, 2024 at 10:31:41PM +0300, kovalev@altlinux.org wrote:
> >> After mounting a remote cifs resource, it becomes unavailable:
> >> df: /mnt/sambashare: Resource temporarily unavailable
> >>
> >> It was tested on the following Linux kernels:
> >> Linux altlinux 5.10.208-std-def-alt1
> >> Linux fedora 5.10.208-200.el8.x86_64
> >>
> >> The error appeared starting from kernel 5.10.206 after adding
> >> the commit [1] "smb: client: fix OOB in SMB2_query_info_init()",
> >> in which the buffer length increases by 1 as a result of changes:
> >> ...
> >> -      iov[0].iov_len = total_len - 1 + input_len;
> >> +      iov[0].iov_len = len;
> >> ...
> >>
>
> We can reproduce this on 5.15.148(latest 5.15.y) and Mohamed reported
> this on 6.1.y, so we need backports there as well.
>
> https://lore.kernel.org/all/09738f0f-53a2-43f1-a09d-a2bef48e1344@oracle.com/
>
>
> [root@vm1 xfstests-dev]# ./check -g quick -s smb3
> TEST_DEV=//<SERVER_IP>/TEST is mounted but not a type cifs filesystem
> [root@vm1 xfstests-dev]# df
> df: /mnt/test: Resource temporarily unavailable
>
>
> This two patch series doesn't cleanly apply to 5.15.y.
>
> Also I am unsure, which is the better approach to go with
>
> Approach 1 - suggested by Paulo:
> https://lore.kernel.org/all/446860c571d0699ed664175262a9e84b@manguebit.com/
>
> Approach 2 - this series
> Pulling in [PATCH 2/2] smb3: Replace smb2pdu 1-element arrays with
> flex-arrays like this series did.
>
> I think approach 1 is better as the changes are minimal, but please
> correct me if that seems wrong.

Yes - Paulo's fix looks simple