Skip to content

Commit 035bfd0

Browse files
Christoph Hellwigdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a3ad434 commit 035bfd0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/linux/sockptr.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ static inline int __must_check init_user_sockptr(sockptr_t *sp, void __user *p)
6464

6565
static inline bool sockptr_is_null(sockptr_t sockptr)
6666
{
67-
return !sockptr.user && !sockptr.kernel;
67+
if (sockptr_is_kernel(sockptr))
68+
return !sockptr.kernel;
69+
return !sockptr.user;
6870
}
6971

7072
static inline int copy_from_sockptr(void *dst, sockptr_t src, size_t size)

0 commit comments

Comments
 (0)