(In reply to Colin Ian King from comment #7) > The file is created but the fd is -1. Surely the semantics of a O_CREAT > failure are a file that's not created.
Not necessarily. You're requesting a file to be created and to be opened afterwards with O_DIRECT support and what we do in this case is fail the open even though the create was successful. Stuff like that can also happen in other cases. In containers you can end up with scenarios where you fail to open a file you created - probably hard to create but possible. Other scenarios would be were your LSM allows you to create files but not to open them. -- You received this bug notification because you are a member of Kernel Packages, which is subscribed to linux in Ubuntu. https://bugs.launchpad.net/bugs/2041670 Title: tmpfs: O_DIRECT | O_CREATE open reports open failure but actually creates a file. Status in Linux: Unknown Status in linux package in Ubuntu: New Bug description: creating a file on tmpfs with open(filename, O_RDWR | O_DIRECT | O_CREAT, 0666) reports an open failure error EINVAL, but still creates the file. The file should not be created if we hit such an error. Tested and fails on: mantic amd64: 6.5.0-10-generic lunar amd64: 6.2.0-35-generic jammie amd64: 5.15.0-generic focal: 5.4.0-165-generic bionic: 4.15.0-213-generic trusty: 4.4.0-148-generic sudo mkdir /mnt/tmpfs sudo mount -t tmpfs -o size=1G,nr_inodes=10k,mode=777 tmpfs /mnt/tmpfs sudo chmod 666 /mnt/tmpfs gcc reproducer.c -o reproducer sudo ./reproducer Run the attached program. It reports an open failure (errno 22, EINVAL) but still manages to create the file. Note this was original discovered by running stress-ng on tmpfs with the open stressor: stress-ng --open 1 To manage notifications about this bug go to: https://bugs.launchpad.net/linux/+bug/2041670/+subscriptions -- Mailing list: https://launchpad.net/~kernel-packages Post to : kernel-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~kernel-packages More help : https://help.launchpad.net/ListHelp