Skip to content

netfilter: pin file with get_file_rcu() before reading f_cred

Tristan Madani netdev netfilter-devel stable syzbot 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5netfilter: xt_owner: pin file with get_file_rcu() before reading f_crednet/netfilter/xt_owner.c+18 -90 replies
2/5netfilter: nft_meta: pin file with get_file_rcu() before reading f_crednet/netfilter/nft_meta.c+12 -70 replies
3/5netfilter: nfnetlink_log: pin file with get_file_rcu() before reading f_crednet/netfilter/nfnetlink_log.c+11 -60 replies
4/5netfilter: nfnetlink_queue: pin file with get_file_rcu() before reading f_crednet/netfilter/nfnetlink_queue.c+11 -60 replies
5/5netfilter: nf_log_syslog: pin file with get_file_rcu() before reading f_crednet/netfilter/nf_log_syslog.c+12 -70 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH nf 0/5] netfilter: pin file with get_file_rcu() before reading f_cred

From: Tristan Madani <[email protected]>

Since commit 0ede61d8589cc ("file: convert to SLAB_TYPESAFE_BY_RCU"), struct file objects can have their slab slot reused while RCU readers still hold pointers to them.

Five netfilter locations read file->f_cred through a stored sock->file pointer under RCU without pinning the file. If the slab slot is reused between the pointer read and the credential dereference, the check operates on stale or unrelated credential data.

Pin the file with get_file_rcu() and release with fput() on all paths.

Tristan Madani (5):
netfilter: xt_owner: pin file with get_file_rcu() before reading
f_cred
netfilter: nft_meta: pin file with get_file_rcu() before reading
f_cred
netfilter: nfnetlink_log: pin file with get_file_rcu() before reading
f_cred
netfilter: nfnetlink_queue: pin file with get_file_rcu() before
reading f_cred
netfilter: nf_log_syslog: pin file with get_file_rcu() before reading
f_cred

 net/netfilter/nf_log_syslog.c   | 19 ++++++++++++-------
 net/netfilter/nfnetlink_log.c   | 17 +++++++++++------
 net/netfilter/nfnetlink_queue.c | 17 +++++++++++------
 net/netfilter/nft_meta.c        | 19 ++++++++++++-------
 net/netfilter/xt_owner.c        | 27 +++++++++++++++---------
 5 files changed, 64 insertions(+), 35 deletions(-)
Signature · 1 line
2.47.3