kernfs, sysfs: refuse splice on /sys/power/resume
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest2 patches 2 repliesIn review
- v22 patches 3 repliesSuperseded
Changes in v3 from the cover letter
- Rename SYSFS_LOOKUP and ->may_lookup to SYSFS_NO_SPLICE and ->no_splice (Tejun).
- Drop the mmap, prealloc and binary attribute checks (Tejun).
- Add Rafael's Acked-by to patch 2.
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | kernfs, sysfs: add SYSFS_NO_SPLICE to refuse splice on writable opensfs/ fs/ fs/ +2 more | +88 | 2 replies | |
| 2/2 | PM: hibernate: refuse splice on /sys/power/resumekernel/ | +2 | 0 replies |
Reviews trailers per patch
1 of 2 patches has a Reviewed-by or Acked-by.
| Patch | Rafael J. Wysocki (Intel) |
|---|---|
| 1/2 | |
| 2/2 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 0/2] kernfs, sysfs: refuse splice on /sys/power/resume
This series refuses splice on writable opens of /sys/power/resume and gives those opens separate lockdep classes, as Tejun suggested in the v1 discussion.
The reported cycle is assembled from two operations. Splice into an ordinary writable kernfs file records pipe->mutex before of->mutex. A normal write to /sys/power/resume records of->mutex before the autofs pipe locks when resume_store() resolves a relative path.
Patch 1 adds SYSFS_NO_SPLICE and kernfs_ops->no_splice. Writable opens of a marked file refuse both splice directions. Their of->mutex and seq_file lock use separate classes. Read-only opens retain splice support.
Patch 2 marks /sys/power/resume. Normal reads and writes stay unchanged, including a write which resolves a relative path through autofs. Rafael acked it to go together with patch 1.
Other stores also look up paths. They remain outside this minimal series and can be marked in follow-up patches.
Tested on v7.4-rc1 in a QEMU guest with the syzbot kernel config. Without the series, the C and syz reproducers trigger the reported lockdep cycle, and a splice from the autofs daemon pipe into /sys/power/resume deadlocks. With the series, neither reproducer triggers a lockdep report although autofs receives the same requests, and that splice fails with EINVAL. Plain reads and writes of /sys/power/resume, read-only splice and splice on other sysfs and cgroup files work as before.
v3:
- Rename SYSFS_LOOKUP and ->may_lookup to SYSFS_NO_SPLICE and ->no_splice (Tejun).
- Drop the mmap, prealloc and binary attribute checks (Tejun).
- Add Rafael's Acked-by to patch 2.
v2:
- Replace the v1 locking changes with per-attribute splice control.
- Preserve splice on read-only opens.
- Split both the open-file mutex and seq_file lock classes.
- Reject incompatible mmap and preallocated-buffer combinations.
- Reject SYSFS_LOOKUP on binary attributes.
- Rebase onto v7.4-rc1.
v2: https://lore.kernel.org/r/[email protected]
v1: https://lore.kernel.org/r/[email protected]
Krystian Kaniewski (2):
kernfs, sysfs: add SYSFS_NO_SPLICE to refuse splice on writable opens
PM: hibernate: refuse splice on /sys/power/resume
fs/kernfs/file.c | 46 +++++++++++++++++++++++++++++++++++++--- fs/sysfs/file.c | 18 ++++++++++++++++ fs/sysfs/group.c | 4 ++-- include/linux/kernfs.h | 9 ++++++++ include/linux/sysfs.h | 22 +++++++++++++------ kernel/power/hibernate.c | 3 ++- 6 files changed, 90 insertions(+), 12 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
Signature · 1 line
2.53.0