From patchwork Tue Mar 30 17:33:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Johansen X-Patchwork-Id: 48995 X-Patchwork-Delegate: apw@canonical.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 4FA63B7C67 for ; Wed, 31 Mar 2010 04:33:50 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1NwfJx-0005o9-Mk; Tue, 30 Mar 2010 18:33:45 +0100 Received: from adelie.canonical.com ([91.189.90.139]) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1NwfJw-0005o4-2a for kernel-team@lists.ubuntu.com; Tue, 30 Mar 2010 18:33:44 +0100 Received: from hutte.canonical.com ([91.189.90.181]) by adelie.canonical.com with esmtp (Exim 4.69 #1 (Debian)) id 1NwfJw-00008V-0c for ; Tue, 30 Mar 2010 18:33:44 +0100 Received: from [96.225.230.137] (helo=canonical.com) by hutte.canonical.com with esmtpsa (TLS-1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1NwfJv-0004Y2-Kd for kernel-team@lists.ubuntu.com; Tue, 30 Mar 2010 18:33:43 +0100 From: john.johansen@canonical.com To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/3] UBUNTU: SAUCE: AppArmor: Return string len rather than the allocation size Date: Tue, 30 Mar 2010 10:33:40 -0700 Message-Id: <1269970421-24271-2-git-send-email-john.johansen@canonical.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1269970421-24271-1-git-send-email-john.johansen@canonical.com> References: <1269970421-24271-1-git-send-email-john.johansen@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: John Johansen Buglink: http://launchpad.net/bugs/551844 AppArmor getprocattr was returning the wrong size for name for unconfined tasks. It returned the size of memory allocated - 1 (\0 is omitted) instead of the size of the string. In the case of unconfined tasks the mode string is not output so the return size needs to be adjusted appropriately. Signed-off-by: Kees Cook Signed-off-by: John Johansen --- security/apparmor/procattr.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) --- security/apparmor/procattr.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/security/apparmor/procattr.c b/security/apparmor/procattr.c index 4991f9d..c31f693 100644 --- a/security/apparmor/procattr.c +++ b/security/apparmor/procattr.c @@ -51,9 +51,11 @@ int aa_getprocattr(struct aa_profile *profile, char **string) sprintf(s, "%s://", ns->base.name); s += ns_len; } - if (profile->flags & PFLAG_UNCONFINED) + if (profile->flags & PFLAG_UNCONFINED) { sprintf(s, "%s\n", profile->base.hname); - else + /* mode string not being appended so reduce string size */ + len -= mode_len; + } else sprintf(s, "%s (%s)\n", profile->base.hname, mode_str); *string = str;