netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: Shrink sock.sk_err sk_err_soft to u16 from int
@ 2022-07-03 20:06 Leonard Crestez
  2022-07-05 10:31 ` Paolo Abeni
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Leonard Crestez @ 2022-07-03 20:06 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski
  Cc: Paolo Abeni, Soheil Hassas Yeganeh, Wei Wang, Joanne Koong,
	netdev, linux-kernel

These fields hold positive errno values which are limited by
ERRNO_MAX=4095 so 16 bits is more than enough.

They are also always positive; setting them to a negative errno value
can result in falsely reporting a successful read/write of incorrect
size.

Signed-off-by: Leonard Crestez <cdleonard@gmail.com>
---
 include/net/sock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I ran some relatively complex tests without noticing issues but some corner
case where this breaks might exist.

diff --git a/include/net/sock.h b/include/net/sock.h
index 0dd43c3df49b..acd85d1702d9 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -480,11 +480,11 @@ struct sock {
 	u16			sk_protocol;
 	u16			sk_gso_max_segs;
 	unsigned long	        sk_lingertime;
 	struct proto		*sk_prot_creator;
 	rwlock_t		sk_callback_lock;
-	int			sk_err,
+	u16			sk_err,
 				sk_err_soft;
 	u32			sk_ack_backlog;
 	u32			sk_max_ack_backlog;
 	kuid_t			sk_uid;
 	u8			sk_txrehash;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-07-06 14:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-03 20:06 [PATCH] net: Shrink sock.sk_err sk_err_soft to u16 from int Leonard Crestez
2022-07-05 10:31 ` Paolo Abeni
2022-07-05 13:01   ` Leonard Crestez
2022-07-05 22:26     ` Soheil Hassas Yeganeh
2022-07-05 19:06 ` Jakub Kicinski
2022-07-06 14:04 ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).