From patchwork Mon Jul 11 19:30:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 9224011 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F0CA860572 for ; Mon, 11 Jul 2016 19:30:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE95327DCE for ; Mon, 11 Jul 2016 19:30:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D33C927E5A; Mon, 11 Jul 2016 19:30:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7780F27DCE for ; Mon, 11 Jul 2016 19:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751191AbcGKTan (ORCPT ); Mon, 11 Jul 2016 15:30:43 -0400 Received: from nm49-vm3.bullet.mail.bf1.yahoo.com ([216.109.115.190]:59533 "EHLO nm49-vm3.bullet.mail.bf1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750967AbcGKTam (ORCPT ); Mon, 11 Jul 2016 15:30:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1468265441; bh=AhqIkBNYkjMiFok3E30nIyDr6OX8eybDbcOJz2UIZ5c=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From:Subject; b=W/pgQ9Kzvwplr1rEH0KSMnaLM2ej++6NF5Id5r4O86+7A+G5K775kZoDXoiqNBNWHIQ8p6QlJa6q64xIf641CcDGE3cGwDnmjgYXKzi7nJw3EvBhvv8RqT0Em6P0T48QLaiOY+f+EXVmTOZi4xOvAHvoX+1R7JZKyWcUQMcwSldQhowTIc5uY/HsK5OxS+Jdjdi6jg1gk2hfwLjkuuT9JRHn5OyIhZPXAj5m+rtEgHbWAyqAWoJb4aCycPcPgu5NXp+OQ0XntFEULNqkoHg5L6WFMMfDpQyHpvRYiq84fx3DJL/RZYGEWu7pGKHB30KxIC1okIpBLsU6BwNicetzqA== Received: from [98.139.215.140] by nm49.bullet.mail.bf1.yahoo.com with NNFMP; 11 Jul 2016 19:30:41 -0000 Received: from [98.139.213.13] by tm11.bullet.mail.bf1.yahoo.com with NNFMP; 11 Jul 2016 19:30:41 -0000 Received: from [127.0.0.1] by smtp113.mail.bf1.yahoo.com with NNFMP; 11 Jul 2016 19:30:41 -0000 X-Yahoo-Newman-Id: 286213.76277.bm@smtp113.mail.bf1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: BgW_UjIVM1lnHauXAE.KcWARGxvHQgkDJQZjzZoyr5Kdpyb wtFdRBbPSJSlKd4qvuAbe771IVWBr_HcD6zVf1Z3KxFzi0aYgrIvY2oXQNjN uWBWi.qyzRCte2CSBj3QIyM5fvFeGLSZ5C2Pf0ADYmtvaZ6vo3a0y8AmJPed 5V7kKDzip2dwXBVZS.TjKL.HAZSimjyWRuOCf83YSPOtVpPJa3oKxRt0prkn eA9o_VbFuRchQbukWBzjhzaeTzdGXU3FBENwOUPVbdUHrkBuO0pYvogtFTi4 mwSmVGOYzRY4C_NoTMeVCNmBbTzt0CaWlaErBTEVDC5RXCQfTziSYQWWWfSa g.R1Vo5lCTAFjaTSlLn8P8ltztDcqYclTFp4nb.GMXYoCWsuYCpuE6OvDdAm r3wDRiu6iSRcWrQGo5ZNgne0O.B5oJSQhylS4MzkcJY34zqcjbWb1W8Efdn5 t_7WRXpaOYEb_JElK.ne1sE.3mRm075aJVaupg5EbUF7SIgkRzCQewea2NEA W4XzjprtLWpPzQ8naRIQNsgJlKFrl0Iun9XUM3cV0motw5gbCcu4tBL0kVSl BMZZRpYdF6mXJ X-Yahoo-SMTP: OIJXglSswBDfgLtXluJ6wiAYv6_cnw-- Subject: [PATCH RFC 06/10] AppArmor: Abstract the file security blob To: LSM , James Morris References: Cc: John Johansen , Tetsuo Handa , Paul Moore , Stephen Smalley From: Casey Schaufler Message-ID: Date: Mon, 11 Jul 2016 12:30:36 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Subject: [PATCH RFC 06/10] AppArmor: Abstract the file security blob Abstract reading the file security blob. Remove abstraction when writing the file security blob. There is no change in the behavior of the code. Signed-off-by: Casey Schaufler --- security/apparmor/include/context.h | 6 ++++++ security/apparmor/lsm.c | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/security/apparmor/include/context.h b/security/apparmor/include/context.h index 07fb7a1..c140aad 100644 --- a/security/apparmor/include/context.h +++ b/security/apparmor/include/context.h @@ -24,6 +24,7 @@ #define cred_cxt(X) apparmor_cred(X) #define current_cxt() cred_cxt(current_cred()) +#define file_cxt(X) apparmor_file(X) /* struct aa_file_cxt - the AppArmor context the file was opened in * @perms: the permission the file was opened with @@ -91,6 +92,11 @@ static inline struct aa_task_cxt *apparmor_cred(const struct cred *cred) return cred->security; } +static inline struct aa_file_cxt *apparmor_file(const struct file *file) +{ + return file->f_security; +} + /** * aa_cred_profile - obtain cred's profiles * @cred: cred to obtain profiles from (NOT NULL) diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index 41a0290..1bd99fa 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -321,7 +321,7 @@ static int apparmor_inode_getattr(const struct path *path) static int apparmor_file_open(struct file *file, const struct cred *cred) { - struct aa_file_cxt *fcxt = file->f_security; + struct aa_file_cxt *fcxt = file_cxt(file); struct aa_profile *profile; int error = 0; @@ -364,14 +364,14 @@ static int apparmor_file_alloc_security(struct file *file) static void apparmor_file_free_security(struct file *file) { - struct aa_file_cxt *cxt = file->f_security; + struct aa_file_cxt *cxt = file_cxt(file); aa_free_file_context(cxt); } static int common_file_perm(int op, struct file *file, u32 mask) { - struct aa_file_cxt *fcxt = file->f_security; + struct aa_file_cxt *fcxt = file_cxt(file); struct aa_profile *profile, *fprofile = aa_cred_profile(file->f_cred); int error = 0; @@ -417,7 +417,7 @@ static int common_mmap(int op, struct file *file, unsigned long prot, { int mask = 0; - if (!file || !file->f_security) + if (!file || file_cxt(file) == NULL) return 0; if (prot & PROT_READ)