Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3395969rdh; Mon, 27 Nov 2023 13:09:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqRc9qzOAQUJt9zvX8WmMYQSN4IhkgvsR+uMc3efuG7puKGlVJ+14lBnTpHUx0ZyTRqOuq X-Received: by 2002:a05:6a20:3d14:b0:18a:b5c3:55da with SMTP id y20-20020a056a203d1400b0018ab5c355damr16981211pzi.10.1701119398568; Mon, 27 Nov 2023 13:09:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701119398; cv=none; d=google.com; s=arc-20160816; b=U8QV0X6StD8MbnsWkExR4CG09jw+PFj7qkeYTmZQqR+bl/fQ+myclH2LXI2bJdj0OT pYvVJv9+IXKbquX+UAIXPet85dW271Y8MGd4JAAx2Wwrq5CpXvuYVnWuXHHMmVVw/kZE ZeEFXDI3ukgTfRusSBVpWhKC9JtmfZVLktrq6v5MaYfUKGn8kGA8jaTqXGoO8nTMuDqV YwyhP5Kk0PE2w8owaLwG+/WYD4k/iXJmzeLJjExNqNquwOgq/ZjnVTUibf3XaR4P9dK2 jneY1zdQ86MvnLXIxD8FZIrofixFKLFbjGEIGbP5fI8dWjSo4GilrDs74qRbjgyjejEo 6yOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ICyqQSR4Qf/fV6d0XlPsyjWKFGZ6Ed6LXacTsr4XCWo=; fh=oZJxQH8gSkaluqj+7p/nynzeTN8cvBlKkB5wPpLuo2Q=; b=eehUCTVZjIAZqP2xUvsKiHlVbVDd3nJ9AyCpU5oEcOMDwynTeU7kDapjFqY61C6JO/ TiyZPVu4nHQ8//f5RWIEcQ65vtGi8qPK4Dk/BPT7IWzCeutvGujNKsDnzpqKG6KfneDP 8xV8ZKyoOdCLUh2yaTYbWMfdccxqJYWr9u1LkhI+h//OWquBuMzYo5S+ZxwU6uTkaqiR MJlgZiZ6Tsf+8WmSx/LbxsKTFkaYwvwwgvYAWxcbAOb1dPM6PcoNlJcclEdey1JwwdtY RZSfNCFgsyCtiDRGNPy5/N6V5n+WCxmR9zFydTbmw5D+3l6vofQdLTWW54TgQI3134h5 lEBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eu2JitOy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id 125-20020a630083000000b0057828b85afdsi10192457pga.795.2023.11.27.13.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 13:09:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eu2JitOy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 011BB8069932; Mon, 27 Nov 2023 13:09:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233005AbjK0VJj (ORCPT + 99 others); Mon, 27 Nov 2023 16:09:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231880AbjK0VJi (ORCPT ); Mon, 27 Nov 2023 16:09:38 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96CBC1B1 for ; Mon, 27 Nov 2023 13:09:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701119383; x=1732655383; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=10W0PaqCPrznnGcNMkRCZKFtSsqKmFSoUVQNEMqT+QM=; b=eu2JitOyNneSwDuhqF7aXoldqWZ3oUAJhiBKUrs/oIM6jSzTY30mSLDV 4cM/pjzfr2agi0rMp8XCeeDtglRaAKi/ddvTLYlJ8n/JGeewxbuawAFpj gXGlguO+1QOiZULK6A9nIVKz6eijGG78xaxpKXoQmLJ4GYngZogLYHHqx vhZvm6ZuLRsKoH6EBWHGOIJBg2U0I/YXiasUP8t+PWn/g/W2rukoTLill 24xMDBJtQf9AjaJXkub7qIKJnKjxtCXZAO64Rk7qV1QP57qhfCTvTEi4y 3nz/pwuAzsnqx88tiND7RVxd29FXjBW9yScccmqKrkkOZZazsmuukCYhp g==; X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="423939907" X-IronPort-AV: E=Sophos;i="6.04,231,1695711600"; d="scan'208";a="423939907" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 13:09:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="886176561" X-IronPort-AV: E=Sophos;i="6.04,231,1695711600"; d="scan'208";a="886176561" Received: from linux.intel.com ([10.54.29.200]) by fmsmga002.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 13:09:43 -0800 Received: from [10.209.158.65] (kliang2-mobl1.ccr.corp.intel.com [10.209.158.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 1FC32580AA7; Mon, 27 Nov 2023 13:09:42 -0800 (PST) Message-ID: <04967d96-cc03-4751-91f2-9f1ff80c6860@linux.intel.com> Date: Mon, 27 Nov 2023 16:09:40 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 0/2] Fix NULL pointer dereference issue during discovering UPI topology Content-Language: en-US To: alexander.antonov@linux.intel.com, peterz@infradead.org, linux-kernel@vger.kernel.org Cc: kyle.meyer@hpe.com, alexey.v.bayduraev@linux.intel.com References: <20231127185246.2371939-1-alexander.antonov@linux.intel.com> From: "Liang, Kan" In-Reply-To: <20231127185246.2371939-1-alexander.antonov@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Mon, 27 Nov 2023 13:09:56 -0800 (PST) On 2023-11-27 1:52 p.m., alexander.antonov@linux.intel.com wrote: > From: Alexander Antonov > > The NULL dereference happens inside upi_fill_topology() procedure in > case of disabling one of the sockets on the system. > > For example, if you disable the 2nd socket on a 4-socket system then > uncore_max_dies() returns 3 and inside pmu_alloc_topology() memory will > be allocated only for 3 sockets and stored in type->topology. > In discover_upi_topology() memory is accessed by socket id from CPUNODEID > registers which contain physical ids (from 0 to 3) and on the line: > >     upi = &type->topology[nid][idx]; > > out-of-bound access will happen and the 'upi' pointer will be passed to > upi_fill_topology() where it will be dereferenced. > > To avoid this issue update the code to convert physical socket id to > logical socket id in discover_upi_topology() before accessing memory. > > Changed in v2: > 1. Factor out topology_gidnid_map() with common code for GIDNIDMAP procedure > > Alexander Antonov (2): > perf/x86/intel/uncore: Fix NULL pointer dereference issue in > upi_fill_topology() > perf/x86/intel/uncore: Factor out topology_gidnid_map() Reviewed-by: Kan Liang Thanks, Kan > > arch/x86/events/intel/uncore_snbep.c | 71 ++++++++++++++++------------ > 1 file changed, 40 insertions(+), 31 deletions(-) >