Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-108683

[cifs] remove fallback unlink/rename when overwriting a file by renaming

Linking RHIVOS CVEs to...Migration: Automation ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • kernel-6.12.0-141.el10
    • No
    • Low
    • ZStream
    • rhel-fs-net
    • 3
    • 30
    • 3
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • Regression Exception
    • Unspecified
    • Unspecified
    • Unspecified
    • None
    • Merge Request passes all submitter checks, Merge Request finished CI testing, Merge Request passed CI testing, Merge Request approved by peer review

      What were you trying to do that didn't work?

      When renaming a file onto an existing file that is open, the atomic cifs rename fails, so the kernel falls back to a two-step 'unlink' of the target file, followed by 'rename' of the source filename to the target name. However, since the file is still open, the rename cannot complete. The result is that the target file is deleted, and the source filename remains. The 'rename' syscall returns -ENOENT.

      What is the impact of this issue to you?

      Deletion of the target file is undesirable, given that the rename failed.

      Please provide the package NVR for which the bug is seen:

      kernel-6.12.0-55.27.1.el10_0
      (as well as upstream)

      How reproducible is this bug?:

      easy

      Steps to reproduce

      1.  echo test1 >test1
      2.  echo test2 >test2
      3.  exec 3<>test1
      4.  mv -f test2 test1

      Expected results

      Target file not deleted, since rename failed (due to file being open)

      Actual results

      # mv -f test2 test1
      mv: cannot move 'test2' to 'test1': No such file or directory
      
      # ls -al test1 test2
      -rwxr-xr-x. 0 root root 6 Aug 11 14:16 test1
      -rwxr-xr-x. 1 root root 6 Aug 11 14:16 test2
      

      (test1 has no more links)

      close the file:

      # exec 3>&-
      # ls -al test1 test2
      ls: cannot access 'test1': No such file or directory
      -rwxr-xr-x. 1 root root 6 Aug 11 14:16 test2
      

              paalcant@redhat.com Paulo Alcantara
              rhn-support-fsorenso Frank Sorenson
              CIFS Team CIFS Team
              Xiaoli Feng Xiaoli Feng
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated: