Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2410239rwi; Fri, 28 Oct 2022 06:51:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM71gR9uXPlqZUW0fTZrgWuk03py5FOxlIocPl+t7rlN5ZLR0VnI75WcSrOsLUDiF6dIFWzt X-Received: by 2002:a05:6402:50d4:b0:461:e349:56b2 with SMTP id h20-20020a05640250d400b00461e34956b2mr23030084edb.17.1666965067105; Fri, 28 Oct 2022 06:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666965067; cv=none; d=google.com; s=arc-20160816; b=ADq1nsK02j4kE/xix/Q/uY2/R6GjwdnxkRTQoq3Ip3RLGMZww8ZbdUMLM6VTRs+Xep rESV2GVnGonlu8LSQJ5Y3aAjJXlYoB7nc8RK3QC2eNH7ywayFKrQS1AXrs+lLG8k8xAs qsAo340rxlM1mc1OUx/2gjV2rHxcMGX+ileomUvMw0HUoHjEYwisvdinjGU2i3Y+cB9b 1YHZDtC9YYuK4p98NxoxveAMS1e0kveh5wTQ3hi+cCrRP5y4GRjbs817vhd1FQ+AZKwc +SmtjCB1BZEo/yROXfmA8KWx6KoW+l4zKOUobcFQu8DjSbZTR2viSpOZcYxlETGDJ0eR Q3Nw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw1-20020a1709066a0100b007807e1ea26csi4930535ejc.637.2022.10.28.06.50.41; Fri, 28 Oct 2022 06:51:07 -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 + 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 ); 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 To: , , CC: , , 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; -- 2.17.1