variable declarer?
Hi,
I can't figure out how to match a declarer in a struct definition. For example:
struct foo {
int bar;
DECLARE_FLEX_ARRAY(u8, array);
};using:
declarer name DECLARE_FLEX_ARRAY;
doesn't work, without it, I get errors at "u8" since, I assume, it's not expecting parens. :)
The full script I'm trying to use is a variation on the prior one:
// Options: --include-headers
@allocated@
identifier STRUCT, ARRAY, COUNTER, CALC;
expression COUNT;
struct STRUCT *PTR;
identifier ALLOC =~ "(devm_)?[kv][cvzm]alloc";
@@
(
CALC = struct_size(PTR, ARRAY, COUNT);
...
PTR = ALLOC(..., CALC, ...);
|
PTR = ALLOC(..., struct_size(PTR, ARRAY, COUNT), ...);
)
...
PTR->COUNTER = COUNT;@annotate@
type COUNTER_TYPE, ARRAY_TYPE;
identifier allocated.STRUCT;
identifier allocated.ARRAY;
identifier allocated.COUNTER;
attribute name __counted_by;
declarer name DECLARE_FLEX_ARRAY;
@@
struct STRUCT {
...
COUNTER_TYPE COUNTER;
...
DECLARE_FLEX_ARRAY(ARRAY_TYPE, ARRAY)
+ __counted_by(COUNTER)
;};
Thanks!
-Kees
Signature · 1 line
Kees Cook
Quoted 48 lines · Kees Cook
Hi,
I can't figure out how to match a declarer in a struct definition. For example:
struct foo { int bar; DECLARE_FLEX_ARRAY(u8, array); };using:
declarer name
DECLARE_FLEX_ARRAY;doesn't work, without it, I get errors at "u8" since, I assume, it's not expecting parens. :)
The full script I'm trying to use is a variation on the prior one:
// Options: --include-headers
@allocated@
identifier STRUCT, ARRAY, COUNTER, CALC;
expression COUNT;
struct STRUCT *PTR;
identifier ALLOC =~ "(devm_)?[kv][cvzm]alloc";
@@(
CALC = struct_size(PTR, ARRAY, COUNT); ... PTR = ALLOC(..., CALC, ...); | PTR = ALLOC(..., struct_size(PTR, ARRAY, COUNT), ...); ) ... PTR->COUNTER = COUNT;@annotate@
typeCOUNTER_TYPE,ARRAY_TYPE;
identifier allocated.STRUCT;
identifier allocated.ARRAY;
identifier allocated.COUNTER;
attribute name__counted_by;
declarer nameDECLARE_FLEX_ARRAY;
@@
Quoted 8 lines
struct STRUCT { ... COUNTER_TYPE COUNTER; ... DECLARE_FLEX_ARRAY(ARRAY_TYPE, ARRAY) + __counted_by(COUNTER) ;};
Should be working now.
julia