Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4754640rdb; Fri, 29 Dec 2023 12:10:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfTS2gbsBN+/a5/10d/jzo3LpXCVBjBnmlnsaNzFkiHkmidmklD/AeD9gvbDEFEPx8FXjQ X-Received: by 2002:ac2:410b:0:b0:50e:22bf:a940 with SMTP id b11-20020ac2410b000000b0050e22bfa940mr4465972lfi.93.1703880623326; Fri, 29 Dec 2023 12:10:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703880623; cv=none; d=google.com; s=arc-20160816; b=Ip+2IMrKG+6VWjxn4LUBp1+GbLvGFeS+EfYReWnY3Jaszra84MD9Or6km/zDsqm+h2 oFW4W+02rCmgA6jy/IaVG4g2GQ7Te+DLiOqKm5c10L2oEtfyMLMbf8om6879bmSIK0zV wCdRn5xlC+fQCOaTcAOlY8JJsuMXfId1uMficClRhju9DLf3rdJ7N2mJhrG9HienSnDE xtSciGtQaXkV9h00aUAcDIGoRqDktlr+yTrNLqd7I9UqJizB01/nj2RPoP7060Xgl0QY K0OpJCpJQf9SVnXs2SQG4ynCp+LbsY/2ve+3UbBWn1J5thQhMKP8J0DeQaxF0z2t0oeO QM/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=fnkilBGqspyqnWv1pv6Xg3JY5TWXi5m97rxffVMIwjA=; fh=FcrUb8onHevjjP2UjSoKd8eC1ztOzd/s49WqDZOJzSM=; b=Wf31rzc4X+22l2hin5QUBPi/JHJJjogXLIgN1mAGnbLm91MjNqXXS4hXEHFmh6gfhB Rgpe4OrrYbz0yJOKdDLQjDqCc0lB7o9c+HtHzhZF4/b9WyO6xKlzAjFz+U4vbefvHr40 WiTObMryoOSxxKi0FRkdiaR1XgDk9OMWy8kSVGczaxnFqIxbTvNjM5i0Xq4rAE9qcYIT RlZorcwhD/t5M6C36iUVSa/EdRKpnLh4sMCsSavORyoeRYIAdziHOdKY2JfpgKocg6bE kCZSPbjOoRAYODhCxTyRCxe4IF5eIl/tGA49lXbhipTlkK0OmdPNzAvacSTiGw2f9rIH /eEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=rGlAIj2w; spf=pass (google.com: domain of linux-kernel+bounces-13221-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13221-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m14-20020a170906160e00b00a23365c248dsi7669851ejd.839.2023.12.29.12.10.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 12:10:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13221-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=rGlAIj2w; spf=pass (google.com: domain of linux-kernel+bounces-13221-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13221-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1894F1F22E2A for ; Fri, 29 Dec 2023 20:10:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1045514003; Fri, 29 Dec 2023 20:10:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="rGlAIj2w" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4888213FF1 for ; Fri, 29 Dec 2023 20:10:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EB32C433C8; Fri, 29 Dec 2023 20:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1703880615; bh=nRJweA6alfblDRh8g5qaz56eqzwAOoHvkXgtYYOUkNo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rGlAIj2wbFYkvEoxn4AeYdP5GKwYAAt13/i217HbUQf2vgdpmB7H4ki/UePSuCZyO P5kuYIMwkIatC8cLtfBhQ0gd3LlTnzcf2/gG4Qc0ia5Oh9VeuyGW0/HmHMeVnyPqj3 3VuCOhbnLMPRSrALGrF/FzWDWUHjRXuBSGYAB1X0= Date: Fri, 29 Dec 2023 12:10:14 -0800 From: Andrew Morton To: Yuntao Wang Cc: bhe@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, dyoung@redhat.com, hbathini@linux.ibm.com, hpa@zytor.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, mingo@redhat.com, seanjc@google.com, tglx@linutronix.de, tiwai@suse.de, vgoyal@redhat.com, x86@kernel.org Subject: Re: [PATCH] crash_core: optimize crash_exclude_mem_range() Message-Id: <20231229121014.fd090f8c616a34fbb45f7843@linux-foundation.org> In-Reply-To: <20231219163418.108591-1-ytcoode@gmail.com> References: <20231218092902.9fae480cfcad3874e9e7236f@linux-foundation.org> <20231219163418.108591-1-ytcoode@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 20 Dec 2023 00:34:18 +0800 Yuntao Wang wrote: > Because memory ranges in mem->ranges are stored in ascending order, when we > detect `p_end < start`, we can break the for loop early, as the subsequent > memory ranges must also be outside the range we are looking for. > > Signed-off-by: Yuntao Wang > --- > Hi Andrew, > > Patch "[PATCH 2/2] crash_core: fix out-of-bounds access check in > crash_exclude_mem_range()" can be ignored, use this patch instead. > Some reviewer input on this would be helpful please? > --- a/kernel/crash_core.c > +++ b/kernel/crash_core.c > @@ -575,9 +575,12 @@ int crash_exclude_mem_range(struct crash_mem *mem, > p_start = mstart; > p_end = mend; > > - if (p_start > end || p_end < start) > + if (p_start > end) > continue; > > + if (p_end < start) > + break; > + > /* Truncate any area outside of range */ > if (p_start < start) > p_start = start; > -- > 2.43.0