SO_PEERSEC protections in sk_getsockopt()?
Paul Moore
paul at paul-moore.com
Mon Oct 10 13:19:28 UTC 2022
On Mon, Oct 10, 2022 at 8:54 AM David Laight <David.Laight at aculab.com> wrote:
> From: Alexei Starovoitov
> > Sent: 07 October 2022 22:55
> ....
> > Not easy at all.
> > There is only way place in the whole kernel that does:
> > return sk_getsockopt(sk, SOL_SOCKET, optname,
> > KERNEL_SOCKPTR(optval),
> > KERNEL_SOCKPTR(optlen));
>
> Until I add change my out of tree driver to work with
> the new code.
> (Although it actually needs to do a getsockopt into SCTP.)
>
> I didn't spot the change to sk_getsockopt() going though.
> But KERNEL_SOCKPTR() is really the wrong function/type
> for the length.
> It would be much safer to have a struct with two members,
> one an __user pointer and one a kernel pointer both to
> socklen_t.
Yes, agreed.
> It isn't really ideal for the buffer pointer either.
> That started as a single field (assuming the caller
> has verified the user/kernel status), then the is_kernel
> field was added for architectures where user/kernel
> addresses use the same values.
> Then a horrid bug (forgotten where) forced the is_kernel
> field be used everywhere.
> Again a structure with two pointers would be much safer.
Any chance you have plans to work on this David?
--
paul-moore.com
More information about the Linux-security-module-archive
mailing list