Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3413163rwa; Tue, 23 Aug 2022 04:29:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ETo4TaJxcAsAN5A16/iPyQy2zdf27JRp/Ydk5hJTNlW6PLfLu/TmHWDqEx2HFadZOt2Wo X-Received: by 2002:a05:6402:40c1:b0:447:154e:856d with SMTP id z1-20020a05640240c100b00447154e856dmr2689336edb.319.1661254164409; Tue, 23 Aug 2022 04:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254164; cv=none; d=google.com; s=arc-20160816; b=Deh1AFOU8lYOCuctn6aObS2XDFhsbThKKHBu+NBTJzgg9QH++er18A4TsHwNCQCxJw 0zVyPnv3WsoksRnCGqv1G2slxFBNHDyogtIztkgsniCXR1jARt7wjVsXocviiVK2p2Fx 5IxOwKesH5Twum3biy1FOo+f7gBNdGGCAolgKkdrjzya3I/HaMEJ8gnR+tRZh1+J9hEB HsX6rpbUAbkneEawvsctnVQC90YrYSjm0EUZCbWjg0Ch9DpnrXXrByGgH1uAoS2JoixZ x6vphyB0cK0EI9JglMaGtln32uJi/wQ6R40rvjaINxWxRmsCk0Z5/d3Rhr2k/I0fFvNI 2ZmQ== 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=Q9R2r0LLQuNM5oO0HvJwUighuj3vNXdWhQ1fYy37Gls=; b=XVsu9TpMXTz/PQFZrbaeO3zwtOevS9nsPY7pAZWMc+fdA/uW1J5Nw6Z+cyn06woXoj 8PFe0mU4qDEP42oRVWn7pohv22wcWpv1MJjiJxwTkFzyUEA4iegGId9fmNWMyn3K9JOG SqSWUrU+GaNw2pGZ8Jnd0Qoy7a4voQWfFXb/PPfOEptxZ74XqvkrHcHxbTUK80CSMYyv fwSNOeKFGaOPnZjLkyMoPxEbiVTP5aBusnb04RyfOZmD7+OOsh/Z7XTE40upNQsnsD92 zlnc78X8LI0KMCStRVkPgbslldHHsyjlwfg6b4qZXSHjbLxjUjCXJIuCM51JCo1IneLO Lr0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eVJdRCMU; 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 sd7-20020a1709076e0700b00730c1850171si12610499ejc.800.2022.08.23.04.28.59; Tue, 23 Aug 2022 04:29:24 -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=eVJdRCMU; 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 S1353267AbiHWKNP (ORCPT + 99 others); Tue, 23 Aug 2022 06:13:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352707AbiHWKGI (ORCPT ); Tue, 23 Aug 2022 06:06:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC59B7D785; Tue, 23 Aug 2022 01:52:28 -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 11C7C6123D; Tue, 23 Aug 2022 08:52:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0304CC433C1; Tue, 23 Aug 2022 08:52:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244747; bh=thibkoY1vJoCkfi1Ybho7TQwoOG2KHM67rYyFifPu9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eVJdRCMUxkr2pQlNaDpMo12CkxYlRGTWnaMkm1hZ4c6prE7HCcDssumSPkRCK3hBD y7mjMiUx1DDj0Qv/JRZIGsQDPnFtyIyrgGMdAeCnkiNXkPu2fJhfSrSCFhpd8Upo+Q 996cxx19Fdds0n3psGAIX8iNEOzuvrQYvGIUzXpo= 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.14 184/229] apparmor: fix reference count leak in aa_pivotroot() Date: Tue, 23 Aug 2022 10:25:45 +0200 Message-Id: <20220823080100.177336614@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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 @@ -687,6 +687,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);