*/
static int apparmor_sk_alloc_security(struct sock *sk, int family, gfp_t flags)
{
- /* allocated and cleared by LSM */
+ struct aa_sk_ctx *ctx;
+
+ ctx = kzalloc(sizeof(*ctx), flags);
+ if (!ctx)
+ return -ENOMEM;
+
+ SK_CTX(sk) = ctx;
return 0;
}
{
struct aa_sk_ctx *ctx = SK_CTX(sk);
+ SK_CTX(sk) = NULL;
aa_put_label(ctx->label);
- ctx->label = NULL;
aa_put_label(ctx->peer);
- ctx->peer = NULL;
path_put(&ctx->path);
- ctx->path.dentry = NULL;
- ctx->path.mnt = NULL;
+ kfree(ctx);
}
/**
struct lsm_blob_sizes apparmor_blob_sizes = {
.lbs_cred = sizeof(struct aa_task_ctx),
.lbs_file = sizeof(struct aa_file_ctx),
- .lbs_sock = sizeof(struct aa_sk_ctx),
};
static struct security_hook_list apparmor_hooks[] __lsm_ro_after_init = {