apparmor: split load data into management struct and data blob

Splitting the management struct from the actual data blob will allow
us in the future to do some sharing and other data reduction
techniques like replacing the the raw data with compressed data.

Prepare for this by separating the management struct from the data
blob.

Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
John Johansen 2018-02-03 20:08:28 +01:00
parent 98cf5bbff4
commit a6a52579e5
2 changed files with 11 additions and 4 deletions

View File

@ -70,7 +70,7 @@ struct aa_loaddata {
int abi; int abi;
unsigned char *hash; unsigned char *hash;
char data[]; char *data;
}; };
int aa_unpack(struct aa_loaddata *udata, struct list_head *lh, const char **ns); int aa_unpack(struct aa_loaddata *udata, struct list_head *lh, const char **ns);

View File

@ -164,8 +164,9 @@ static void do_loaddata_free(struct work_struct *work)
} }
kzfree(d->hash); kzfree(d->hash);
kfree(d->name); kzfree(d->name);
kvfree(d); kvfree(d->data);
kzfree(d);
} }
void aa_loaddata_kref(struct kref *kref) void aa_loaddata_kref(struct kref *kref)
@ -180,10 +181,16 @@ void aa_loaddata_kref(struct kref *kref)
struct aa_loaddata *aa_loaddata_alloc(size_t size) struct aa_loaddata *aa_loaddata_alloc(size_t size)
{ {
struct aa_loaddata *d = kvzalloc(sizeof(*d) + size, GFP_KERNEL); struct aa_loaddata *d;
d = kzalloc(sizeof(*d), GFP_KERNEL);
if (d == NULL) if (d == NULL)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
d->data = kvzalloc(size, GFP_KERNEL);
if (!d->data) {
kfree(d);
return ERR_PTR(-ENOMEM);
}
kref_init(&d->count); kref_init(&d->count);
INIT_LIST_HEAD(&d->list); INIT_LIST_HEAD(&d->list);