Received: by 2002:a05:7412:85a1:b0:e2:908c:2ebd with SMTP id n33csp145510rdh; Mon, 30 Oct 2023 17:18:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNHzK0jp+ZPj9HROl3T6oRrvvfK/HlshyuwqbcpDtFgfMlwxKQ5rDaDCMTEC8j2jUVr5/W X-Received: by 2002:a17:90a:db92:b0:27e:277:3014 with SMTP id h18-20020a17090adb9200b0027e02773014mr8226367pjv.11.1698711479833; Mon, 30 Oct 2023 17:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698711479; cv=none; d=google.com; s=arc-20160816; b=QTXGZngiMkwHKTK4hBrEaz9PsmaxJdE5QbUeSoz5PIKUYRE73pfoI9jJ3BYMkHLBXt t+LIvEoGWVto06DAUYy3NWUcHZOKTBiql1V40DDuun/TxTJZu9OjYTAghNO7sM32+TdL vXWOwmBB1wxSMpvaEWS4IITbE+EtnTxTLBR92cd/O3QJtfqkc4hVEr70ZHCrAvebhCCt sHuUYpcn4Pu1p5OL67v77FKgBBGz697MpoyFPoB3Q8m0XXoIriUZU/iSrob5vYLb8PF+ yowuDscm4BXrLq37XiN+DsJggCLCfZtck2Yuc5MuSwnuHI+rOgb7ZQpo7armoSRxIH+J ZHCg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OD4RKFVfAbTN2kU9bJZ9F+y9XLZ/Az1TURsN25S7xmg=; fh=YhAnhY9dmzSlZ/xbBVyQfHpMTWB92dDwW/BuEFCwEvk=; b=IcPKIbjqaWWVkTlkPZoKJguUtJOUirpz07T9CvT4N4aeih1jaAmmeiXcz9iqSBA+do wr4LBHHRktMuJRSYhnboiq9bJKkNXCiXh2OAiOjapQy0s9xH6zq5w5xSdjEafiJWh/OM DdFZZSAB/6VZk//JihcRoIvbEyeoAcdhk0+WuUgisua11hsTIGfGZ+PK/4+t1OC3i/Uu NsPRJV4oDV2avIQ4WxDKfSXMza4M+fjO6qIytqA7uo1lUGnFjY60HpgJ8GEjnll4RzhY 8dfF7Qa3MQdqpv2shj/k+kry/43GBY+rlMEbkyDsp49mvEP3e/yovIiy46u0PJdl2r4P ep3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Dh4wFZfF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ft4-20020a17090b0f8400b00279866aa14csi121836pjb.16.2023.10.30.17.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 17:17:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Dh4wFZfF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 53F4680B8DF5; Mon, 30 Oct 2023 17:17:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236314AbjJaARe (ORCPT + 99 others); Mon, 30 Oct 2023 20:17:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236251AbjJaARd (ORCPT ); Mon, 30 Oct 2023 20:17:33 -0400 Received: from mail-yw1-x1143.google.com (mail-yw1-x1143.google.com [IPv6:2607:f8b0:4864:20::1143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DEABB3; Mon, 30 Oct 2023 17:17:31 -0700 (PDT) Received: by mail-yw1-x1143.google.com with SMTP id 00721157ae682-5a87ac9d245so48984987b3.3; Mon, 30 Oct 2023 17:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698711450; x=1699316250; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OD4RKFVfAbTN2kU9bJZ9F+y9XLZ/Az1TURsN25S7xmg=; b=Dh4wFZfFnVQAcqLeqTB3vybYBdM1EMB5VBjz/9WWuUyVMM/WJXkwFiR5B6d7cXh79K Bbu5Xf2YCAHONFFjKX/To3rmm0RIDvhUs92RTILbZ46CYriRXuIpqKhMHSwdZ6BdsW34 VmSrOvdr0vf/IXo//TOHeejBpx7BedafDRcj7eTh4rh+J5e+1QzR4CynXUaSptQxpiNs w7hp5qk3Z/j1fD9asbvOKGHPs9EqH/nNZdw4CdnE4S0GajsJVEtTpp99Lxm9zYI1S31h zUfKi7aPutymMpfDoFsHWGiKu8qX7L4QGug3+BB5wmgBDyNjoYMFVRkn5+o9d4bH78/d uQjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698711450; x=1699316250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OD4RKFVfAbTN2kU9bJZ9F+y9XLZ/Az1TURsN25S7xmg=; b=u4SjTYqkuRya9vvPRIA9i7IIrYe2zlFmZ1djEub6E0U3Q7aFieTUVYUBVk/LknAP/l T9LjuHoKSy61xj9u3N+Tmbj6hwGTQhRuh1OvwGLGwoPMboff7TArh63ZA9GcxO/xY3h3 p2UDaHu1eimugz6/K/hZkRDjJDTSLXsqSWccQGycm2eJSYrd65mGfBuWop8xtHCTbGUn FardLFUFnOeYtzzoztbTxd6w7vTOpNpsUgk/JWT19im0tnWJSLV2kKGLp2W6GtOlDlNo ZoMOSOvTlHfGaW57Eik2nqFlzOqiVsZQtRlRoCEHzo2jWfXkOv2RDwdTQhCDeZ17MGGZ mOEQ== X-Gm-Message-State: AOJu0YwjQxYIJ49/PihprLgssV+BYWTKpPrSKbgPfE7WdJpD+XrrTe4A 0r+CQ8nAyOYLn2aykz84FKGFeEhxmdJ9 X-Received: by 2002:a05:690c:f13:b0:5a7:d133:370d with SMTP id dc19-20020a05690c0f1300b005a7d133370dmr14467747ywb.16.1698711450524; Mon, 30 Oct 2023 17:17:30 -0700 (PDT) Received: from fedora.mshome.net (pool-173-79-56-208.washdc.fios.verizon.net. [173.79.56.208]) by smtp.gmail.com with ESMTPSA id fc10-20020a05690c314a00b005a7bf9749c8sm113824ywb.4.2023.10.30.17.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 17:17:30 -0700 (PDT) From: Gregory Price X-Google-Original-From: Gregory Price To: linux-kernel@vger.kernel.org Cc: linux-cxl@vger.kernel.org, linux-mm@kvack.org, ying.huang@intel.com, akpm@linux-foundation.org, aneesh.kumar@linux.ibm.com, weixugc@google.com, apopple@nvidia.com, hannes@cmpxchg.org, tim.c.chen@intel.com, dave.hansen@intel.com, mhocko@kernel.org, shy828301@gmail.com, gregkh@linuxfoundation.org, rafael@kernel.org, Gregory Price Subject: [RFC PATCH v3 1/4] base/node.c: initialize the accessor list before registering Date: Mon, 30 Oct 2023 20:17:18 -0400 Message-Id: <20231031001721.3972-2-gregory.price@memverge.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231031001721.3972-1-gregory.price@memverge.com> References: <20231031001721.3972-1-gregory.price@memverge.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 30 Oct 2023 17:17:57 -0700 (PDT) The current code registers the node as available in the node array before initializing the accessor list. This makes it so that anything which might access the accessor list as a result of allocations will cause an undefined memory access. In one example, an extension to access hmat data during interleave caused this undefined access as a result of a bulk allocation that occurs during node initialization but before the accessor list is initialized. Initialize the accessor list before making the node generally available to the global system. Signed-off-by: Gregory Price --- drivers/base/node.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/base/node.c b/drivers/base/node.c index 493d533f8375..4d588f4658c8 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -868,11 +868,15 @@ int __register_one_node(int nid) { int error; int cpu; + struct node *node; - node_devices[nid] = kzalloc(sizeof(struct node), GFP_KERNEL); - if (!node_devices[nid]) + node = kzalloc(sizeof(struct node), GFP_KERNEL); + if (!node) return -ENOMEM; + INIT_LIST_HEAD(&node->access_list); + node_devices[nid] = node; + error = register_node(node_devices[nid], nid); /* link cpu under this node */ @@ -881,7 +885,6 @@ int __register_one_node(int nid) register_cpu_under_node(cpu, nid); } - INIT_LIST_HEAD(&node_devices[nid]->access_list); node_init_caches(nid); return error; -- 2.39.1