cifs: Copying file to same directory results in page fault
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux (Ubuntu) |
Invalid
|
Undecided
|
Unassigned | ||
Mantic |
Fix Released
|
High
|
Matthew Ruffell |
Bug Description
BugLink: https:/
[Impact]
Copying or modifying a file to the same directory within a cifs mount results in a page fault, and the process that initiated the copy being killed. This could be cp, nautilus, etc.
This results in the following oops:
BUG: unable to handle page fault for address: fffffffffffffffe
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD f45a3f067 P4D f45a3f067 PUD f45a41067 PMD 0
Oops: 0000 [#1] PREEMPT SMP NOPTI
CPU: 0 PID: 28103 Comm: Thread (pooled) Tainted: P OE 6.5.0-27-generic #28-Ubuntu
RIP: 0010:cifs_
Code: 49 89 cd 31 c9 41 54 49 89 f4 48 c1 ee 0c 53 48 83 ec 08 48 8b 7f 30 44 89 45 d4 e8 79 b3 23 f1 48 89 c3 31 c0 48 85 db 74 77 <48> 8b 13 b8 00 10 00 00 f7 c2 00 00 01 00 74 10 0f b6 4b 51 48 d3
RSP: 0018:ffffaab686
RAX: 0000000000000000 RBX: fffffffffffffffe RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffaab6865ffc28 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000023854 R11: 0000000000000000 R12: 0000000000000000
R13: ffffaab6865ffc78 R14: ffff906675d8aed0 R15: ffffaab6865ffc70
FS: 00007bd4d594b6c
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: fffffffffffffffe CR3: 000000017022a000 CR4: 0000000000750ef0
PKRU: 55555554
Call Trace:
<TASK>
? show_regs+0x6d/0x80
? __die+0x24/0x80
? page_fault_
? kernelmode_
? __bad_area_
? bad_area_
? do_kern_
? exc_page_
? asm_exc_
? cifs_flush_
? cifs_flush_
cifs_remap_
do_clone_
vfs_clone_
ioctl_file_
do_vfs_
? __fget_
__x64_sys_
do_syscall_
? kmem_cache_
? putname+0x5b/0x80
? exit_to_
? syscall_
? do_syscall_
? do_syscall_
? do_syscall_
There is no known workaround.
[Fix]
The stacktrace is very similar to a regression reported to upstream 6.1.y:
https:/
The thread mentions that:
commit 7b2404a886f8b91
Author: David Howells <email address hidden>
Date: Fri Dec 1 00:22:00 2023 +0000
Subject: cifs: Fix flushing, invalidation and file size with copy_file_range()
Link: https:/
introduced the issue to Debian's 6.1 kernel.
This got backported to Ubuntu in:
commit 3adbe2ccd8b9b8f
Author: David Howells <email address hidden>
Date: Fri Dec 1 00:22:00 2023 +0000
Subject: cifs: Fix flushing, invalidation and file size with copy_file_range()
$ git describe --contains 3adbe2ccd8b9b8f
Ubuntu-
Which we have been using for some time now, and is not the culprit.
Reading the regression mailing list thread, they mention that things work differently in 6.1:
> Yeah. __filemap_
> folio or NULL. In 6.7 it returns a folio or a negative error code. The error
> check in cifs_flush_folio() needs to change to something like:
>
> folio = filemap_
> if (!folio)
> return -ENOMEM;
>
> David
6.1.y then got a specific patch to fix the issue in 6.1, which is:
commit 21bb2ba4f1ac1e3
Author: Steve French <email address hidden>
Date: Fri Jan 12 23:08:51 2024 -0600
Subject: cifs: fix flushing folio regression for 6.1 backport
Link: https:/
$ git describe --contains 21bb2ba4f1ac1e3
Ubuntu-
Since the Ubuntu mantic kernel consumes both 6.1.y and 6.7.y / 6.8.y stable patches, this patch was applied to mantic's 6.5 kernel by mistake, and contains the wrong logic for how __filemap_
The fix is to revert "cifs: fix flushing folio regression for 6.1 backport" as a SAUCE patch.
[Testcase]
Start two VMs. One is recommended to be Debian 12, which is what some users have had luck with in the past, as the server, and the client can be mantic.
Server
------
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install samba
$ sudo vim /etc/samba/smb.conf
server min protocol = NT1
[sambashare]
comment = Samba on Ubuntu
path = /home/ubuntu/
read only = no
browsable = yes
$ mkdir ~/sambashare
$ sudo smbpasswd -a ubuntu
Client
------
$ sudo apt update
$ sudo apt install cifs-utils
$ mkdir ~/share
$ sudo mount -t cifs -o username=ubuntu //192.168.
Password for ubuntu@
$ mount -l
...
//192.168.
$ ls
hallo.txt hello.txt sample.txt sample2.txt
$ sudo cp hello.txt hello.txt.1
Killed
If you install the test kernel available from the following ppa:
https:/
The copy will work as expected.
[Where problems could occur]
Reverting the patch restores logic back to how it was between 6.5.0-20-generic through to 6.5.0-26-generic, which functions, and is well tested by the community.
If a regression were to occur, it would impact all writes to cifs mounts, particularly to the same destination directory as the origin file. There is no known workarounds.
Changed in linux (Ubuntu): | |
assignee: | nobody → Jose Ogando Justo (joseogando) |
no longer affects: | linux-raspi (Ubuntu) |
no longer affects: | linux-hwe-6.5 (Ubuntu) |
no longer affects: | linux-azure (Ubuntu) |
Changed in linux (Ubuntu): | |
assignee: | Jose Ogando Justo (joseogando) → nobody |
status: | Confirmed → Invalid |
Changed in linux (Ubuntu Mantic): | |
status: | New → In Progress |
importance: | Undecided → High |
assignee: | nobody → Matthew Ruffell (mruffell) |
summary: |
- Remote filesystems mounted as CIFS not working after update to Kernel - "6.5.0-27-generic #28-Ubuntu" (amd64) or Kernel "6.5.0-1014-raspi - #17-Ubuntu" (aarch64). + cifs: Copying file to same directory results in page fault |
description: | updated |
Status changed to 'Confirmed' because the bug affects multiple users.