summaryrefslogtreecommitdiff
path: root/include/linux/sockptr.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-07-28 19:38:34 +0300
committerDavid S. Miller <davem@davemloft.net>2020-07-28 23:43:40 +0300
commit035bfd051eae5b365368be915dfaf916aa501a52 (patch)
treeb943278a8688f27ae44d0e6e18d6fcde385afaa9 /include/linux/sockptr.h
parenta3ad434ad782085670d74e1a35c4c3f6043749f0 (diff)
downloadlinux-035bfd051eae5b365368be915dfaf916aa501a52.tar.xz
net: make sockptr_is_null strict aliasing safe
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>
Diffstat (limited to 'include/linux/sockptr.h')
-rw-r--r--include/linux/sockptr.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h
index 7d5cdb2b30b5..b13ea1422f93 100644
--- a/include/linux/sockptr.h
+++ b/include/linux/sockptr.h
@@ -64,7 +64,9 @@ static inline int __must_check init_user_sockptr(sockptr_t *sp, void __user *p)
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)