Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp247891yba; Mon, 20 May 2019 08:05:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLE728bwKTln/q1H7Lk8xdMYRg3TZfB/foVM7vCUJ5KGpI3nQDAcSFV9y0Ngq3IlsPtFbB X-Received: by 2002:a63:3182:: with SMTP id x124mr74791204pgx.364.1558364737019; Mon, 20 May 2019 08:05:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558364737; cv=none; d=google.com; s=arc-20160816; b=TUxo1xUcEpYSESrqgGUqmYFmrPX5UbWlZgLIRhSATajla1448YANRiapa1ZRgaEEcO SpLAi8+fciwVQ4rCHze5mThaKGBMlvwXgTPuoaph5DsRUcoVt4ZKOkJkHhBcsgOnHdRE 8JVLT363B1yJBEO0lpEpXnT3AX7nGBGHRYvo1nDCx9uQHpSCr/8jw0niRf+A+A9YLVL5 pvgeCCXY3sw4JIwfxAWn1yMK5WuC7zC4/yALlyTM2uB+lc0dGsIDz6wsyTBRtrOFfLMp GZYZdsr4IkRdJ+SvI+ZrjBFSFdw+Edwr4jqzIYvrM0Ik8IqUGhdEyMXpvy3Bmyw0z98C 7C5A== 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=Q7e/tzuMaFyt3iK7HEy1mm7hKgpOGI4bLYPorKBYH+Y=; b=GkOfoPlyAREaJOVJ5rWZbm6xQwtoU9xbVRiFv+FxJZlplhr4Dr6RVAJOFgsgi5jz6z OrkrpSbypZ/+XTEZzIY/BPBm4zOE/G1NPV12u1Ub9ocwp6Tr5VTWPbPsn3zbfn4JpdPb dyV62hwDp+NUj4+P+95yc36cj2D8LG5m5NrSxugEZ4a66rhwxwNs7X7PNs6aISKHYGQ8 5zhp7QMyEIa5tTCISRHPWOt57hgEVFp88ovYBUw/5yyaiww9mjqHFKCvoBSXuuP05Z8R HyB+mEHz+nJu5GznozhLGArWLq5K4eORWBAwrzPofXiAfb8ezmWYLXZBdFUc2tnnwGji VR7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g+DtfhtP; 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 w16si7841821plq.141.2019.05.20.08.05.21; Mon, 20 May 2019 08:05:37 -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=g+DtfhtP; 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 S2388040AbfETMUq (ORCPT + 99 others); Mon, 20 May 2019 08:20:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:34164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387414AbfETMUm (ORCPT ); Mon, 20 May 2019 08:20:42 -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 8909B21707; Mon, 20 May 2019 12:20:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558354842; bh=4s/pIXABEDSZVoKp7kapNJZleYdXNZPVMKYkWaXO+R4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g+DtfhtP5YHgTo94b/OfyHgsxyAI5lxfYo/FvVfzE81xoiGYAQGSMv3V8SSRd5TK1 6oto9gVJN/NF3HOblmTRJ6K7ib8SJbRHN/zCutXhvOFPuN5sNmYVJpBe0Ex0URR7na JTeKBskv8Q1pDKqCQK1Zuoj4DZOll2cQuDgpVVwk= 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.14 13/63] arm64: compat: Reduce address limit Date: Mon, 20 May 2019 14:13:52 +0200 Message-Id: <20190520115232.626804299@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115231.137981521@linuxfoundation.org> References: <20190520115231.137981521@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 @@ -49,7 +49,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) ? \