Message ID | 20221028123320.88132-1-xiujianfeng@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp805153wru; Fri, 28 Oct 2022 05:39:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5iY73MeKx8Y0u26NkIK+Qp1345JR3BHC0u6ZG1VBH6uh+XyTnkaskNLHoAxVTg6AB0KuUv X-Received: by 2002:a17:90b:1d8b:b0:20d:30a5:499e with SMTP id pf11-20020a17090b1d8b00b0020d30a5499emr16257603pjb.84.1666960758359; Fri, 28 Oct 2022 05:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666960758; cv=none; d=google.com; s=arc-20160816; b=bP84DwNLQw5gPR7fKP9kvKt+XXdFQyAdP736yZOakiSNgGN7oiH0Vhz6Ogwr/VQLtK U9oA7LQBVHGBXKpBWbj6hFHwkEvrPX+Sy5BLVFBqVwfPSllAJzbQEr3RLQPJBlbWQOnl tsLK3awtCz6/M13BoQk9WHrRVTeg0nbmYCrh/2V7/AqHC/7pBJP2DEGyriZQwZwKYha2 lLd614sMeXwwNarddgpiR/fmfFif/7x1XXVYBgJuh1uN0nlECoX1ikiaKe3Z/6zKH5YC W0fD2gL32ftbuEI9HG5M1pOMYuk4dp1NqgUREaFKtRkSp2d39hjGzQM9NS2ZnfrLkFcJ 8lDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=zh9tGPmgOIJRTa8V/HJda5Jdk4hEulljAzfjp7RP1gQ=; b=YPAloTnspdA9nH9wBD0S/lfJ3PgadNt/Oy32RTfywZCJ7DVcVCKZqp6FpbVq4OXNv8 xrRIQfoGqx4TwTWOz9/xUcXRTn4Tjfqpkgj9l+yqrRHWi75ePz7Ugxpw+vqTUlaqewPI FPA1ST2h1lEuizotgQ6Z08+HFyDQlMxG/E3hSUTokLO4N+pstLhJ6THsYr5Lpn+3coNE tyorgYXFP8dr5E8p/MPgfaiBZOoWXh/H/p4WpOtJUbgc1319efwTsxlArllswhjb50lo 3baqksTY+jDWt3Ss1IrR/6gKbOGl/ZREvGqtpe3bvBK/zSvYrB369fS+SIDFWp/W9BiF JUXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p9-20020a17090a930900b0021311a385c3si4896655pjo.46.2022.10.28.05.39.02; Fri, 28 Oct 2022 05:39:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229868AbiJ1Mgs (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Fri, 28 Oct 2022 08:36:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230128AbiJ1Mgp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 28 Oct 2022 08:36:45 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6C671CCCE2; Fri, 28 Oct 2022 05:36:42 -0700 (PDT) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MzMNx0GSwzmV75; Fri, 28 Oct 2022 20:31:45 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.58) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 28 Oct 2022 20:36:40 +0800 From: Xiu Jianfeng <xiujianfeng@huawei.com> To: <john.johansen@canonical.com>, <paul@paul-moore.com>, <serge@hallyn.com> CC: <apparmor@lists.ubuntu.com>, <linux-security-module@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH] apparmor: Fix memleak in alloc_ns() Date: Fri, 28 Oct 2022 20:33:20 +0800 Message-ID: <20221028123320.88132-1-xiujianfeng@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.58] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747935044534130014?= X-GMAIL-MSGID: =?utf-8?q?1747935044534130014?= |
Series |
apparmor: Fix memleak in alloc_ns()
|
|
Commit Message
Xiu Jianfeng
Oct. 28, 2022, 12:33 p.m. UTC
After changes in commit a1bd627b46d1 ("apparmor: share profile name on
replacement"), the hname member of struct aa_policy is not valid slab
object, but a subset of that, it can not be freed by kfree_sensitive(),
use aa_policy_destroy() to fix it.
Fixes: a1bd627b46d1 ("apparmor: share profile name on replacement")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
security/apparmor/policy_ns.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 10/28/22 05:33, Xiu Jianfeng wrote: > After changes in commit a1bd627b46d1 ("apparmor: share profile name on > replacement"), the hname member of struct aa_policy is not valid slab > object, but a subset of that, it can not be freed by kfree_sensitive(), > use aa_policy_destroy() to fix it. > > Fixes: a1bd627b46d1 ("apparmor: share profile name on replacement") > Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> Acked-by: John Johansen <john.johansen@canonical.com> I have pulled this into my tree > --- > security/apparmor/policy_ns.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/security/apparmor/policy_ns.c b/security/apparmor/policy_ns.c > index 5c38563a6dcf..fd5b7afbcb48 100644 > --- a/security/apparmor/policy_ns.c > +++ b/security/apparmor/policy_ns.c > @@ -132,7 +132,7 @@ static struct aa_ns *alloc_ns(const char *prefix, const char *name) > return ns; > > fail_unconfined: > - kfree_sensitive(ns->base.hname); > + aa_policy_destroy(&ns->base); > fail_ns: > kfree_sensitive(ns); > return NULL;
diff --git a/security/apparmor/policy_ns.c b/security/apparmor/policy_ns.c index 5c38563a6dcf..fd5b7afbcb48 100644 --- a/security/apparmor/policy_ns.c +++ b/security/apparmor/policy_ns.c @@ -132,7 +132,7 @@ static struct aa_ns *alloc_ns(const char *prefix, const char *name) return ns; fail_unconfined: - kfree_sensitive(ns->base.hname); + aa_policy_destroy(&ns->base); fail_ns: kfree_sensitive(ns); return NULL;