Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1181646rwb; Sat, 1 Oct 2022 17:40:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM42eJfGTHwqcpRujCmMfJzrlO0cDY4vb53P3tVaAP0PwYGhKJr7iCFQ3dxIvTjEvEAQWn4G X-Received: by 2002:a17:903:2683:b0:17c:6ecc:d03 with SMTP id jf3-20020a170903268300b0017c6ecc0d03mr10066764plb.151.1664671211875; Sat, 01 Oct 2022 17:40:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664671211; cv=none; d=google.com; s=arc-20160816; b=HjWBgOdp1Uq+hJHUpKIDiwSadhNfB2X8YdUeXWhC4NCFfA5OV/jZEI2Y3OQEVXtlPE XOOLwllP0R/JYENHrlTbLrO12NuYuKILXH2xaRXqAtdXTPcnDSDZDCkgvahX/jahElaH HXENLxH4STTP4gD59KSFqYnWO1mEOYuNHGUhNOqv1QKJdg4e7ONWXPBwfx/Lf0ASP+tZ Lmg+DLNxfxzWkRcaJuL7riTmhRTBC/KTaGnflRqnP39bgfhJOBAU7s/gL6qqNW9QbTID 1rz503s9u6EAH5oOvTlZDRUn01SCB/XM5zAXrPe05khWKz6eazy1jpWl2Z1x2NUhWUlH tbJA== 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=Xj6V+c3LASn12cdkhFeN+XK3j+6kzYSw+TcgxWQJNMA=; b=MMzILyIK3je83Bpt8fUq1NHhIMYbUNRqUFNREwBO8CV2gNEw9f7s3Kg3sLOzoL5pmL 54E/4IVHhIuNG20HFzXqr91/RiF+pEWSeZ4BPMJ6C5g4WuBZ1NjtP3afTxdcUfrbp640 N9Hn8ye0Wl8L7PrxUGKqWKKy4DDBIfTeLq1yUgnFTlYgDIHSB9qpkyC/zxWjZ0LuF7nS jPD6XlZ4K11piOwMnnu81MZh3MP+E4klcPT2VqdmRmxpHvUY2v+ZNF156lr/IZvQIxV9 8IP1lagElefUDYYRs1uDCk7BEOxsTxLGFpUOx5CYaDblRFXbsKy0wJXMUZ+/3neTlFe6 V1Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=K44iPsYR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a170903231100b0017d9ea99bd8si3339226plh.33.2022.10.01.17.39.59; Sat, 01 Oct 2022 17:40:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=K44iPsYR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbiJBAXe (ORCPT + 99 others); Sat, 1 Oct 2022 20:23:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbiJBAXb (ORCPT ); Sat, 1 Oct 2022 20:23:31 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3975753024 for ; Sat, 1 Oct 2022 17:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664670211; x=1696206211; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LtFIt5FTKyNGfjeUxeseV6vRVd/REofNRZov49L9ZaM=; b=K44iPsYRwI1upZwOhQlaY4wj+HvdFNJHf7Ocmnu06smDL/CgWMO9e23o U1mmnWlg0Bu3UUDN3INYrS2pwcaEBpKauoDTFbF1ZuywXbVtmqCcOp+d5 KWe0qdHQS4EDLrrW/jHN+u+zEbbkjAgeNUlSQUMWq2YBCXVBpRvkqPLpL elheVRYdUUb0+ifPko+3fayw+sDE08HpDqjE+tV83aQ7JmxCIIieVpJIh Pk/GjFFWwqy1FeprAE/8y6lIHLqc4CooI1Ihl/Y6mNgaxGpWsVk+mYKRi PNJF1TeCF74Ec0FBG7zJ0UKh5sf0xVcpJfEJ62716ZAadl4yUJHCZe3iq w==; X-IronPort-AV: E=McAfee;i="6500,9779,10487"; a="285564519" X-IronPort-AV: E=Sophos;i="5.93,361,1654585200"; d="scan'208";a="285564519" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2022 17:23:30 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10487"; a="656347031" X-IronPort-AV: E=Sophos;i="5.93,361,1654585200"; d="scan'208";a="656347031" Received: from iweiny-desk3.amr.corp.intel.com (HELO localhost) ([10.213.181.73]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2022 17:23:30 -0700 From: ira.weiny@intel.com To: Jens Wiklander , Sumit Garg , Andrew Morton Cc: Ira Weiny , Matthew Wilcox , Al Viro , "Fabio M. De Francesco" , Thomas Gleixner , Christoph Hellwig , op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/4] highmem: Enhance is_kmap_addr() to check kmap_local_page() mappings Date: Sat, 1 Oct 2022 17:23:23 -0700 Message-Id: <20221002002326.946620-2-ira.weiny@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221002002326.946620-1-ira.weiny@intel.com> References: <20221002002326.946620-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ira Weiny is_kmap_addr() is only looking at the kmap() address range which may cause check_heap_object() to miss checking an overflow on a kmap_local_page() page. Add a check for the kmap_local_page() address range to is_kmap_addr(). Cc: Matthew Wilcox Cc: Al Viro Cc: "Fabio M. De Francesco" Cc: Thomas Gleixner Cc: Christoph Hellwig Cc: Andrew Morton Signed-off-by: Ira Weiny --- include/linux/highmem-internal.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h index 034b1106d022..5fd5cb58f109 100644 --- a/include/linux/highmem-internal.h +++ b/include/linux/highmem-internal.h @@ -152,7 +152,10 @@ static inline void totalhigh_pages_add(long count) static inline bool is_kmap_addr(const void *x) { unsigned long addr = (unsigned long)x; - return addr >= PKMAP_ADDR(0) && addr < PKMAP_ADDR(LAST_PKMAP); + + return (addr >= PKMAP_ADDR(0) && addr < PKMAP_ADDR(LAST_PKMAP)) || + (addr >= __fix_to_virt(FIX_KMAP_END) && + addr < __fix_to_virt(FIX_KMAP_BEGIN)); } #else /* CONFIG_HIGHMEM */ -- 2.37.2