lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240825152440.93054-1-kerneljasonxing@gmail.com>
Date: Sun, 25 Aug 2024 23:24:38 +0800
From: Jason Xing <kerneljasonxing@...il.com>
To: davem@...emloft.net,
	edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com,
	dsahern@...nel.org,
	willemb@...gle.com
Cc: netdev@...r.kernel.org,
	Jason Xing <kernelxing@...cent.com>
Subject: [PATCH net-next 0/2] timestamp: control SOF_TIMESTAMPING_RX_SOFTWARE feature per socket

From: Jason Xing <kernelxing@...cent.com>

Prior to this series, when one socket is set SOF_TIMESTAMPING_RX_SOFTWARE
which measn the whole system turns on this button, other sockets that only
have SOF_TIMESTAMPING_SOFTWARE will be affected and then print the rx
timestamp information even without SOF_TIMESTAMPING_RX_SOFTWARE flag.
In such a case, the rxtimestamp.c selftest surely fails, please see
testcase 6.

In a normal case, if we only set SOF_TIMESTAMPING_SOFTWARE flag, we
can't get the rx timestamp because there is no path leading to turn on
netstamp_needed_key button in net_enable_timestamp(). That is to say, if
the user only sets SOF_TIMESTAMPING_SOFTWARE, we don't expect we are
able to fetch the timestamp from the skb.

More than this, we can find there are some other ways to turn on
netstamp_needed_key, which will happenly allow users to get tstamp in
the receive path. Please see net_enable_timestamp().

How to solve it?
setsockopt interface is used to control each socket separately but in
this case it is affected by other sockets. For timestamp itself, it's
not feasible to convert netstamp_needed_key into a per-socket button
because when the receive stack just handling the skb from driver doesn't
know which socket the skb belongs to. So we have to test the exact
timestamping flag when the users do recvmsg: if we set both of flags, it
means we want the timestamp; if not, it means we don't expect to see the
timestamp even the skb carries.

As we can see, this patch makes the SOF_TIMESTAMPING_RX_SOFTWARE under
setsockopt control. And it's a per-socket fine-grained now.


Jason Xing (2):
  tcp: make SOF_TIMESTAMPING_RX_SOFTWARE feature per socket
  net: make SOF_TIMESTAMPING_RX_SOFTWARE feature per socket

 include/net/sock.h       | 11 ++++++-----
 net/bluetooth/hci_sock.c |  4 ++--
 net/core/sock.c          |  2 +-
 net/ipv4/ip_sockglue.c   |  2 +-
 net/ipv4/ping.c          |  2 +-
 net/ipv4/tcp.c           | 10 ++++++++--
 net/ipv6/datagram.c      |  4 ++--
 net/l2tp/l2tp_ip.c       |  2 +-
 net/l2tp/l2tp_ip6.c      |  2 +-
 net/nfc/llcp_sock.c      |  2 +-
 net/rxrpc/recvmsg.c      |  2 +-
 net/socket.c             |  7 ++++---
 net/unix/af_unix.c       |  2 +-
 13 files changed, 30 insertions(+), 22 deletions(-)

-- 
2.37.3


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ