Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2428392pxa; Mon, 24 Aug 2020 14:02:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh50Ozu+GjS50LQZDSKzS/l3lXa2IM2tpn0gaqirZoVr5PYBBEgbb1AT91KxGwbIi/tn9B X-Received: by 2002:a50:8f44:: with SMTP id 62mr7554765edy.3.1598302965295; Mon, 24 Aug 2020 14:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598302965; cv=none; d=google.com; s=arc-20160816; b=wonqXcpqH+wjGSKm0vW+5w4AEz2BwXlA4Gd293AOLBB9lBO5Tf7qabc1QNwjNtq7ud 76UiHvJ4ugKlgluZQLl1vk7dSavSL3FXLeWBze4RTN5DvUBdmxIoPlj2FQ8IBpiOALGo R+cxM8+6ZJpC7K8nCLx/EJ8uBbcDjCyghDQrrl/bS9HEGD+Xz+DUOmv5rZwe7JH7hNfK csmcDAW0YWu82S6CgojXV1Rd4mp0wOlmctPkxnRQ8GLr8NAZ1dd+IcRq7KCCpGaLWHoB wT/36lwOvS5GaITbR2G0GBOCDBazCcjF6YSi1htVDWJDBRsOkQ/q8PI8VaduQt01EAfV p35A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=GxWlCtBMoOL3/Pxs2zXYm+jlO7AMfR8iC41GfrLyZz4=; b=v+gNUmAsiIOO6J330j4NNkRLAAIODC5zvBING1TW3/JXpluAmfDhuA7akKuo13hJGu bAota67ERULB0A0kill9oQyCLttr1/pDFUoc+mhyCdVCCVgFSxQu9kG78nbHVloksKUy aGxST+fOfJeXB4oEPhhsv0hSGOsKORPsQeDL5Ld7n4+3J9ml7LVWJHCynJTx3hNcZPDA zv/gI9s340DqVH0LIU0+DjwP00Wburpz1vCTjmAhwswd62MKaVnCZzLe4g0qTmIll+l4 PywQlG65xzIQfRZlcqalyl8YPgkmDteLlzfc/AR2l6akcCs4gTz2ygTquWEje/z7YVqv Lw/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B25I8koM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q10si8127554eji.292.2020.08.24.14.02.21; Mon, 24 Aug 2020 14:02:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B25I8koM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726700AbgHXU72 (ORCPT + 99 others); Mon, 24 Aug 2020 16:59:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:56846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725904AbgHXU70 (ORCPT ); Mon, 24 Aug 2020 16:59:26 -0400 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. >