Received: by 10.213.65.68 with SMTP id h4csp713640imn; Fri, 6 Apr 2018 07:42:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx49tUgOshkUgsiR2Er/qbxqmBDTeZUShN14a8bTi54zfMwcWnejw79QLZor9EQq//OkW0Wcp X-Received: by 2002:a17:902:1e5:: with SMTP id b92-v6mr27346619plb.78.1523025773939; Fri, 06 Apr 2018 07:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523025773; cv=none; d=google.com; s=arc-20160816; b=SlAJFA2MnLcF469BpRKHaYMEd7oz0AIlXjAdH2rCf9pBNWWWqCOM1df60DQyCbvzsg Q9zg4GejckaV/RrPFH0LvAJ9F4KHGgHlCHXEAKzOh/08lTidHABTCpNTGUNlOGrfcxLd g2qsvnhZHyZ2l0EzDipJEaKgOAhAL9+bahTuuMNgD/7HzdSazNYD/TnGUkajiIuPPFoL 640+x2c/lMwaFHgOXxLfh4zm9yTwe4yb0eX2VTMXmEtHuV2FGJwMJ7hX8N6Jff7sPNsA 67uz/q7eSx+fUO4G9uva4Hk2skUzpRy29cKZZDAxLou0fqntpLXIBTvPpyIg7VySt6cL 6tGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=qF/tECtzQPIjRNeMBr10q78jFyAS2n8RNiqXIFMKaWk=; b=PxxmB+C3vauO+G+aDUpN/Io/IS9CMjNbqZfwyHDQ0nJ6A4vxtMJBiyrMoKiN8KZgRQ ME5YjmIhahJ8hxZa1BhCEBUgaX31njwZNlXzpHUwh6NcKf8t4Xt/juIFxa5BvlYyS8cQ 9StIeo+RJmhHwdxa5w0d3Tc5nV7W67oQp8uu92hPvSElrssT6PYGqDwW9C74jrPO9V+m rQWYUZwKTJF2qngbAy2NRKNFiMYQrXBkNHMyqZdWdJq4jadizuzDXwEiU/8YVl8p80e6 cV0tTIHbE18HmPsf5iqcwud8wgWvCUNBcwtMF7YkP0TYdTRL48pedQCKYoEg9JI1K8Um C72Q== ARC-Authentication-Results: i=1; mx.google.com; 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 e9si5010779pgn.17.2018.04.06.07.42.39; Fri, 06 Apr 2018 07:42:53 -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; 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 S1755895AbeDFNeh (ORCPT + 99 others); Fri, 6 Apr 2018 09:34:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58384 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753046AbeDFNed (ORCPT ); Fri, 6 Apr 2018 09:34:33 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 30E29DAC; Fri, 6 Apr 2018 13:34:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Yury Norov , Matthias Kaehlcke , Nick Desaulniers , Will Deacon , Nathan Chancellor Subject: [PATCH 4.9 032/102] arm64: avoid overflow in VA_START and PAGE_OFFSET Date: Fri, 6 Apr 2018 15:23:13 +0200 Message-Id: <20180406084336.133024456@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084331.507038179@linuxfoundation.org> References: <20180406084331.507038179@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nick Desaulniers commit 82cd588052815eb4146f9f7c5347ca5e32c56360 upstream. The bitmask used to define these values produces overflow, as seen by this compiler warning: arch/arm64/kernel/head.S:47:8: warning: integer overflow in preprocessor expression #elif (PAGE_OFFSET & 0x1fffff) != 0 ^~~~~~~~~~~ arch/arm64/include/asm/memory.h:52:46: note: expanded from macro 'PAGE_OFFSET' #define PAGE_OFFSET (UL(0xffffffffffffffff) << (VA_BITS - 1)) ~~~~~~~~~~~~~~~~~~ ^ It would be preferrable to use GENMASK_ULL() instead, but it's not set up to be used from assembly (the UL() macro token pastes UL suffixes when not included in assembly sources). Suggested-by: Ard Biesheuvel Suggested-by: Yury Norov Suggested-by: Matthias Kaehlcke Signed-off-by: Nick Desaulniers Signed-off-by: Will Deacon Cc: Nathan Chancellor Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/memory.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -64,8 +64,10 @@ * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area. */ #define VA_BITS (CONFIG_ARM64_VA_BITS) -#define VA_START (UL(0xffffffffffffffff) << VA_BITS) -#define PAGE_OFFSET (UL(0xffffffffffffffff) << (VA_BITS - 1)) +#define VA_START (UL(0xffffffffffffffff) - \ + (UL(1) << VA_BITS) + 1) +#define PAGE_OFFSET (UL(0xffffffffffffffff) - \ + (UL(1) << (VA_BITS - 1)) + 1) #define KIMAGE_VADDR (MODULES_END) #define MODULES_END (MODULES_VADDR + MODULES_VSIZE) #define MODULES_VADDR (VA_START + KASAN_SHADOW_SIZE)