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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230703175048.151683-2-jthinz@mailbox.tu-berlin.de>
Date: Mon, 3 Jul 2023 19:50:45 +0200
From: Jörn-Thorben Hinz <jthinz@...lbox.tu-berlin.de>
To: <bpf@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<netdev@...r.kernel.org>, <linux-kselftest@...r.kernel.org>
CC: Jörn-Thorben Hinz <jthinz@...lbox.tu-berlin.de>, Alexei
 Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>, Andrii
 Nakryiko <andrii@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>, "David
 S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub
 Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, Shuah Khan
	<shuah@...nel.org>, Willem de Bruijn <willemb@...gle.com>, Deepa Dinamani
	<deepa.kernel@...il.com>
Subject: [PATCH 1/2] net: Implement missing getsockopt(SO_TIMESTAMPING_NEW)

Commit 9718475e6908 ("socket: Add SO_TIMESTAMPING_NEW") added the new
socket option SO_TIMESTAMPING_NEW. Setting the option is handled in
sk_setsockopt(), querying it was not handled in sk_getsockopt(), though.

For consistency, implement the missing getsockopt(SO_TIMESTAMPING_NEW).
Similar as with SO_TIMESTAMP_{OLD,NEW}, the active timestamping flags
are only returned when querying the same SO_TIMESTAMPING_{OLD,NEW}
option they were set for. Empty flags are returned with
SO_TIMESTAMPING_{NEW,OLD} otherwise.

Fixes: 9718475e6908 ("socket: Add SO_TIMESTAMPING_NEW")
Signed-off-by: Jörn-Thorben Hinz <jthinz@...lbox.tu-berlin.de>
---
 net/core/sock.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index 9370fd50aa2c..cfb48244ed12 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1710,9 +1710,14 @@ int sk_getsockopt(struct sock *sk, int level, int optname,
 		break;
 
 	case SO_TIMESTAMPING_OLD:
+	case SO_TIMESTAMPING_NEW:
 		lv = sizeof(v.timestamping);
-		v.timestamping.flags = sk->sk_tsflags;
-		v.timestamping.bind_phc = sk->sk_bind_phc;
+		if (optname == (sock_flag(sk, SOCK_TSTAMP_NEW) ?
+					SO_TIMESTAMPING_NEW :
+					SO_TIMESTAMPING_OLD)) {
+			v.timestamping.flags = sk->sk_tsflags;
+			v.timestamping.bind_phc = sk->sk_bind_phc;
+		}
 		break;
 
 	case SO_RCVTIMEO_OLD:
-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ