Received: by 2002:a05:7412:85a1:b0:e2:908c:2ebd with SMTP id n33csp152549rdh; Mon, 30 Oct 2023 17:38:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFq8iZPI/6IXzrP0lVu47aL3sFb8R0c4vai/2Hc8VLYgr+h+I67b+fj6zW+inTnAUMA7X5r X-Received: by 2002:a17:902:ecc5:b0:1cc:54b5:b4d9 with SMTP id a5-20020a170902ecc500b001cc54b5b4d9mr3035800plh.52.1698712732944; Mon, 30 Oct 2023 17:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698712732; cv=none; d=google.com; s=arc-20160816; b=U0s/47uCOluqAGcpoddKXz+c7ADV4DgJT/nq+knwJq4i0CvTsUyzMNTkpKkuxbgVKS wAfNydL+vhc1/aoVh1NRUlP0VgxeyhwGukfuuV8Bv1a4yGE/iSt5i/7I0xhpXdDJRf+A 2rl8DYtY06Nc3E8wRlYlldXNk7q+NB/IfLa0EoRA/uFx/wtH32MtfBUYT1fbNgN2XJ7u bV43NjqraiOONltGr1DM0h9y3Mb1U1aJTB6QleQEXPXM9udZO771Hede848/wOvW270P WCD46kS8RJna3VDVQIM6lk02SwFBOAuEGeDXj7AQ2iIkQkRPc2lVoXGyf2Ghz/erFm8H nwNg== 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=WRWx7J9f3Sdg6zuJue0XfbWdECre9gZ2zclivjSVhccpviXrJCkC1niYpt98nCfb18 g/GCCikqSjJgmWrNyEYx6vfnuJkNjgmv25UrBwVk4G9GUTuXVIr2V7BXVdwrzqwZMoLY Zhy4QQqkVkEkJxsnux9plVzORd0z0jm1rho2fl7xU0QYWhorFWXKMF1fDn9qWgga0Lzj dNmEhoxb7R65Pjcwpnh9OSp8wZmgHEqVF3SKSyzRywOLqCgUcuv/E4CuDL/TGPEE4SQH sj1ZfnxBioGCOlh5QB4u0JAZ5AZUwNktzluU//aNlKZyj4Q2wsEOENk6eEqxXtKyOUf3 FE4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VkQ7OU1x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id s11-20020a170903214b00b001c754f13381si170910ple.455.2023.10.30.17.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 17:38:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VkQ7OU1x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 9A10080B26DE; Mon, 30 Oct 2023 17:38:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236807AbjJaAi2 (ORCPT + 99 others); Mon, 30 Oct 2023 20:38:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234997AbjJaAiX (ORCPT ); Mon, 30 Oct 2023 20:38:23 -0400 Received: from mail-yb1-xb44.google.com (mail-yb1-xb44.google.com [IPv6:2607:f8b0:4864:20::b44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A094A99; Mon, 30 Oct 2023 17:38:21 -0700 (PDT) Received: by mail-yb1-xb44.google.com with SMTP id 3f1490d57ef6-d9fe0a598d8so4137823276.2; Mon, 30 Oct 2023 17:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698712700; x=1699317500; 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=VkQ7OU1xlX2UrJqR70nb1pd++N1HYyZIUKoCcl6LGVfaOkxhCSyMV+5wlX2qbt73DL aXniR5moJE+uvTc8euJlTDgyB2ESEM0iEPAhtyBb1V+Xlc8YuL7V3k7UIQSF2uD3fDVN 8+GpAm1/VuJ3s4SL50BcskgzHO7CDKprWl9knHpXxPSgjXRHDidOmsOMfljtu1R0o3MW vL4wmTSlM9xpKIdMCZu2aXgOPk0bcl8r1lI5gHiH9lLGy08vnZpp68jQM9wEOVZ53i72 kPMBph6QNQuToWzXPgfuq4POIay5q8JPF4l4Z8ASVdFRaqW/iVM08/Am5s5S/XFmTl2F VVyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698712701; x=1699317501; 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=g8R3a+pV5+GnpeoAFdigJwROJ+YhDXCSRqgS3GtChdg7/Iny2qrNiOfIa2IBD4NNx9 /kxoDJs/yUNn1zllJYaOKY0vdZAuEavMXkVue97+HjK5YUtwHVHxWdGXXKM1AGx1Josh rsmsT9fgVj9/KfEj8xSOxePmXo00iQrkOp7LTl2ATlFZ8hJzgpNIFg+Ycb4pGLvjEZk1 c8PJcDu4d6bQbVeVSUh9TQkSqlxgCELq7CE8f097zq6i7ltfLkLye356kltBYfoaa+M7 lpa7/gY8DExCgQdB+xseaqnPy6uZltGokOpLGVCuYVmNt7dkkH+J9NTB0qsO4+hPawii OlxQ== X-Gm-Message-State: AOJu0Yxbm3wfm/ocQV0SqaVNQxGQaPRScsAxNxIkq+HGk9aJZKEN6K9b TCnAX1btG6INwrIY2OA+UUsEqBfblUQg X-Received: by 2002:a25:83c2:0:b0:da0:3535:41f5 with SMTP id v2-20020a2583c2000000b00da0353541f5mr10377007ybm.52.1698712700698; Mon, 30 Oct 2023 17:38:20 -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 b19-20020a25ae93000000b00da086d6921fsm182750ybj.50.2023.10.30.17.38.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 17:38:20 -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:38:07 -0400 Message-Id: <20231031003810.4532-2-gregory.price@memverge.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20231031003810.4532-1-gregory.price@memverge.com> References: <20231031003810.4532-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 30 Oct 2023 17:38:50 -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