Project

General

Profile

Actions

Bug #48202

closed

libcephfs allows calling ftruncate on a file open read-only

Added by John Mulligan over 3 years ago. Updated about 3 years ago.

Status:
Resolved
Priority:
Normal
Category:
Correctness/Safety
Target version:
% Done:

0%

Source:
Community (dev)
Tags:
Backport:
octopus,nautilus
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Component(FS):
Client
Labels (FS):
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

When calling ceph_ftruncate on an "fd" open read only, using the O_RDONLY flag, libcephfs does not return and error and instead truncates the file. Compare this to the typical libc/linux ftruncate call which will return an error when the fd is not open for writing.

To reproduce I am attaching a simple c file that first "touches" the file (to ensure it exists) and then opens it read only and then demonstrates that truncate "succeeds" but a subsequent write fails. In comparison I attach a c file with system calls that demonstrates that ftruncate fails before reaching the write call.

I originally discovered this issue while wrapping APIs for go-ceph, but wrote the C versions to ensure this issue was, in fact, present in the libcephs layer.

Please let me know if I can provide any other information.


Files

cephfs_ftruncate.c (2.14 KB) cephfs_ftruncate.c Reproduer John Mulligan, 11/11/2020 06:47 PM
just_ftruncate.c (1.24 KB) just_ftruncate.c Comparision John Mulligan, 11/11/2020 06:47 PM

Related issues 2 (0 open2 closed)

Copied to CephFS - Backport #48375: octopus: libcephfs allows calling ftruncate on a file open read-onlyResolvedNathan CutlerActions
Copied to CephFS - Backport #48376: nautilus: libcephfs allows calling ftruncate on a file open read-onlyResolvedNathan CutlerActions
Actions #1

Updated by Patrick Donnelly over 3 years ago

  • Status changed from New to In Progress
  • Assignee set to Patrick Donnelly
  • Target version set to v16.0.0
  • Source set to Community (dev)
  • Backport set to octopus,nautilus
Actions #2

Updated by Patrick Donnelly over 3 years ago

  • Status changed from In Progress to Fix Under Review
  • Pull request ID set to 38031
Actions #3

Updated by Patrick Donnelly over 3 years ago

  • Status changed from Fix Under Review to Pending Backport
Actions #4

Updated by Nathan Cutler over 3 years ago

  • Copied to Backport #48375: octopus: libcephfs allows calling ftruncate on a file open read-only added
Actions #5

Updated by Nathan Cutler over 3 years ago

  • Copied to Backport #48376: nautilus: libcephfs allows calling ftruncate on a file open read-only added
Actions #6

Updated by Nathan Cutler about 3 years ago

  • Status changed from Pending Backport to Resolved

While running with --resolve-parent, the script "backport-create-issue" noticed that all backports of this issue are in status "Resolved" or "Rejected".

Actions

Also available in: Atom PDF