Re: Lightweight type analysis for memory safety through verificationof API uses

From: Marcelo Sousa
Date: Tue Sep 24 2013 - 06:33:27 EST


Dear Andi,

Thanks for the reply.

On Tue, Sep 24, 2013 at 5:11 AM, Andi Kleen <andi@xxxxxxxxxxxxxx> wrote:
> Marcelo Sousa <marceloabsousa@xxxxxxxxx> writes:
>
>> I've designed and implemented a tool similar to sparse and CQUAL that
>> does type inference of user specified type qualifiers, e.g. iomem. It
>> receives an API specification with the type qualifiers and also a
>> partial order, e.g. IOAddr is not compatible with KernelAddr and
>> ioremap returns a pointer to IOAddr while __kmalloc returns a pointer
>> to a KernelAddr.
>
> Tracking iomem is ultimatively not very interesting, as in many common
> architectures it's just a normal pointer.

My motivation for tracking iomem was the fact that cmpxchg in x86 had
the side effect of always writing to the memory pointer even if the
comparison fails. Since the iomem pointer could be pointing to a
non-readable location performing a cmpxchg would always result in
memory corruption.

>
> __user is much more interesting, as that is real security bugs.
> You can probably find some in standard security advisories.

Yes, there has been research on user vs kernel pointer separation, and
I'm focusing on that at the moment. However, I can't really find any
recent bugs on this topic. If you can provide pointers that would be
great.

>
> Really interesting would be static lock set tracking for pointers
> and similar.

Is this to track that lock/unlock is correctly modelled (no double
lock, no unlock before lock, deadlock) or do you have a specific goal
in mind? Again, if you know of any existing bugs or a particular
pattern that you are interested in verifying that would be great.

Kind regards,
Marcelo

>
> -Andi
>
> --
> ak@xxxxxxxxxxxxxxx -- Speaking for myself only
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/