Re: [RFC PATCH 3/7] arm64: add check for comparison against tagged address
Dan Carpenter <[email protected]>
| Newsgroups | org.kernel.vger.smatch |
|---|---|
| Message-ID | <20191205142842.GP1787@kadam> |
On Thu, Dec 05, 2019 at 04:27:03PM +0300, Dan Carpenter wrote:
> > We hardcode symbols of interest that we consider to be untagged addresses. This
> > provides good coverage but isn't very flexible. A better approach would be to
> > annotate the kernel with address space tags, such as is the case for __user,
> > __percpu, etc. Thus variables, struct members and function parameters could be
> > annotated to indicate that they contain untagged addresses. Unfortunately:
> >
> > - At present it's not possible to determine a struct member's address space
> > from Smatch
>
> I'm not sure how to get the address space for anything not just struct
> members. :( I will investigate.
I was using the wrong attribute in my testing. In the kernel __user is
#define __user __attribute__((noderef, address_space(1)))
Just get_type() should work:
arg = get_argument_from_call_expr(expr->args, 0);
if (!arg)
return;
type = get_type(arg);
if (!type || !type->ctype.as)
return;
sm_msg("%s: expr = '%s' address space = %s", __func__, expr_to_str(expr), type->ctype.as->name);
The output looks like:
test.c:23 main() check_namespace: expr = 'frob(f->p)' address space = <asn:1>
regards,
dan carpenter