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]
Date: Tue, 20 Feb 2024 15:01:39 +0800
From: "D. Wythe" <alibuda@...ux.alibaba.com>
To: kgraul@...ux.ibm.com,
	wenjia@...ux.ibm.com,
	jaka@...ux.ibm.com,
	wintera@...ux.ibm.com,
	guwen@...ux.alibaba.com
Cc: kuba@...nel.org,
	davem@...emloft.net,
	netdev@...r.kernel.org,
	linux-s390@...r.kernel.org,
	linux-rdma@...r.kernel.org,
	tonylu@...ux.alibaba.com,
	pabeni@...hat.com,
	edumazet@...gle.com
Subject: [RFC net-next 14/20] net/smc: allow to access the state of inet smc sock

From: "D. Wythe" <alibuda@...ux.alibaba.com>

As we know, in inet version of smc, smc_sock and tcp_sock coexist,
this will result in the sk_state field has been accessed and modified by
both protocols, which can cause obvious exceptions. Therefore, this
patch modify the state macro for reading and setting the smc state,
using the icsk field to determine which is the very field needed to
be accessed or changed.

Signed-off-by: D. Wythe <alibuda@...ux.alibaba.com>
---
 net/smc/smc.h | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/net/smc/smc.h b/net/smc/smc.h
index 932d61f..e54a30c 100644
--- a/net/smc/smc.h
+++ b/net/smc/smc.h
@@ -38,9 +38,6 @@
 #define KERNEL_HAS_ATOMIC64
 #endif
 
-#define smc_sk_state(sk)		((sk)->sk_state)
-#define smc_sk_set_state(sk, state)	(smc_sk_state(sk) = (state))
-
 enum smc_state {		/* possible states of an SMC socket */
 	SMC_ACTIVE	= 1,
 	SMC_INIT	= 2,
@@ -254,6 +251,7 @@ struct smc_sock {				/* smc sock container */
 		struct sock sk;
 	};
 	struct socket		*clcsock;	/* internal tcp socket */
+	unsigned char		smc_state;	/* smc state used in smc via inet_sk */
 	void			(*clcsk_state_change)(struct sock *sk);
 						/* original stat_change fct. */
 	void			(*clcsk_data_ready)(struct sock *sk);
@@ -397,6 +395,20 @@ static __always_inline bool smc_sock_is_inet_sock(const struct sock *sk)
 	return inet_test_bit(IS_ICSK, sk);
 }
 
+#define smc_sk_state(sk)	({				\
+	struct sock *__sk = (sk);				\
+	smc_sock_is_inet_sock(__sk) ?				\
+		smc_sk(__sk)->smc_state : (__sk)->sk_state;	\
+})
+
+static __always_inline void smc_sk_set_state(struct sock *sk, unsigned char state)
+{
+	if (smc_sock_is_inet_sock(sk))
+		smc_sk(sk)->smc_state = state;
+	else
+		sk->sk_state = state;
+}
+
 #define smc_sock_flag(sk, flag)	sock_flag(sk, flag)
 
 #endif	/* __SMC_H */
-- 
1.8.3.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ