Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751956AbdHCRxO (ORCPT ); Thu, 3 Aug 2017 13:53:14 -0400 Received: from mail-qk0-f180.google.com ([209.85.220.180]:36734 "EHLO mail-qk0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751241AbdHCRxN (ORCPT ); Thu, 3 Aug 2017 13:53:13 -0400 MIME-Version: 1.0 In-Reply-To: References: <20170803132035.gixd7m7oxtehpquu@yury-thinkpad> <20170803171117.107992-1-ndesaulniers@google.com> From: Nick Desaulniers Date: Thu, 3 Aug 2017 10:53:12 -0700 Message-ID: Subject: Re: [PATCH] arm64: avoid overflow in VA_START and PAGE_OFFSET To: Ard Biesheuvel Cc: zijun_hu , Andrew Morton , Greg Hackmann , Doug Anderson , Stephen Hines , Pirama Arumuga Nainar , Catalin Marinas , Will Deacon , Mark Rutland , Laura Abbott , Oleksandr Andrushchenko , Alexander Popov , Neeraj Upadhyay , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 527 Lines: 19 > Would > > #define VA_START (UL(0xffffffffffffffff) - (1 << VA_BITS) + 1) > > also work? I think you'd have to wrap the 1 in a UL(), ex: #define VA_START (UL(0xffffffffffffffff) - (UL(1) << VA_BITS) + 1) Otherwise IIUC a integral literal (`1`) is treated as an int, which on arm64 is LP64 making it 32b, where most configs set VA_BITS to larger than 32b. Shifting by more than the width is undefined behavior. And without it, I get compile errors. I'll send v2 with your suggestion, thanks. -- Thanks, ~Nick Desaulniers