Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp270712imn; Fri, 29 Jul 2022 06:27:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR6oFS+p+WSf4hpcV/IZo72ny0TmEbbqo18uymL1c09msySjNT8FXVLwvAIAcKDRxNKM5sNx X-Received: by 2002:a17:90b:4d07:b0:1ef:521c:f051 with SMTP id mw7-20020a17090b4d0700b001ef521cf051mr4934515pjb.164.1659101237040; Fri, 29 Jul 2022 06:27:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659101237; cv=none; d=google.com; s=arc-20160816; b=LY7T/wesmoinSUkCzcxcYr4TVMkZQB9F9Djf2oOPgGigdgCEv7TsD+usdZGXkrgQ7Q XC5N63wWAEZnnQ9mvMCeEviSPoI75MhUpLghpCkhUe713u3ndJr5Ef4LLED+CgExbduk 9qYppp0MqMRq1YMLxilmhjMUGU5JC0runk72psUQRGdFml0CgIYmBExtw3w3iRHPNGLs +MId3Y9yXdrmyXKznNCD+n9M5mGhWVj5I5fK5sfBh7Ep7tziIhvOddqkgOVOeIl8YCmJ OltZrYPIwv8nqbhMBZtj1yDD7d0vsDQRIiYZjc1i93Hnw9xSMju7UKGF1FURwRr582/M XSUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=9qcN7rePxCfT6Ee+38vYxX+IiOzUOHthC5oSI/3Hm30=; b=RligAvPOPnlQX5TbFdB/77mz/4vaQzbzwhdEN+3ulgxzvc+9bLBVt74YamOvGsXMjL l3iuhBeY2P9hRW1pd7MAq8rHyQhvGryDVHNUnd3eRk9qve0P2vjlqiPXrCbAs1y6F6fc Ti5Ha13IqWv5iEGZrh5z45niH7djXulJkzurBXTAeK8uebnIkYOUjdTmgdD4T9qYevnC daXUTrZYIHORKU/mxPS/fUYp2WpNgMda415yE+K60OQNrWEl8m5TthhX/ep0JABPo+DA ZStIh4Bvyf5Q3mnu/b2z94ooGj0gt/Es6MnO+2FAnU44/sx88xxLyjU/0bSRjybfzLqF KJBw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a62d441000000b0052c8b7d7586si3424134pfl.45.2022.07.29.06.26.45; Fri, 29 Jul 2022 06:27:17 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236404AbiG2NIu (ORCPT + 99 others); Fri, 29 Jul 2022 09:08:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231976AbiG2NId (ORCPT ); Fri, 29 Jul 2022 09:08:33 -0400 Received: from a.mx.secunet.com (a.mx.secunet.com [62.96.220.36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73B5310F7; Fri, 29 Jul 2022 06:08:26 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id 5B75D2057B; Fri, 29 Jul 2022 15:08:24 +0200 (CEST) X-Virus-Scanned: by secunet Received: from a.mx.secunet.com ([127.0.0.1]) by localhost (a.mx.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7NYllXnDYExq; Fri, 29 Jul 2022 15:08:23 +0200 (CEST) Received: from mailout1.secunet.com (mailout1.secunet.com [62.96.220.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by a.mx.secunet.com (Postfix) with ESMTPS id 7A3CE204E5; Fri, 29 Jul 2022 15:08:23 +0200 (CEST) Received: from cas-essen-01.secunet.de (unknown [10.53.40.201]) by mailout1.secunet.com (Postfix) with ESMTP id 704D380004A; Fri, 29 Jul 2022 15:08:23 +0200 (CEST) Received: from mbx-essen-02.secunet.de (10.53.40.198) by cas-essen-01.secunet.de (10.53.40.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 29 Jul 2022 15:08:23 +0200 Received: from gauss2.secunet.de (10.182.7.193) by mbx-essen-02.secunet.de (10.53.40.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 29 Jul 2022 15:08:23 +0200 Received: by gauss2.secunet.de (Postfix, from userid 1000) id D284B318103E; Fri, 29 Jul 2022 15:08:22 +0200 (CEST) Date: Fri, 29 Jul 2022 15:08:22 +0200 From: Steffen Klassert To: Xin Xiong CC: Herbert Xu , "=?utf-8?B?4oCcRGF2aWQgUyAu?= Miller" , Eric Dumazet , "Jakub Kicinski" , Paolo Abeni , James Morris , , , , Xin Tan Subject: Re: [PATCH] xfrm: fix refcount leak in __xfrm_policy_check() Message-ID: <20220729130822.GC2602992@gauss3.secunet.de> References: <20220724095557.4350-1-xiongx18@fudan.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20220724095557.4350-1-xiongx18@fudan.edu.cn> X-ClientProxiedBy: cas-essen-01.secunet.de (10.53.40.201) To mbx-essen-02.secunet.de (10.53.40.198) X-EXCLAIMER-MD-CONFIG: 2c86f778-e09b-4440-8b15-867914633a10 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 On Sun, Jul 24, 2022 at 05:55:58PM +0800, Xin Xiong wrote: > The issue happens on an error path in __xfrm_policy_check(). When the > fetching process of the object `pols[1]` fails, the function simply > returns 0, forgetting to decrement the reference count of `pols[0]`, > which is incremented earlier by either xfrm_sk_policy_lookup() or > xfrm_policy_lookup(). This may result in memory leaks. > > Fix it by decreasing the reference count of `pols[0]` in that path. > > Fixes: 134b0fc544ba ("IPsec: propagate security module errors up from flow_cache_lookup") > Signed-off-by: Xin Xiong > Signed-off-by: Xin Tan Applied, thanks a lot Xin!