Skip to content

Commit

Permalink
net: make sockptr_is_null strict aliasing safe
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christoph Hellwig authored and David S. Miller committed Jul 28, 2020
1 parent a3ad434 commit 035bfd0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/linux/sockptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 035bfd0

Please sign in to comment.