From patchwork Tue Dec 21 07:06:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Gordeev X-Patchwork-Id: 12696953 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B960CC433EF for ; Tue, 21 Dec 2021 07:08:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=IZJR/tQpBZyVrR/DoKEx7hYlwmsXyvLo02Ic0+wsp+8=; b=2ELiWspefzQ5IE fEtmK8XA0FdjvxuECVRsx9CF7hTYLAB+D5SRrz3ObTfN7Ktvej0ErJM2/M+d2hHCIkjKPD8dY7wlA 6LO5Qac0NYUxHIyJ6BgQl0oUV2wcEJk7CSaks6sQjRpwqHb8y6twYJfkRx4btSr97tzPkdBEvwKIn U6SgQKOR1a+G+k8WtIAGcsHNIPckYkRWwH54QLAmMmSXTjxoXS4QR07DWR8oeFYPCXCHruwFEFZRT LHzAQIbHaNZpTkuka9dXdSaZn8JjXnfWPtWocoi2XW5z/Tr1sidThM2bfFaJcUKXRil9Lvn9V/LH5 9Qn9JJAzn/jeBs96Ngtw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzZEU-005iNa-4o; Tue, 21 Dec 2021 07:06:46 +0000 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzZEQ-005iNG-8x for linux-arm-kernel@lists.infradead.org; Tue, 21 Dec 2021 07:06:45 +0000 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1BL5xuvC032611; Tue, 21 Dec 2021 07:06:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=+FzhdU8s+H6f8OYVqx0rwO0AUCZKk5PGUnwZ8gKaqck=; b=pIsfjXYVwjl/zgkWFOQ9xC/fCjGtuOwzRZdC7xIlHDJtyzRHutn01+SQLbRwiKTW24xm Wk8adOVEdoReJ4fhZpPZd8xGtNXmy0MuZVhHXXCTjp335s9BJB0ROULmr8SluBpTh2St FnjGPpNsR360rFY3lTZZdtyqyQHkpimxMMZAZetVTlQ6VmWZHFu14r9437JZDGO/J8jH 4rnMGAguG93pFWdXKS8yRqL2BvGrAQ3FJc0RFYXVGnuLeFxK42s9v1YdaitXf118FBQ0 97AIScR6x3yMTEfZ1nWPBnrm3SBOs3XGFaq2qYuAhllYKRgiEDik7hOFrJv6r2Zy1W7J tQ== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 3d3990h54n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Dec 2021 07:06:31 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1BL72cBI021010; Tue, 21 Dec 2021 07:06:29 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma04ams.nl.ibm.com with ESMTP id 3d1799jtpr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Dec 2021 07:06:29 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1BL76Q5q43909516 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Dec 2021 07:06:26 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BFCDB5204E; Tue, 21 Dec 2021 07:06:26 +0000 (GMT) Received: from li-4a3a4a4c-28e5-11b2-a85c-a8d192c6f089.ibm.com.com (unknown [9.145.30.13]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 665F852050; Tue, 21 Dec 2021 07:06:26 +0000 (GMT) From: Alexander Gordeev To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Thierry Reding , Arnd Bergmann , Russell King Subject: [PATCH] asm/sections: fix memory object end check Date: Tue, 21 Dec 2021 08:06:24 +0100 Message-Id: <20211221070624.1541842-1-agordeev@linux.ibm.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 673ZBziW4vko3o26ne_5eF7mGHtXdOa1 X-Proofpoint-GUID: 673ZBziW4vko3o26ne_5eF7mGHtXdOa1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-21_02,2021-12-21_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 impostorscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 spamscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112210029 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211220_230642_459393_0FC045A8 X-CRM114-Status: GOOD ( 20.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Function memory_contains() checks whether a memory object is entirely contained within a memory region. The condition that checks the upper bound of the object against the upper bound of the region is inclusive. That does not correspond to the similar checks in memory_intersects() friend function, nor to the actual regions memory_contains() is called against. In particular, __init_end address assumed do not belong to the init section itself. Similarly, on ARM __idmap_text_end and __entry_text_end are affected. Fixes: 979559362516 ("asm/sections: add helpers to check for section data") Cc: Thierry Reding Cc: Arnd Bergmann Cc: Russell King Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Alexander Gordeev --- include/asm-generic/sections.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index 1dfadb2e878d..23f325cd2c66 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -78,7 +78,7 @@ extern __visible const void __nosave_begin, __nosave_end; static inline bool memory_contains(void *begin, void *end, void *virt, size_t size) { - return virt >= begin && virt + size <= end; + return virt >= begin && virt + size < end; } /**