Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp11088ybm; Mon, 20 May 2019 10:58:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNqqG69uepexbvqNvc5d30jtpKoVRwvx6lL2dB78pTcvQ/ixj2CL/Wr0D0Leqh51gFzR7R X-Received: by 2002:a17:902:e683:: with SMTP id cn3mr54447135plb.86.1558375120907; Mon, 20 May 2019 10:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558375120; cv=none; d=google.com; s=arc-20160816; b=lYTlAZepRchE4ZfOWR2BMB9DJ3lNhgXPMKFHbekZf83AO52zKABaRgXhyhA3pT4A2X s8H3a6wqCT6fM+LHLIEEMz8SlhpxgwvyzeeCHaERzPiCdiMMk0hAHebGG8BM8LJYrDCe 6C21U2ckAmZjx+iuu1WEj3U7Dkw3KL+LRFOk35V85fAXQ4zHuMgqvBcurx6/0UzBY7PY l5QBa6yFeUNu1a+XfRPxUYwhrGJP7PeWGJjvYaX8LdMMcht3OUaXv3ZN5BIDEQvWyPo2 x6ZekzMbh+YX24SVE/p7IaWBIlTbIWBd2KUQ2nwv62TmHPTsJxBJ4o+AU44T0oS+vrf1 3Ymw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5ECSdodkhbb5phnkERd4HmNTvDHRI8l2AlzofojtGJA=; b=EDH8Z4/GGkF46+MJROJ3ALTLMEFJ2r0k2o7v0laIMcciuNKxuSlUrvOwfrq3moXLOt CV8dBNuLz9oO2Rl+f+TJhzwCghpegITqQ/RovhqMWwiH3GRg0PTXbn9ZfCcUUrYXkw8d G5bkHIN8+8Ka2ekQ5pWbqZqRjWW/dUYUJv6bxJ/BW29Da8b3nrQhSWdF7JldJWdvHjcc HZ21o5zKDQ6KApxM+MWt6DshdEN3XIo4UsuOyy3vhvj09t/SAHBYBBnsRf5lBvMcbRoA pPWDcwjCT/V9GR2ub5KVsnqHQ+BS1/ifVvpnKrKxTwwt70UHklLXsE4wqvrsW0D5ud7r 5icA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sh++2JhD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t63si18225963pgd.452.2019.05.20.10.58.26; Mon, 20 May 2019 10:58:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sh++2JhD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388151AbfETMtv (ORCPT + 99 others); Mon, 20 May 2019 08:49:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:34926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388135AbfETMVU (ORCPT ); Mon, 20 May 2019 08:21:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3946720815; Mon, 20 May 2019 12:21:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558354879; bh=e+Q5MT/71K3kY9Issi2bifEyQX5Pilz9dahAzmliD3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sh++2JhDuEzjJ2GJcKpbRTb9bQA4fXpLJyZvvYPus31LAvr+g818QKza4pZtSBEwf IstfxwwF23s0TFRqTAoQmLI0FeL9hjmK5JQCiEo/V9AefLGI4tQnlCJ0RiWtW4afiH qZR1QGv8PKMfxisibuBfC5yE7zcfF/G+k4Om/Ixo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Catalin Marinas , Will Deacon , Jann Horn , Vincenzo Frascino Subject: [PATCH 4.19 014/105] arm64: compat: Reduce address limit Date: Mon, 20 May 2019 14:13:20 +0200 Message-Id: <20190520115248.018429464@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115247.060821231@linuxfoundation.org> References: <20190520115247.060821231@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincenzo Frascino commit d263119387de9975d2acba1dfd3392f7c5979c18 upstream. Currently, compat tasks running on arm64 can allocate memory up to TASK_SIZE_32 (UL(0x100000000)). This means that mmap() allocations, if we treat them as returning an array, are not compliant with the sections 6.5.8 of the C standard (C99) which states that: "If the expression P points to an element of an array object and the expression Q points to the last element of the same array object, the pointer expression Q+1 compares greater than P". Redefine TASK_SIZE_32 to address the issue. Cc: Catalin Marinas Cc: Will Deacon Cc: Jann Horn Cc: Reported-by: Jann Horn Signed-off-by: Vincenzo Frascino [will: fixed typo in comment] Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/processor.h | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -53,7 +53,15 @@ * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area. */ #ifdef CONFIG_COMPAT +#ifdef CONFIG_ARM64_64K_PAGES +/* + * With CONFIG_ARM64_64K_PAGES enabled, the last page is occupied + * by the compat vectors page. + */ #define TASK_SIZE_32 UL(0x100000000) +#else +#define TASK_SIZE_32 (UL(0x100000000) - PAGE_SIZE) +#endif /* CONFIG_ARM64_64K_PAGES */ #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ TASK_SIZE_32 : TASK_SIZE_64) #define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk, TIF_32BIT) ? \