Blob Blame History Raw
From: Christoph Hellwig <hch@lst.de>
Date: Tue, 28 Jul 2020 18:38:34 +0200
Subject: net: make sockptr_is_null strict aliasing safe
Patch-mainline: v5.9-rc1
Git-commit: 035bfd051eae5b365368be915dfaf916aa501a52
References: bsc#1177028

While the kernel in general is not strict aliasing safe we can trivially
do that in sockptr_is_null without affecting code generation, so always
check the actually assigned union member.

Reported-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Gary Lin <glin@suse.com>
---
 include/linux/sockptr.h |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/include/linux/sockptr.h
+++ b/include/linux/sockptr.h
@@ -36,7 +36,9 @@ static inline sockptr_t USER_SOCKPTR(voi
 
 static inline bool sockptr_is_null(sockptr_t sockptr)
 {
-	return !sockptr.user && !sockptr.kernel;
+	if (sockptr_is_kernel(sockptr))
+		return !sockptr.kernel;
+	return !sockptr.user;
 }
 
 static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size)