mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
apparmor: share profile name on replacement
The profile names are the same, leverage this. Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
cf797c0e5e
commit
a1bd627b46
3 changed files with 72 additions and 9 deletions
|
@ -100,6 +100,36 @@ static inline bool path_mediated_fs(struct dentry *dentry)
|
|||
return !(dentry->d_sb->s_flags & MS_NOUSER);
|
||||
}
|
||||
|
||||
|
||||
struct counted_str {
|
||||
struct kref count;
|
||||
char name[];
|
||||
};
|
||||
|
||||
#define str_to_counted(str) \
|
||||
((struct counted_str *)(str - offsetof(struct counted_str, name)))
|
||||
|
||||
#define __counted /* atm just a notation */
|
||||
|
||||
void aa_str_kref(struct kref *kref);
|
||||
char *aa_str_alloc(int size, gfp_t gfp);
|
||||
|
||||
|
||||
static inline __counted char *aa_get_str(__counted char *str)
|
||||
{
|
||||
if (str)
|
||||
kref_get(&(str_to_counted(str)->count));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static inline void aa_put_str(__counted char *str)
|
||||
{
|
||||
if (str)
|
||||
kref_put(&str_to_counted(str)->count, aa_str_kref);
|
||||
}
|
||||
|
||||
|
||||
/* struct aa_policy - common part of both namespaces and profiles
|
||||
* @name: name of the object
|
||||
* @hname - The hierarchical name
|
||||
|
@ -108,7 +138,7 @@ static inline bool path_mediated_fs(struct dentry *dentry)
|
|||
*/
|
||||
struct aa_policy {
|
||||
const char *name;
|
||||
const char *hname;
|
||||
__counted char *hname;
|
||||
struct list_head list;
|
||||
struct list_head profiles;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue