Linux Security Modules development
 help / color / mirror / Atom feed
* SO_PEERSEC protections in sk_getsockopt()?
@ 2022-10-05 20:44 Paul Moore
  2022-10-07 17:43 ` Paul Moore
  0 siblings, 1 reply; 14+ messages in thread
From: Paul Moore @ 2022-10-05 20:44 UTC (permalink / raw)
  To: Martin KaFai Lau
  Cc: Alexei Starovoitov, netdev, linux-security-module, selinux

Hi Martin,

In commit 4ff09db1b79b ("bpf: net: Change sk_getsockopt() to take the
sockptr_t argument") I see you wrapped the getsockopt value/len
pointers with sockptr_t and in the SO_PEERSEC case you pass the
sockptr_t:user field to avoid having to update the LSM hook and
implementations.  I think that's fine, especially as you note that
eBPF does not support fetching the SO_PEERSEC information, but I think
it would be good to harden this case to prevent someone from calling
sk_getsockopt(SO_PEERSEC) with kernel pointers.  What do you think of
something like this?

  static int sk_getsockopt(...)
  {
    /* ... */
    case SO_PEERSEC:
      if (optval.is_kernel || optlen.is_kernel)
        return -EINVAL;
      return security_socket_getpeersec_stream(...);
    /* ... */
  }

-- 
paul-moore.com

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

end of thread, other threads:[~2022-10-10 15:56 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-05 20:44 SO_PEERSEC protections in sk_getsockopt()? Paul Moore
2022-10-07 17:43 ` Paul Moore
2022-10-07 19:12   ` Alexei Starovoitov
2022-10-07 20:06     ` Paul Moore
2022-10-07 21:55       ` Alexei Starovoitov
2022-10-09 22:01         ` Paul Moore
2022-10-10  6:19           ` Alexei Starovoitov
2022-10-10 13:28             ` Paul Moore
2022-10-10 14:10               ` Alexei Starovoitov
2022-10-10 15:50                 ` Paul Moore
2022-10-10 12:54         ` David Laight
2022-10-10 13:19           ` Paul Moore
2022-10-10 15:34             ` David Laight
2022-10-10 15:56               ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox