From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7E61C4332F for ; Sun, 2 Oct 2022 00:23:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D5DF6B0073; Sat, 1 Oct 2022 20:23:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6AD978D0003; Sat, 1 Oct 2022 20:23:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FE236B0075; Sat, 1 Oct 2022 20:23:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 421096B0073 for ; Sat, 1 Oct 2022 20:23:33 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F0F06C038A for ; Sun, 2 Oct 2022 00:23:32 +0000 (UTC) X-FDA: 79974110664.27.2C9CE1B Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf19.hostedemail.com (Postfix) with ESMTP id 4FCDE1A000D for ; Sun, 2 Oct 2022 00:23:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664670212; x=1696206212; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LtFIt5FTKyNGfjeUxeseV6vRVd/REofNRZov49L9ZaM=; b=kif2ZEiKGs7rUmcqLpIMiWE0DvB0S31ASgUrYjvhfj4S64fW6m28lty9 8D/UtccRlsMAna/aiBM8xB3HAHVZ5GdoGNwSa7L8dix9tpnlP3zGgQy/e EgixPefzQw7K8zULBgjeGNhQd0LFWxpleFRCWtCvZIUr0MxTJD5r2tsbN QGnZ5anhCAGqukpcPb2XW+x2tX/wZRmsOIHCfrIvE9U5BOz6FmF6qpM/W FwJyO7cxyDZC9NfTef/2ACma0rykrlqC4GXXk2tz3OXmX/GkteZEX8BEh rMoWEiz3Uw1lepoBA+jrm7eSUm1a05HWGACZGI/TxLJ897V3+rqZzuXd0 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10487"; a="303336307" X-IronPort-AV: E=Sophos;i="5.93,361,1654585200"; d="scan'208";a="303336307" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664670212; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Xj6V+c3LASn12cdkhFeN+XK3j+6kzYSw+TcgxWQJNMA=; b=hJCQ3nss4cpugX3YTE/O1IwQ+ZZVJSEp+e1b4VfpoObIBsZ1kTCaKggEKk7ob9MDSezT1m jjIh5UAjTm1RavIasbGG2NJvbwBaZISZ21bct4V9SWkvB4WuDN1kZJzjlLWFwfIfHh/2sP L72Q10pDr5KMUf31EhoVZhJCAQKD+Y8= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=kif2ZEiK; spf=pass (imf19.hostedemail.com: domain of ira.weiny@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=ira.weiny@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664670212; a=rsa-sha256; cv=none; b=gjGSp5m80kpNgrAsnK5IV9m3WflIPC15n7+MCuWRnzXiixiPtxqWk0PNE2rLWA6DDFzmpI +/ycRyfhSieD8t5+d/Z4g+EYcwyWbXblko6nOP91x/iFMVVjrGttGgAWJZRhvhodNDafv+ gNwtLfSfUbj72weOHQDPRt4DBu5VHuA= X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4FCDE1A000D Authentication-Results: imf19.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=kif2ZEiK; spf=pass (imf19.hostedemail.com: domain of ira.weiny@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=ira.weiny@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Stat-Signature: 1ntmp71fo3w8dgnwkjzt4wk5cdggczk4 X-HE-Tag: 1664670212-958820 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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