Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3408573rwa; Tue, 23 Aug 2022 04:24:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR7VhuWqVETY2stEgvCDcuiSparFzVVLiOnLZT3r3/jR5d6NzNxj45uAiCxCEvGkjLxrMpIk X-Received: by 2002:a63:ff24:0:b0:42a:20e7:99a5 with SMTP id k36-20020a63ff24000000b0042a20e799a5mr18414711pgi.261.1661253865308; Tue, 23 Aug 2022 04:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253865; cv=none; d=google.com; s=arc-20160816; b=qKI7NVikNYOTMVnhj57KLl5fkKyYC7KSOtmBKdcOoPoIGEF4XLny7HbDaLnlRavD+o tLCi4ywQ6AM92J1pgcmAdKbh1CwgApdy8Dwl1dTKvVI6vndYV59F/NbfIevV9jacMlXy gk8tm+w0m8pKyIWcCrLw31jCKBjGGrLk32qJ9P9Cv1iV8yYt7Z3r1z4LtzSC3OJex8/j dWdTp7aPPNVOewKgGSad3gAo6sNMkjiLEDl5wsC/Ksd2pqSn47bW5X3jqVtBOEGRekIH nH/OvVk1/cMspv/xCsF6XELBlHXz2GYRv7JwEyEJXk8he3B+cuXEd4bhu7aM6unuNGoI iPyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tNuDvg/qEb2zHP96pH904F0L/J5iBJzNa/Rkdz72KtQ=; b=hU0rkr0en2W4LzqBNIGjP91UdO9d5MIwzqQRADoX8QUUcMcPhu9VQYz5agoZvmJhhB 7jkM5/8obcOc33DxiMbuYRjCfd+sKznT1Xap3iSWL1f4T660gkqFSyVK/ICaKkuRINNR IF3AIuvWpC01xUJEHk0Zw0TKMwWtjr2gP5/I427EGrbIiHgvbZIxmAWPBB0fSE0Mr87a tjlNocYdDJWgAUI5eLWi+WD9dRS/USimCfc9u3aaf5xbMLPio03Nq2B4Q91OK4RZ7JHl +/4MZWxSg1Gui7FMr+bI+hnbOyvMF8Q7ATV2XjZpg8Fom8jrMYPfpbPtV0+CTvEZWWcz jb1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=irQ9YFMG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cp8-20020a056a00348800b005184183372csi14061629pfb.350.2022.08.23.04.24.14; Tue, 23 Aug 2022 04:24:25 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=irQ9YFMG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244163AbiHWKyn (ORCPT + 99 others); Tue, 23 Aug 2022 06:54:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356431AbiHWKrW (ORCPT ); Tue, 23 Aug 2022 06:47:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F02386B4E; Tue, 23 Aug 2022 02:11:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BC13C60DB4; Tue, 23 Aug 2022 09:11:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC3A3C433D6; Tue, 23 Aug 2022 09:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245910; bh=ABq+T4w3fzA7lwyjdCSsJMz1bpZ3rIbr9SCyC8Hlzt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=irQ9YFMGUBoZ2sCjyNbIXL+arOqxmHDPU0efhkLXqIgThKKDkdPDpsF+H0xBjU98G q8SJjCEMGVKy551d9quoOMrTDRpgv80hzd8/TI4pe5iBhhitqYK+AFQ1MT9Azg+E8A ta7+VMQ2nbhJkKDsRMPztlqvuz7Pra7W0vwic3Sw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiyu Yang , Xin Tan , Xin Xiong , John Johansen Subject: [PATCH 4.19 228/287] apparmor: fix reference count leak in aa_pivotroot() Date: Tue, 23 Aug 2022 10:26:37 +0200 Message-Id: <20220823080108.688336207@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Xin Xiong commit 11c3627ec6b56c1525013f336f41b79a983b4d46 upstream. The aa_pivotroot() function has a reference counting bug in a specific path. When aa_replace_current_label() returns on success, the function forgets to decrement the reference count of “target”, which is increased earlier by build_pivotroot(), causing a reference leak. Fix it by decreasing the refcount of “target” in that path. Fixes: 2ea3ffb7782a ("apparmor: add mount mediation") Co-developed-by: Xiyu Yang Signed-off-by: Xiyu Yang Co-developed-by: Xin Tan Signed-off-by: Xin Tan Signed-off-by: Xin Xiong Signed-off-by: John Johansen Signed-off-by: Greg Kroah-Hartman --- security/apparmor/mount.c | 1 + 1 file changed, 1 insertion(+) --- a/security/apparmor/mount.c +++ b/security/apparmor/mount.c @@ -686,6 +686,7 @@ int aa_pivotroot(struct aa_label *label, aa_put_label(target); goto out; } + aa_put_label(target); } else /* already audited error */ error = PTR_ERR(target);