From patchwork Wed Oct 19 08:31:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5209 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp264655wrs; Wed, 19 Oct 2022 04:20:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM62uCZdSIIkzYDGhvEIxE4ca2wPLvslCSFuTdgH2OAHk4owrQZGnJWCBPe4mRI9rdWabGJB X-Received: by 2002:a17:907:2702:b0:78e:e94:2ac4 with SMTP id w2-20020a170907270200b0078e0e942ac4mr6233974ejk.679.1666178437096; Wed, 19 Oct 2022 04:20:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666178437; cv=none; d=google.com; s=arc-20160816; b=zvBh9FxcUXdgyAkbasNG7LPs7M7/nggBKU8Svc6TIK3vXogKZKTou5JuKObX4Dh8GU q9NVvzBVnov9AgnAhV18SzBSr7RSh1OAopajBhRIRNOUzb19h5+fW2p/7u+f5YIMY411 wsucqobzKL0JJ6JY1luSU0uUmBvINDeHd7IzOFYGdqvkZX4d6lcXLhgujbAoBCUcWFA1 6QCtKv2CL3d+Zp+vGmhtgdksw1kdfEyD0NYN543Oms+f67qvgPteHMeXmwcKB1VHMjyo GnbqujUou/FZYUxcD73Ap0hHuZ2SXSu6abS6sKhJbB4jmfEALe9gGCeePLqvJ1bbMm44 0chg== 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=LCUOLP1nMan9i8WIEQSziWZ5WoxFUBos6X4ta8kGOro=; b=rh05lYTO1dvV6nPtFrvwVQYQFtOHS55QY7vlvnV3ifjEE0QqQDS9jZFr3RTsAiHe1u /SopfmHuukSqJAVAGWprVmpgCT0BtGYfmpSD5UCIOvfcpVpfCazqpTwBlHZPHyOQvkmP kc87/Swjlt/7dxQ6kbnF/EWcLe8zChm2SzXU9sCDP4iB+Hs43syovfhtTimgMeKsq2Cr JUP6tercDZsT44EZsFxoonFNqcvtS89YG9NwuLM0LoWvR1uVExUp/InxTNMO2E/j+Rbj 7nZBuiJPsSothyGdRa+F8mmAMyP4LktdKGgsrqeTegX3YLjl8NAdDqaQjzrpB4gl6VKk ahXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p+T1nxJK; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u27-20020a17090617db00b0077b2e822b5dsi12434344eje.674.2022.10.19.04.20.11; Wed, 19 Oct 2022 04:20:37 -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=p+T1nxJK; 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 S230261AbiJSLIs (ORCPT + 99 others); Wed, 19 Oct 2022 07:08:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232334AbiJSLI1 (ORCPT ); Wed, 19 Oct 2022 07:08:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFACC17C54C; Wed, 19 Oct 2022 03:37:03 -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 B8C59B8239F; Wed, 19 Oct 2022 09:06:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05C54C433B5; Wed, 19 Oct 2022 09:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170401; bh=+NwEIh0CKLU+P0/6RuqD9Lvp0NWwOKt/Z49Pb8qKbWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p+T1nxJKfd6c8vze6LZXnj3cEaI7TiDn4PaAlbMlvn9X0P18yGrd21MKJS64oH56i rg2mwdKJZKcyYzOSUp2/Kz2b6v+mVSgucqn3bT2aBtwLlbrrd8Gq/yxY7oQegphEKF /cS4QgrIQ9dOdgrOIPepA0aj0EheDQhUPr0O11Do= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , "Eric W. Biederman" , Sasha Levin Subject: [PATCH 6.0 606/862] ipc: mqueue: fix possible memory leak in init_mqueue_fs() Date: Wed, 19 Oct 2022 10:31:33 +0200 Message-Id: <20221019083316.717671409@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747114720382073437?= X-GMAIL-MSGID: =?utf-8?q?1747114720382073437?= From: Hangyu Hua [ Upstream commit c579d60f0d0cd87552f64fdebe68b5d941d20309 ] commit db7cfc380900 ("ipc: Free mq_sysctls if ipc namespace creation failed") Here's a similar memory leak to the one fixed by the patch above. retire_mq_sysctls need to be called when init_mqueue_fs fails after setup_mq_sysctls. Fixes: dc55e35f9e81 ("ipc: Store mqueue sysctls in the ipc namespace") Signed-off-by: Hangyu Hua Link: https://lkml.kernel.org/r/20220715062301.19311-1-hbh25y@gmail.com Signed-off-by: Eric W. Biederman Signed-off-by: Sasha Levin --- ipc/mqueue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ipc/mqueue.c b/ipc/mqueue.c index f98de32aeea1..9cf314b3f079 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -1746,6 +1746,7 @@ static int __init init_mqueue_fs(void) unregister_filesystem(&mqueue_fs_type); out_sysctl: kmem_cache_destroy(mqueue_inode_cachep); + retire_mq_sysctls(&init_ipc_ns); return error; }