From patchwork Wed Jul 13 12:40:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: weiyj_lk@163.com X-Patchwork-Id: 9227487 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 7E5826088F for ; Wed, 13 Jul 2016 12:41:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EE6526A4D for ; Wed, 13 Jul 2016 12:41:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 636B526E8A; Wed, 13 Jul 2016 12:41:57 +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, FREEMAIL_FROM, 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 6AB8726E64 for ; Wed, 13 Jul 2016 12:41:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750978AbcGMMlC (ORCPT ); Wed, 13 Jul 2016 08:41:02 -0400 Received: from m12-14.163.com ([220.181.12.14]:46929 "EHLO m12-14.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750923AbcGMMlB (ORCPT ); Wed, 13 Jul 2016 08:41:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=maKCu sy0QokDkejvyUBtP6GecB3C6vSV1/OS5AGByVE=; b=UBs9VmTY+35zlSr/+VnCM 9SKg6axKMt61BRAgja1ykt+s81alC4vx1zVeTfmJqWJjbwMwtuvbJEx4y7ZoY/Sy H/oNMUVAi+LdGuyoeYIA4rlT6Aufw235H7YG5BbzG8Zkdux6QOPXtLDyZKHzHatc MNmpaYTtV2MPl8e5eVAiOw= Received: from localhost.localdomain.localdomain (unknown [180.102.101.186]) by smtp10 (Coremail) with SMTP id DsCowAB3oqC9NoZXrKcFAg--.34819S2; Wed, 13 Jul 2016 20:40:31 +0800 (CST) From: weiyj_lk@163.com To: John Johansen , James Morris , "Serge E. Hallyn" Cc: Wei Yongjun , linux-security-module@vger.kernel.org Subject: [PATCH -next] apparmor: fix error return code in __aa_fs_profile_mkdir() Date: Wed, 13 Jul 2016 12:40:29 +0000 Message-Id: <1468413629-1980-1-git-send-email-weiyj_lk@163.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-CM-TRANSID: DsCowAB3oqC9NoZXrKcFAg--.34819S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7Wr4kAFy7Kr1kCFy7uFWkCrg_yoWDtFX_C3 y5J348Cw1j93Z3tr4jyFWSgr9ag340yrZYv34rtrnrXFyrKrs8JFsrGFykZFyrKws7Gr4D C3ZrXrZ3Z3W7XjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUnOJ57UUUUU== X-Originating-IP: [180.102.101.186] X-CM-SenderInfo: pzhl5yxbonqiywtou0bp/1tbiGR+l1lXlT2JMcgAAsW Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Wei Yongjun The error return code is set to PTR_ERR(dent) when malloc failed, 'dent' can be NULL here, this means the return value will be set to 0. Fix to return -ENOMEM in this error handling case. Signed-off-by: Wei Yongjun Acked-by: Serge Hallyn Acked-by: John Johansen --- security/apparmor/apparmorfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 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/apparmorfs.c b/security/apparmor/apparmorfs.c index 729e595..25479dc 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -424,8 +424,10 @@ int __aa_fs_profile_mkdir(struct aa_profile *profile, struct dentry *parent) id_len = snprintf(NULL, 0, ".%ld", profile->ns->uniq_id); profile->dirname = kmalloc(len + id_len + 1, GFP_KERNEL); - if (!profile->dirname) - goto fail; + if (!profile->dirname) { + error = -ENOMEM; + goto fail2; + } mangle_name(profile->base.name, profile->dirname); sprintf(profile->dirname + len, ".%ld", profile->ns->uniq_id++);