Project

General

Profile

Bug #48202

libcephfs allows calling ftruncate on a file open read-only

Added by John Mulligan 3 months ago. Updated 2 months ago.

Status:
Pending Backport
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:

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.

cephfs_ftruncate.c View - Reproduer (2.14 KB) John Mulligan, 11/11/2020 06:47 PM

just_ftruncate.c View - Comparision (1.24 KB) John Mulligan, 11/11/2020 06:47 PM


Related issues

Copied to CephFS - Backport #48375: octopus: libcephfs allows calling ftruncate on a file open read-only In Progress
Copied to CephFS - Backport #48376: nautilus: libcephfs allows calling ftruncate on a file open read-only New

History

#1 Updated by Patrick Donnelly 3 months 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

#2 Updated by Patrick Donnelly 3 months ago

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

#3 Updated by Patrick Donnelly 2 months ago

  • Status changed from Fix Under Review to Pending Backport

#4 Updated by Nathan Cutler 2 months ago

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

#5 Updated by Nathan Cutler 2 months ago

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

Also available in: Atom PDF