Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1065122lqj; Mon, 3 Jun 2024 09:08:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+lmCE6Jy+LHuElhhouA7ggtIPnWKqLh4m7mc7MN7lfrDz+NbcOfbQyFEWTnAdCbt1AC4f7ydAcZfLdTzjWys9Y4fGVJ0u8f7NryhIug== X-Google-Smtp-Source: AGHT+IGhmTfhhvZQSRSszV4YcEtDV54XXzOHho+Z3JGIU6AIvLP34yiDPsB/48Jcx8ZJsNHHZe/E X-Received: by 2002:a17:903:2289:b0:1f4:a3a1:a7e9 with SMTP id d9443c01a7336-1f63701f13cmr111603575ad.24.1717430890028; Mon, 03 Jun 2024 09:08:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717430890; cv=pass; d=google.com; s=arc-20160816; b=PPc1RqVYx3ioTqjo68bj5kwsiuvjQ2DZy5kLnwCuGji6+QOgpqHRivG9LLCG7dmUH2 lPedF3NBi+lfHCt2vzgpaICXGs6i5t0AwQ6VP1xt+1MGUUhp0kPfGxujNzFF+VFzINTX JPWSz8bfkI4/boTr5uZt/08uy41Ghzi/V89+uEuQW1ANeb43DF+AQa/4QuyJLJT7M3IU QiF3qwz6RHae8K8/6NzdwA7LNkNYQFLzXZ0zbpLUYb8AJ6WfoYQWiDlpTfJqjHTYWk09 Bjc5ZsKfn1Cxc9dB6uU7eiCDZs/z/hQA8TmaCZ+ic+2VTzedYIwuBQ4w636EhWbmTDcc xxKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=tXPXokhm2bGedsPgz0iJ5Czp96sqvizSxz1KwzeJ7QM=; fh=gyCseKo3WawlldYfIuzM+yc87Q3eRgKrJUddBWmj0yE=; b=YCUt3NbmGtsN6uv6MFVdVlXs13G+VMNYkPDuj6nblTpCiK7OXTG4+B6qf6ALl+oI7l Hp8F3xE09BXknk4xlZUVOSR7m3kYh2mfT07xDsvSGOoGaijAQ6uUTJfP533O9w+bP8Rl XDXgKoy+Xq1erH/g1fCYgssBwLA4rqJ4H47I+hm95Z1eWg6Hk1Ud9F/u+uxVWlZ0BHuZ EaXtA+Nx2W85kQ3H2MHznihdxc6L7wXhqqX7j/v2CSMhGCeNpS/MdCdL2IIk0odqEe6K mmLljTseL7MQQFlw/wZgEqfc4V1xjiz79iknZleryi+Iovaxgw1szMwzbC3wCUoKFWc8 tusQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P2Slb6Tn; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-199415-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199415-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f68b50c211si6336925ad.511.2024.06.03.09.08.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 09:08:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199415-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P2Slb6Tn; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-199415-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199415-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C8B83285F40 for ; Mon, 3 Jun 2024 16:07:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A94F134415; Mon, 3 Jun 2024 16:07:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="P2Slb6Tn" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAC8E134409 for ; Mon, 3 Jun 2024 16:07:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717430870; cv=none; b=G0CpwvGh0auQgGYz7hTrTcElWl1gXVFUA4r7MzoHp1ovd0vuHLnAxC4y4vDitbRUiwEXOvyYNMSTRHfSnkYtUZcmnIGZxdVYotjqxYYyxY9oi1ccZASZMjctN+jwkfmXc0tSeiNnITJzbFWYhDwBanoCCcaEMypv6r1FpgXC5Tk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717430870; c=relaxed/simple; bh=gAkZrmhsWjiuqSjaLWzrSfZcZKDPi/3J/0JelfMP2Nw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=sn5XxP4DgWoNpKrPlG4E5Vyq/CfpYWhjka14mxxxS9lZ1OPNaIySnOH/mVZ2hU1O3upapFHE94fmRETB2g+o/VtmMVDkWOmwg8CHqfFTuSs4JiEmvnpPQRqeEET6DF1eQpVDiVMWq2HX/1l5vnkMmzPSFVR7UfIm1bDBMg+TZtg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=P2Slb6Tn; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717430867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=tXPXokhm2bGedsPgz0iJ5Czp96sqvizSxz1KwzeJ7QM=; b=P2Slb6TnSFccqfeQS1jD2jz5hWzap1cPML9kvxojk12+ZhDGwarXtjWJEMPVBrBuu5RnU0 ELQIMcuOQ8D2PZsQvrYXIFwY86fil5wAOr6F1lPrBwEwSEse4TNINxd/pxVMdY+JkTCkUk LLRn5MHwl37Rqa/As+SwBajZBce77jA= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-4Xi6ZVXiN9iX_gATbYMGQA-1; Mon, 03 Jun 2024 12:07:45 -0400 X-MC-Unique: 4Xi6ZVXiN9iX_gATbYMGQA-1 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2ea91ce9225so29909761fa.3 for ; Mon, 03 Jun 2024 09:07:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717430864; x=1718035664; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=tXPXokhm2bGedsPgz0iJ5Czp96sqvizSxz1KwzeJ7QM=; b=lazUBIQW4mxLNW0O4D3TDoh57wdafM+nB+VFO4ya8/XNxh0oXAfE4zFQZb3jZ+jFJf cDtzeqU2R3qvkpSj1AWVRXSVLyzNHGvnCiWh0sawc5MMZYaP50L8eNnicVq0cAKVfqvp w18oZrloGP9yrSGkCT6pG+xs+Nyb1aOWAQD7w4E0FVbhoU7GHv7vIc9fl8jokzIemiDf P4bhZIK4A/Wl3RaGa7/zmB0SBU7AY96RE9Ux0XuB/Qm6vE/viQOOyUCYX6QJLmxjHvh5 3A8KvAzZXE3a+1BADVC2A9F99o5LMen8O1J4MmP5Kqu1nYPAqyu0+74WO0hsFLxw/ksx emsQ== X-Forwarded-Encrypted: i=1; AJvYcCU/eHmNFgKK18IsKEQI5HSoghaUOjVT6EjeGv1MMifKX08bY6Ise3q5ZO2U33RJhPG/uYauJXiTSzWF3mi0g7rKyiUiL87YYkiqizrF X-Gm-Message-State: AOJu0Yyl246rZ+njuCf9GaHUS4Vg97FkUoB6uwuPh7Q+4VqpDhJ6rieJ pq/NA+1dWBU7vteO8xEZaSqQ7AfKoP8zc9Eo1ZuYzh8Uf8ceQwWPbVCCF9ZgIuUIYQ3u5ZkLhaH WR9LZyF+kE8IbfW8SI2PykSdp33pCjbXAtXM+h5XTDTUiSamRbDSHDIQg69oTOP+oNgyO2g== X-Received: by 2002:a2e:8712:0:b0:2d8:5af9:90c5 with SMTP id 38308e7fff4ca-2ea951de2cemr89657341fa.39.1717430864082; Mon, 03 Jun 2024 09:07:44 -0700 (PDT) X-Received: by 2002:a2e:8712:0:b0:2d8:5af9:90c5 with SMTP id 38308e7fff4ca-2ea951de2cemr89657051fa.39.1717430863553; Mon, 03 Jun 2024 09:07:43 -0700 (PDT) Received: from ?IPV6:2a01:599:908:c963:af9b:c64c:dfd8:5999? ([2a01:599:908:c963:af9b:c64c:dfd8:5999]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ea91b9d678sm12672781fa.24.2024.06.03.09.07.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Jun 2024 09:07:43 -0700 (PDT) Message-ID: <3c2b1b1e-c9b3-442e-8f7b-5c7518d3fbdb@redhat.com> Date: Mon, 3 Jun 2024 18:07:39 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm/memory_hotplug: prevent accessing by index=-1 To: Anastasia Belova Cc: Oscar Salvador , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org References: <20240603112830.7432-1-abelova@astralinux.ru> From: David Hildenbrand Content-Language: en-US Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQ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I7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20240603112830.7432-1-abelova@astralinux.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 03.06.24 13:28, Anastasia Belova wrote: > nid may be equal to NUMA_NO_NODE=-1. Prevent accessing node_data > array by invalid index with check for nid. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: e83a437faa62 ("mm/memory_hotplug: introduce "auto-movable" online policy") > Signed-off-by: Anastasia Belova > --- > mm/memory_hotplug.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 431b1f6753c0..bb98ee8fe698 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -846,7 +846,7 @@ static bool auto_movable_can_online_movable(int nid, struct memory_group *group, > unsigned long kernel_early_pages, movable_pages; > struct auto_movable_group_stats group_stats = {}; > struct auto_movable_stats stats = {}; > - pg_data_t *pgdat = NODE_DATA(nid); > + pg_data_t *pgdat = (nid != NUMA_NO_NODE) ? NODE_DATA(nid) : NULL; > struct zone *zone; > int i; pgdat is never dereferenced when "nid == NUMA_NO_NODE". NODE_DATA is defined as arch/arm64/include/asm/mmzone.h:#define NODE_DATA(nid) (node_data[(nid)]) arch/loongarch/include/asm/mmzone.h:#define NODE_DATA(nid) (node_data[(nid)]) arch/mips/include/asm/mach-ip27/mmzone.h:#define NODE_DATA(n) (&__node_data[(n)]->pglist) arch/mips/include/asm/mach-loongson64/mmzone.h:#define NODE_DATA(n) (__node_data[n]) arch/powerpc/include/asm/mmzone.h:#define NODE_DATA(nid) (node_data[nid]) arch/riscv/include/asm/mmzone.h:#define NODE_DATA(nid) (node_data[(nid)]) arch/s390/include/asm/mmzone.h:#define NODE_DATA(nid) (node_data[nid]) arch/sh/include/asm/mmzone.h:#define NODE_DATA(nid) (node_data[nid]) arch/sparc/include/asm/mmzone.h:#define NODE_DATA(nid) (node_data[nid]) arch/x86/include/asm/mmzone_32.h:#define NODE_DATA(nid) (node_data[nid]) arch/x86/include/asm/mmzone_64.h:#define NODE_DATA(nid) (node_data[nid]) Regarding architectures that's actually support memory hotplug, this is pure pointer arithmetic. (it is for mips as well, just less obvious) So how is that a real problem? Do we have a reproducer? -- Cheers, David / dhildenb