Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3342380pxa; Tue, 25 Aug 2020 19:36:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxg6WXiPxhVFHqBaubcwTR89m5dO2urK0ihA8lMJXTIYa/7JEDKAwkHAdEOCfUZy8/ecrl5 X-Received: by 2002:a17:906:5205:: with SMTP id g5mr13220379ejm.488.1598409405609; Tue, 25 Aug 2020 19:36:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598409405; cv=none; d=google.com; s=arc-20160816; b=m7/7D7AEZIT66bP/kQX9sgz336Gg5HcLlHanzgBDCp1b43YrABxzQiIQ5pexMKiJnj IqD2aUY+dE9TLu/ZYY3AY5jnGG1JwAHJubwmmKWcnRTA1zkU1xIvIemSqBo8jce20D8D W+Fd2FzMAaiPw9qRMTmWV4PVnxMj4tcmt3mz5PWjO5JfDl3bIBKaQ/zI+U412fF3GY2L FFO8FyOR3ZNQcUnqqxkkUpgbcjEgCGGNzaEbS31QeCZmGFOk78df8dWuBpyBBicfGlfy cu/U7diECxJCYkjEG06D1YqVxjK0RbTtrR+MLZ1DmVwukynOW8dcRsxnGxOFmwxtasVW DHuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=qTTirhS4tgARwSmt2CrwMKjZEtQBfU50yJZ95gB7kI0=; b=clbztdqQmBUdms+thafIPw82VJlv9EZnlFXU82lwjwaz2wML/giDLdscN6S8S0fqyw 35RiC5RqiOM9cpEEunfYnsyHTiaEgp8zMq4KO5wBXZpT1VRL32WGcbpFrQtca3gwZ2Qd Cl/NpkW1IF69fb/W6toR6mVaCz2IHEIVWMsimoX+bf4796ShCLGRESuAdNwZVW6/8o3i 582jSFmWVyv+5fG+mTjzKzTz5MPgszErZ2KOtHFXtnMEl74Yv5p3qe8eoSQnPIBSIikE dXGur5didcgaNMbo9JEA0hL3oy8rZJE5CzRwa2aG5sFSVquzbZK3u63fH1ffsrayEa/s uvuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=nZB3nTfX; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds5si831166ejc.703.2020.08.25.19.36.21; Tue, 25 Aug 2020 19:36: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=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=nZB3nTfX; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726661AbgHZCf0 (ORCPT + 99 others); Tue, 25 Aug 2020 22:35:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726611AbgHZCfZ (ORCPT ); Tue, 25 Aug 2020 22:35:25 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61FC8C061574 for ; Tue, 25 Aug 2020 19:35:25 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id o13so310858pgf.0 for ; Tue, 25 Aug 2020 19:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qTTirhS4tgARwSmt2CrwMKjZEtQBfU50yJZ95gB7kI0=; b=nZB3nTfXwtirj0Dfa02h5DsBk22b7a15AQG/8Ko2SeqemhlIzMy2w39Fz8bbh4K2vO Fx4gyfYwOFf7zThB7wyYq3gwTm4oCfF00+tWqQLQ5IHYhUicQMJe9P2XjChp8LWnXu2P iom5SDmp3BW0+4qVS62AIRq5kMP56kAxjqSnQmas1O04vVMWoV22LzXVTMYT5SoSZ7QE NU/agOeI6zKO/At7M99eJzFK1s0Sg9rcOmqEpTZLK56yLXSE36ai0sOUoug8hvnduR6k NbKzXDn4VPDzl6vW910Vi2GWUk6nJhlTNP/mCMEvxJ78J2R3JqB7Tq+8iHQXAuOV2nZD JTiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qTTirhS4tgARwSmt2CrwMKjZEtQBfU50yJZ95gB7kI0=; b=afaYkKC//NGoTzBbIFzl5MepR6w8ylpPq9KS25ohdQGq/tmV8VebpB64Gr0Ee+HDks QuemoqBxZdRqYjCgjF1uMg48CorZmOzACGAkUXhT8GI436bOg43cpYkXq0Ui3qOuSvj6 VdVl2lWW6p9ECXAZkqAqCCpwIDprjtdmS4Dc8NcHmkGMTRzp5r6PPUGNAz+LhE19CZrS DUymBN/k8VymTQx8ruURVDerJ4COE5FY4gsDbODZN5POcsUNXMNv2g4IdmNi4UwgMbvu veB86LCoTq5m+eU5o+gwYj3yweLt2DOSRVwb6dumdFbNJEBHEivjafVwbvZrTAn2RFIq QaJg== X-Gm-Message-State: AOAM531uxoyr5F7wYhohHo6etixKcqLWAlhZ4LRZ9y96jajgu3HIr4mQ mNmAHvgg88MsSBoH4WiLnqzZtwqQ91FxH0ymYjpvNQ== X-Received: by 2002:a62:6497:: with SMTP id y145mr10157831pfb.97.1598409324792; Tue, 25 Aug 2020 19:35:24 -0700 (PDT) MIME-Version: 1.0 References: <20200822095328.61306-1-songmuchun@bytedance.com> <20200825152509.GO1509399@tassilo.jf.intel.com> In-Reply-To: <20200825152509.GO1509399@tassilo.jf.intel.com> From: Muchun Song Date: Wed, 26 Aug 2020 10:34:48 +0800 Message-ID: Subject: Re: [Phishing Risk] [External] Re: [PATCH] mm/hugetlb: Fix a race between hugetlb sysctl handlers To: Andi Kleen Cc: mike.kravetz@oracle.com, Andrew Morton , npiggin@suse.de, agl@us.ibm.com, nacc@us.ibm.com, Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org HI Andi, On Tue, Aug 25, 2020 at 11:34 PM Andi Kleen wrote: > > > Fixes: e5ff215941d5 ("hugetlb: multiple hstates for multiple page sizes") > > I don't think the Fixes line is correct. The original patch > just used a global variable and didn't have this race. > It must have been added later in some other patch that added > hugetlb_sysctl_handler_common. I don't agree with you. The 'e5ff215941d5' is not used a global variable. Below is the code snippet of this patch. Thanks. @@ -1037,8 +1109,19 @@ int hugetlb_sysctl_handler(struct ctl_table *table, int write, struct file *file, void __user *buffer, size_t *length, loff_t *ppos) { + struct hstate *h = &default_hstate; + unsigned long tmp; Here is a local variable of tmp. + + if (!write) + tmp = h->max_huge_pages; + + table->data = &tmp; + table->maxlen = sizeof(unsigned long); proc_doulongvec_minmax(table, write, file, buffer, length, ppos); - max_huge_pages = set_max_huge_pages(max_huge_pages); + + if (write) + h->max_huge_pages = set_max_huge_pages(h, tmp); + return 0; } > > -Andi -- Yours, Muchun