Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3414397rwa; Tue, 23 Aug 2022 04:30:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR5OHARInRKhTTlTBlfSuHcxjv7uQ26zgw/Nb4tLAlEpwyCmKQhjA4v8lVCCj1rNW02+zJsr X-Received: by 2002:a05:6402:2549:b0:447:1cd7:7537 with SMTP id l9-20020a056402254900b004471cd77537mr2276010edb.422.1661254235366; Tue, 23 Aug 2022 04:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254235; cv=none; d=google.com; s=arc-20160816; b=rsOA625Fe7D62Pub4mbOsALkPlCydl5VQHwhXXREQHuzs8pGre6q2NMCAHCjSQ9P9D JG4tk+keb1xG1Kfalo1ogMOimL9mSeRb1NMtQC4RRyYLZfD23yF6uUd04LCzk/KQ88dj ANLMeFg0vW3RdpuTvSRuJ2nZSgPADe2AluYBCEoeXJn5jWpgZ8CR/G/A+99GpSYA4RYg cu+CeAesDLlpkuAiP9Vb14krMpgXVlOnsuQViXy4nPFm8bqE3vHnSvpalgfb7LnuH6WN xbVpCdys1pZEdZHhIH/jJwCg0lxkz9X/c5KBqbtsusIaN/iyBYTQEqYyKxUDTQSEOvvQ q0tQ== 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=BbLCLyCS7H8y8vY6MS1EvHC/9i/do1ifC/liN0T1gss=; b=B02Y8CqMyT0Rr1FPbeFT8fuFfG1TDUZRjeqOGbMaiNowj0LEK134y9bP6QVM8QKJLh cLsma4uflherwpbVoBIGl8BjqRZAJCvbpZ9ofILYGHFYVjPHAFY7AeQs0PGElaNR180q i4MngXPmmkDYSEFqnQRPNbWKd56B/visD9gxL/E79b4Vsn5hjAjwgrlnNxKY2TAJTc3Y fca3d5KiBftAovSl5nOyh6Vt7iQLs19cmxtdMww3vzjGrl9Vqk2Mc51xUYoIq7AAY+Xu 0FQT0A7bo9Q8bQNqkM7egvTRN09z5lnhHDqS9Mmxewg3FVNPLFFLVpO82qBwEX3po0Ck /l6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PLr3sFaG; 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 k29-20020a50ce5d000000b00446064a8cf3si1699750edj.621.2022.08.23.04.30.09; Tue, 23 Aug 2022 04:30:35 -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=PLr3sFaG; 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 S242944AbiHWJoS (ORCPT + 99 others); Tue, 23 Aug 2022 05:44:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352213AbiHWJlC (ORCPT ); Tue, 23 Aug 2022 05:41:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEC3779A55; Tue, 23 Aug 2022 01:42:00 -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 ams.source.kernel.org (Postfix) with ESMTPS id 61467B81C65; Tue, 23 Aug 2022 08:41:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A218FC433D6; Tue, 23 Aug 2022 08:41:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244084; bh=uPEDf+H+9p9j/UybwHupxb1s2C5Sf1klNm8f8v4Kf9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PLr3sFaG7pPGmdGrFlX6UjerRKMf2eUzuPiq3Bp01ZQkqcJP5pfRNQ/sPOX3z9sMe meBAQGurmsaEKMvfv5XdS8dC/5idRscfGa2qkZvPVWOxgWW3MENT+1Ag2n/AoPiYta ca4snDV2bhYARRTY1CFca+VQ5t9X7h8cufkWpAMQ= 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 5.15 034/244] apparmor: fix reference count leak in aa_pivotroot() Date: Tue, 23 Aug 2022 10:23:13 +0200 Message-Id: <20220823080100.206857297@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@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 @@ -719,6 +719,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);