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 X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8596C433E1 for ; Mon, 24 Aug 2020 20:59:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7185920738 for ; Mon, 24 Aug 2020 20:59:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="B25I8koM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7185920738 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EDC768E0017; Mon, 24 Aug 2020 16:59:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E64E28D0003; Mon, 24 Aug 2020 16:59:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2C418E0017; Mon, 24 Aug 2020 16:59:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0033.hostedemail.com [216.40.44.33]) by kanga.kvack.org (Postfix) with ESMTP id B97B78D0003 for ; Mon, 24 Aug 2020 16:59:31 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6953D180AD822 for ; Mon, 24 Aug 2020 20:59:31 +0000 (UTC) X-FDA: 77186678142.18.pail68_0c12cf527056 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 05141100EC66E for ; Mon, 24 Aug 2020 20:59:26 +0000 (UTC) X-HE-Tag: pail68_0c12cf527056 X-Filterd-Recvd-Size: 2370 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Mon, 24 Aug 2020 20:59:26 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4DFBD2067C; Mon, 24 Aug 2020 20:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598302765; bh=4+0iQbpq05lWO5uaP5s74XH/C6aQ3ITZkVphPS3p7ss=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=B25I8koMGssHnexX/OyD91/GVSd1cU2haDLC4bxbiNAuPpfnviIXV89tPBjDUF0u0 J1UgRrf0rRVYYm2iY2kE+PyVwDdP2JOkrrIUdVOojBS1gisoZtt9euTQRoBqTHL94D ptOp5ZBbB76H7MP0Ly2k8zDi+WUQniIr5yge+few= Date: Mon, 24 Aug 2020 13:59:24 -0700 From: Andrew Morton To: Muchun Song Cc: mike.kravetz@oracle.com, npiggin@suse.de, agl@us.ibm.com, ak@linux.intel.com, nacc@us.ibm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/hugetlb: Fix a race between hugetlb sysctl handlers Message-Id: <20200824135924.b485e000d358cee817c4f05c@linux-foundation.org> In-Reply-To: <20200822095328.61306-1-songmuchun@bytedance.com> References: <20200822095328.61306-1-songmuchun@bytedance.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 05141100EC66E X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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, 22 Aug 2020 17:53:28 +0800 Muchun Song wrote: > There is a race between the assignment of `table->data` and write value > to the pointer of `table->data` in the __do_proc_doulongvec_minmax(). Where does __do_proc_doulongvec_minmax() write to table->data? I think you're saying that there is a race between the assignment of ctl_table->table in hugetlb_sysctl_handler_common() and the assignment of the same ctl_table->table in hugetlb_overcommit_handler()? Or not, maybe I'm being thick. Can you please describe the race more carefully and completely? > Fix this by duplicating the `table`, and only update the duplicate of > it. And introduce a helper of proc_hugetlb_doulongvec_minmax() to > simplify the code. >