Star64_linux/net
Linus Torvalds d8e464ecc1 vfs: mark pipes and sockets as stream-like file descriptors
In commit 3975b097e5 ("convert stream-like files -> stream_open, even
if they use noop_llseek") Kirill used a coccinelle script to change
"nonseekable_open()" to "stream_open()", which changed the trivial cases
of stream-like file descriptors to the new model with FMODE_STREAM.

However, the two big cases - sockets and pipes - don't actually have
that trivial pattern at all, and were thus never converted to
FMODE_STREAM even though it makes lots of sense to do so.

That's particularly true when looking forward to the next change:
getting rid of FMODE_ATOMIC_POS entirely, and just using FMODE_STREAM to
decide whether f_pos updates are needed or not.  And if they are, we'll
always do them atomically.

This came up because KCSAN (correctly) noted that the non-locked f_pos
updates are data races: they are clearly benign for the case where we
don't care, but it would be good to just not have that issue exist at
all.

Note that the reason we used FMODE_ATOMIC_POS originally is that only
doing it for the minimal required case is "safer" in that it's possible
that the f_pos locking can cause unnecessary serialization across the
whole write() call.  And in the worst case, that kind of serialization
can cause deadlock issues: think writers that need readers to empty the
state using the same file descriptor.

[ Note that the locking is per-file descriptor - because it protects
  "f_pos", which is obviously per-file descriptor - so it only affects
  cases where you literally use the same file descriptor to both read
  and write.

  So a regular pipe that has separate reading and writing file
  descriptors doesn't really have this situation even though it's the
  obvious case of "reader empties what a bit writer concurrently fills"

  But we want to make pipes as being stream-line anyway, because we
  don't want the unnecessary overhead of locking, and because a named
  pipe can be (ab-)used by reading and writing to the same file
  descriptor. ]

There are likely a lot of other cases that might want FMODE_STREAM, and
looking for ".llseek = no_llseek" users and other cases that don't have
an lseek file operation at all and making them use "stream_open()" might
be a good idea.  But pipes and sockets are likely to be the two main
cases.

Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Eic Dumazet <edumazet@google.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Marco Elver <elver@google.com>
Cc: Andrea Parri <parri.andrea@gmail.com>
Cc: Paul McKenney <paulmck@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-11-25 09:12:11 -08:00
..
6lowpan
9p
802
8021q
appletalk
atm net: atm: Reduce the severity of logging in unlink_clip_vcc 2019-11-18 17:08:20 -08:00
ax25
batman-adv Here are two batman-adv bugfixes: 2019-10-28 16:39:07 -07:00
bluetooth
bpf
bpfilter
bridge bridge: ebtables: don't crash when using dnat target in output chains 2019-11-04 20:58:34 +01:00
caif
can can: j1939: warn if resources are still linked on destroy 2019-11-13 10:42:34 +01:00
ceph
core net: rtnetlink: prevent underflows in do_setvfinfo() 2019-11-22 09:28:46 -08:00
dcb
dccp dccp: do not leak jiffies on the wire 2019-11-04 11:36:31 -08:00
decnet
dns_resolver
dsa net: dsa: tag_8021q: Fix dsa_8021q_restore_pvid for an absent pvid 2019-11-16 12:23:53 -08:00
ethernet
hsr
ieee802154
ife
ipv4 udp: drop skb extensions before marking skb stateless 2019-11-22 09:28:46 -08:00
ipv6 net-ipv6: IPV6_TRANSPARENT - check NET_RAW prior to NET_ADMIN 2019-11-21 19:15:20 -08:00
iucv
kcm
key
l2tp
l3mdev
lapb
llc
mac80211 mac80211: fix station inactive_time shortly after boot 2019-11-08 09:17:28 +01:00
mac802154
mpls
ncsi
netfilter Merge branch 'master' of git://blackhole.kfki.hu/nf 2019-11-04 20:59:00 +01:00
netlabel
netlink
netrom
nfc nfc: netlink: fix double device reference drop 2019-11-07 15:23:19 -08:00
nsh
openvswitch
packet
phonet
psample
qrtr
rds rds: ib: update WR sizes when bringing up connection 2019-11-16 12:59:08 -08:00
rfkill
rose
rxrpc rxrpc: Fix handling of last subpacket of jumbo packet 2019-10-31 12:23:09 -07:00
sched net/sched: act_pedit: fix WARN() in the traffic path 2019-11-19 18:57:16 -08:00
sctp inet: stop leaking jiffies on the wire 2019-11-01 14:57:52 -07:00
smc net/smc: fix fastopen for non-blocking connect() 2019-11-16 13:03:33 -08:00
strparser
sunrpc SUNRPC: Destroy the back channel when we destroy the host transport 2019-10-30 12:04:35 -04:00
switchdev
tipc tipc: add back tipc prefix to log messages 2019-11-14 18:03:03 -08:00
tls net/tls: enable sk_msg redirect to tls socket egress 2019-11-19 15:03:02 -08:00
unix
vmw_vsock vsock/virtio: fix sock refcnt holding during the shutdown 2019-11-08 12:17:50 -08:00
wimax
wireless nl80211: fix validation of mesh path nexthop 2019-10-30 10:11:18 +01:00
x25
xdp
xfrm xfrm: release device reference for invalid state 2019-11-12 08:24:38 +01:00
compat.c
Kconfig
Makefile
socket.c vfs: mark pipes and sockets as stream-like file descriptors 2019-11-25 09:12:11 -08:00
sysctl_net.c