Commit 48087fe
committed
smb: client: fix data loss due to broken rename(2)
JIRA: https://issues.redhat.com/browse/RHEL-114295
commit c5ea306
Author: Paulo Alcantara <pc@manguebit.org>
Date: Sun Sep 7 21:24:06 2025 -0300
smb: client: fix data loss due to broken rename(2)
Rename of open files in SMB2+ has been broken for a very long time,
resulting in data loss as the CIFS client would fail the rename(2)
call with -ENOENT and then removing the target file.
Fix this by implementing ->rename_pending_delete() for SMB2+, which
will rename busy files to random filenames (e.g. silly rename) during
unlink(2) or rename(2), and then marking them to delete-on-close.
Besides, introduce a FIND_WR_NO_PENDING_DELETE flag to prevent open(2)
from reusing open handles that had been marked as delete pending.
Handle it in cifs_get_readable_path() as well.
Reported-by: Jean-Baptiste Denis <jbdenis@pasteur.fr>
Closes: https://marc.info/?i=16aeb380-30d4-4551-9134-4e7d1dc833c0@pasteur.fr
Reviewed-by: David Howells <dhowells@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
Cc: Frank Sorenson <sorenson@redhat.com>
Cc: Olga Kornievskaia <okorniev@redhat.com>
Cc: Benjamin Coddington <bcodding@redhat.com>
Cc: Scott Mayhew <smayhew@redhat.com>
Cc: linux-cifs@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Paulo Alcantara <paalcant@redhat.com>1 parent c89f97a commit 48087fe
File tree
8 files changed
+268
-72
lines changed- fs/smb/client
8 files changed
+268
-72
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
1938 | 1938 | | |
1939 | 1939 | | |
1940 | 1940 | | |
1941 | | - | |
1942 | | - | |
1943 | | - | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
1944 | 1947 | | |
1945 | 1948 | | |
1946 | 1949 | | |
| |||
2374 | 2377 | | |
2375 | 2378 | | |
2376 | 2379 | | |
| 2380 | + | |
| 2381 | + | |
2377 | 2382 | | |
2378 | 2383 | | |
2379 | 2384 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
684 | | - | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
685 | 688 | | |
686 | 689 | | |
687 | 690 | | |
| |||
2286 | 2289 | | |
2287 | 2290 | | |
2288 | 2291 | | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
2289 | 2295 | | |
2290 | 2296 | | |
2291 | 2297 | | |
| |||
2403 | 2409 | | |
2404 | 2410 | | |
2405 | 2411 | | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
2406 | 2422 | | |
2407 | 2423 | | |
2408 | 2424 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1912 | 1912 | | |
1913 | 1913 | | |
1914 | 1914 | | |
1915 | | - | |
| 1915 | + | |
1916 | 1916 | | |
1917 | 1917 | | |
1918 | 1918 | | |
| |||
1983 | 1983 | | |
1984 | 1984 | | |
1985 | 1985 | | |
1986 | | - | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
1987 | 1991 | | |
1988 | 1992 | | |
1989 | 1993 | | |
| |||
2051 | 2055 | | |
2052 | 2056 | | |
2053 | 2057 | | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
2054 | 2063 | | |
2055 | 2064 | | |
2056 | 2065 | | |
| |||
2338 | 2347 | | |
2339 | 2348 | | |
2340 | 2349 | | |
| 2350 | + | |
| 2351 | + | |
2341 | 2352 | | |
| 2353 | + | |
2342 | 2354 | | |
2343 | 2355 | | |
2344 | 2356 | | |
2345 | 2357 | | |
2346 | 2358 | | |
2347 | 2359 | | |
2348 | | - | |
2349 | 2360 | | |
2350 | 2361 | | |
2351 | 2362 | | |
| |||
2438 | 2449 | | |
2439 | 2450 | | |
2440 | 2451 | | |
2441 | | - | |
| 2452 | + | |
2442 | 2453 | | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
2443 | 2457 | | |
2444 | 2458 | | |
2445 | 2459 | | |
| |||
2450 | 2464 | | |
2451 | 2465 | | |
2452 | 2466 | | |
| 2467 | + | |
2453 | 2468 | | |
2454 | 2469 | | |
2455 | 2470 | | |
| |||
2485 | 2500 | | |
2486 | 2501 | | |
2487 | 2502 | | |
| 2503 | + | |
2488 | 2504 | | |
2489 | 2505 | | |
2490 | 2506 | | |
| |||
2569 | 2585 | | |
2570 | 2586 | | |
2571 | 2587 | | |
2572 | | - | |
2573 | | - | |
2574 | | - | |
2575 | | - | |
2576 | | - | |
2577 | | - | |
2578 | | - | |
2579 | | - | |
2580 | | - | |
2581 | | - | |
2582 | | - | |
2583 | | - | |
2584 | | - | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
2585 | 2635 | | |
2586 | 2636 | | |
2587 | 2637 | | |
| |||
2610 | 2660 | | |
2611 | 2661 | | |
2612 | 2662 | | |
| 2663 | + | |
| 2664 | + | |
2613 | 2665 | | |
2614 | 2666 | | |
2615 | 2667 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
| 35 | + | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
| |||
0 commit comments