On Thu, Nov 01, 2012 at 10:29:19AM -0400, Mimi Zohar wrote: > On Thu, 2012-11-01 at 09:53 -0400, Vivek Goyal wrote: > > On Thu, Nov 01, 2012 at 09:10:03AM -0400, Vivek Goyal wrote: > > > > [..] > > > > > > > > > - So say we can sign /sbin/kexec at build time and distros can do that. > > > > > - Verify the signature at exec time using kernel keyring and if > > > > > verification happens successfully, say process gains extra capability. > > > > > - Use this new capability to determine whether kexec_load() will be > > > > > successful or not. > > > > > > > > > > Even if we can do all this, it still has the issue of being able to > > > > > stop the process in user space and replace the code at run time > > > > > and be able to launch unsigned kernel. > > > > > > Thinking more about it. Can we just keep track whether a process was > > > ptraced or not and disallow kexec_load() syscall if it was ptraced. > > > (I am assuming that ptrace is the only way to change process code/data). > > > > > > So binaries can be signed offline. Signature verification can take place > > > using kernel keyring at exec() time. And we can keep track of ptraced > > > processes and disallow calling kexec_load() for such processes. If this > > > is implementable, this should take care of following requirement raised > > > by matthew. > > > > > > ************************************************************************ > > > It must be impossible for the kernel to launch any /sbin/kexec that hasn't > > > been signed by a trusted key that's been built into the kernel, and it > > > must be impossible for anything other than /sbin/kexec to make the kexec > > > system call. > > > ************************************************************************* > > > > > > Thoughts? > > > > Eric responded but my mistake he responded to only me. So I will quickly > > put his idea here. > > > > [start quote] > > > > You can't ptrace a process that has a capability you don't. > > > > That should be enforced in security/commoncap/ > > > > [end quote] > > > > This looks like a good idea. Upon verification signed binaries will be > > assigned special capability and then no unsigned binary should be able > > to ptrace signed/verified processes > > That's a good generic solution, which I'm all in favor of, but it > doesn't resolve the latter half of Matthrew's requirement "and it must > be impossible for anything other than /sbin/kexec to make the kexec > system call." Only those executables which have extended capability (say CAP_SIGNATURES_VERIFIED) will be able to call kexec_load() syscall. Only signed executables will get this capability upon signature verification (using keys in kernel keyring only). so any xyz executable will not be able to call kexec_load() until and unless it is signed with keys kernel trusts. This is similar to signed module verification. So I think this does satisfy the requirement matthew specified. Isn't it? Matthew, what do you think? Thanks Vivek