archive mirror
 help / color / mirror / Atom feed
* Re: [Clarification] writes to kernel addresses that came from userspace
       [not found] <20210912162030.GA4692@titan>
@ 2021-09-12 18:47 ` Kees Cook
  0 siblings, 0 replies; only message in thread
From: Kees Cook @ 2021-09-12 18:47 UTC (permalink / raw)
  To: Len Baker; +Cc: kernelnewbies, linux-hardening

On Sun, Sep 12, 2021 at 06:20:30PM +0200, Len Baker wrote:
> I am taking a look to the issues in the Kernel Self Protection Project [1]
> and this one [2] (perform taint-tracking of writes to kernel addresses
> that came from userspace) take my attention. Reading the explanation does
> not make it clear to me where the flaw is.
> [extracted from the KSPP]
> It should be possible to perform taint tracking of addresses in the kernel
> to avoid flaws of the form:
> copy_from_user(object, src, ...);
> ...
> memcpy(object.address, something, ...);
> [end of extracted]
> My question is: Why is this scenario a flaw?

I likely didn't give enough context in the Issue tracker. It's not a
flaw on its own, but rather an example of an attack situation if a flaw
were present (e.g. having no sanity-check on "object.address" above).

> If I understand correctly, the copy_from_user() function copies n bytes of
> src (in user space address) to object (in kernel space address). I think
> that it is the correct way to act. Then, in kernel space the object is
> modified. So, I don't see the problem. Sorry if it is a trivial question
> but I can not figure it out on my own.

The trouble is that the address came from userspace and (in this
example) has no validation, etc.

This Issue is about developing methods to perform "taint tracking"
within the kernel to better catch cases where validation is missing.
There is some limited support for this via the "__user" annotation and
the "address spaces" checks that "sparse" does, but that's been rather
limited in scope. Having something more like smatch doing function-graph
analysis would be nice for static analysis, and even better would be
stuff like DataFlowSanitizer[1], which can do this at runtime.

Hopefully that makes things more clear! I'll go update the issue
tracker. :)



> [1]
> [2]

Kees Cook

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-12 18:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210912162030.GA4692@titan>
2021-09-12 18:47 ` [Clarification] writes to kernel addresses that came from userspace Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).