Re: [PATCH] kernel: auditfilter: looping issue, memory leak if has2 or more AUDIT_FILTERKEYs

From: Chen Gang
Date: Thu Apr 11 2013 - 10:34:44 EST


On 2013å04æ11æ 21:40, Eric Paris wrote:
>> > can we add it in audit_free_rule ?
>> >
>> > maybe like this:
>> >
>> > @@ -75,6 +75,8 @@ static inline void audit_free_rule(struct audit_entry *e)
>> > /* some rules don't have associated watches */
>> > if (erule->watch)
>> > audit_put_watch(erule->watch);
>> > + if (erule->tree)
>> > + audit_put_tree(erule->tree);
>> > if (erule->fields)
>> > for (i = 0; i < erule->field_count; i++) {
>> > struct audit_field *f = &erule->fields[i];
> Where does the tree information get freed normally? That's the code you need to run down. You don't want to start getting double frees on the non-error case. I'll try to dig into it if Al doesn't. It's easy to show the leak on current kernels.
>

I think:
it is in function audit_del_rule. when del, also set NULL.
so the deletion in audit_free_rule is safe.
the process of erule->watch and erule->tree are similar.

please check, thanks.


> while(1)
> auditctl -a exit,always -w /etc -F auid=-1
>
>
>

it is valuable to me, thanks.



--
Chen Gang

Asianux Corporation
--
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/