From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 119F3C433FE for ; Mon, 21 Mar 2022 08:59:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 433116B0072; Mon, 21 Mar 2022 04:59:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E2676B0073; Mon, 21 Mar 2022 04:59:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AA9C6B0074; Mon, 21 Mar 2022 04:59:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id 1A9046B0072 for ; Mon, 21 Mar 2022 04:59:52 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BBCA3181FA8D6 for ; Mon, 21 Mar 2022 08:59:51 +0000 (UTC) X-FDA: 79267795782.17.7309459 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf10.hostedemail.com (Postfix) with ESMTP id 3E424C0028 for ; Mon, 21 Mar 2022 08:59:51 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 42178210EC; Mon, 21 Mar 2022 08:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1647853190; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rerL71kehnz2q1cuLKpY1j8XERV8cV3bZj87Fo6jIys=; b=poiCcF7d/51GTWfnNu2CbvHJnzPs2yUjE5Y7L3EkTLobZrTCOGqy2oYA7niyWrfBCVNWPQ 3MDrFE82IngFzzAbTGUR2NDZ4PM13k/05MI58h48sOPbvbs7TN65SMiQQxFVNo6P2fQSdz NT6zcFxbSGWCQWWTd/B+mbAmx256Gmw= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 09E3DA3B87; Mon, 21 Mar 2022 08:59:49 +0000 (UTC) Date: Mon, 21 Mar 2022 09:59:49 +0100 From: Michal Hocko To: Miaohe Lin Cc: Andrew Morton , kosaki.motohiro@jp.fujitsu.com, mgorman@suse.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/mempolicy: fix potential mpol_new leak in shared_policy_replace Message-ID: References: <20220311093624.39546-1-linmiaohe@huawei.com> <26577566-ae1e-801c-8c64-89c2c89a487d@huawei.com> <24b2a9ef-eea0-09bd-6842-121d8436e56a@huawei.com> <6ebebfd6-6356-e956-4fbc-0abaa58308ff@huawei.com> <207bbd69-6678-5120-3760-e2bcd9803a14@huawei.com> <36b0ea44-39ab-bc52-1ae5-eca2cf832900@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <36b0ea44-39ab-bc52-1ae5-eca2cf832900@huawei.com> X-Rspam-User: Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=poiCcF7d; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf10.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 3E424C0028 X-Stat-Signature: tdd8hx5ferk3jteh9d18o6ouqgi6xa9n X-HE-Tag: 1647853191-697960 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat 19-03-22 18:42:33, Miaohe Lin wrote: [...] > This would be triggered easily with below code snippet in my virtual machine: > > shmid = shmget((key_t)5566, 1024 * PAGE_SIZE, 0666|IPC_CREAT); > shm = shmat(shmid, 0, 0); > loop { > mbind(shm, 1024 * PAGE_SIZE, MPOL_LOCAL, mask, maxnode, 0); > mbind(shm + 128 * PAGE_SIZE, 128 * PAGE_SIZE, MPOL_DEFAULT, mask, maxnode, 0); > } > > If there're many process doing the above work, mpol_new will be leaked easily. > So should I resend this patch with Cc stable? But it seems I'am not supposed > to make this decision and the maintainer will take care of this? I would just add Fixes: 42288fe366c4 ("mm: mempolicy: Convert shared_policy mutex to spinlock") Cc: stable # 3.8 And also add your above reproducer snippet added to the original changelog. This would be more then enough to conclude the importance. Thank you for working hard on this! -- Michal Hocko SUSE Labs