Skip to content

seq_file allocation in seq_open()

Yann Droneaud linux-fsdevel lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3fs: use seq_open_private() for proc_mountsfs/mount.h fs/namespace.c fs/proc_namespace.c+19 -240 replies
2/3fs: allocate structure unconditionally in seq_open()fs/seq_file.c+9 -70 replies
3/3fs: documents seq_open()'s usage of file->private_datafs/seq_file.c+2 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] seq_file allocation in seq_open()

Hi,

I found myself trying to use seq_open() and experiencing crash as seq_open() was using my private data in file->private_data as its own struct seq_file.

It should be noted such behavior is not documented.

It's also an issue if seq_release() is used in release handler, as it will kfree() a pointer which was not allocated by seq_open().

So, please find a patchset that drop the support for pre-allocated struct seq_file in seq_open(): it's only of use in proc_namespace.c and can be easily replaced by using seq_open_private()/seq_release_private().

Additionally, it documents the use of file->private_data to hold pointer to struct seq_file.

Yann Droneaud (3):
fs: use seq_open_private() for proc_mounts
fs: allocate structure unconditionally in seq_open()
fs: documents seq_open()'s usage of file->private_data

 fs/mount.h          |  3 ---
 fs/namespace.c      |  6 +++---
 fs/proc_namespace.c | 34 ++++++++++++++++------------------
 fs/seq_file.c       | 18 +++++++++++-------
 4 files changed, 30 insertions(+), 31 deletions(-)
Signature · 1 line
2.1.0