Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp57148imu; Tue, 27 Nov 2018 08:59:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/UwkTFbBTig2jm/5/X31/V3tHIKKmvhKP9I51dplsw2lTXpf5tnvAZctMX/8zW98KCm0xxo X-Received: by 2002:a17:902:8c91:: with SMTP id t17mr32194943plo.119.1543337998020; Tue, 27 Nov 2018 08:59:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543337997; cv=none; d=google.com; s=arc-20160816; b=X29teB83b6Ppe6pSoLLos1lXiXbC7daJVw6s1W4++NhSqaSpIwAncHcH4MOPEIgQ3d OxcY0Nd4uUpDc+KFJ7XqZDk2h7r+iu/b5zyRam+W+lxlYtBEF2qlwICuVDIqVPVXCQuw rQYMBByZXwHPa6xZo2aUWVBylUdjfA9QB2vTRoPRguOTnk3O1xGK/3yfpazpSQlghrgm e46oBV5EslBoQ0APolOUEsUGopFGpwCKIYRKt4jCrKmeL+AylGqVIK1p4whPbRlD2lX4 PGt1Uvh0rx/ujHgee4AXlSOBsJ7pcH3jbppGhRqV42Hi2ypLlBo/tAQ59E767Ag7Hlxa 4Uvw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6e1l9Y/ECE5gJLR0cHfFtNGEhOKinaqvIQUjwSbnIxA=; b=y4JEMCUhhgfXM+/ij0MQ+D0IOHqJXBjldU/Xf/ZCBHG2PBTXnQIL9ZkX9Var+ket8R huEcO1Jeg+7W46XzHGzfAsMLZxFGZo6NblbtXo72NffAW6jyeD/7rH8ThZAYw/ivXAah z87fyjsOnAS1ASdDunnDHdGm6yrh25jOdn/aYVN4sUX+dbFjHmf20hd/ACZRRusZTZSk mi/bY+NtRDeGw7vlEVKMHALeFJhlEFCVgom4ZxALJ6WjoGwn08DpslG352Sy8/PIrWCh nCE/bNgme9Q2nyVAJa1puwl/6S5HKL4ZA84eqLEPjttobCh+VLOshwKQQ1zDBW37xGLJ lStA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=c7RLbeCB; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si3952160pgv.456.2018.11.27.08.59.42; Tue, 27 Nov 2018 08:59:57 -0800 (PST) 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=@google.com header.s=20161025 header.b=c7RLbeCB; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731910AbeK1D4e (ORCPT + 99 others); Tue, 27 Nov 2018 22:56:34 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45361 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731634AbeK1Dyh (ORCPT ); Tue, 27 Nov 2018 22:54:37 -0500 Received: by mail-wr1-f67.google.com with SMTP id v6so23430442wrr.12 for ; Tue, 27 Nov 2018 08:56:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6e1l9Y/ECE5gJLR0cHfFtNGEhOKinaqvIQUjwSbnIxA=; b=c7RLbeCBSVZ4Kt6XmRk41o0eRiADDbVObnmQOr8RuKkIYie1CCJ4fYq8kfj9AfajBv OBvv316qqeqXWjU+4grgAXMDTb6uhS5R6mR7OXy5YlGkW6IH0gS0+aVi0WFb16P7E03z C9Mq+XCW4ZYUNS6UaPDcu9pBuiFLIKyA94mcuUhjZjhUXihex0N5TWIkfeVY82bcQLdr HnqZUKZa05tov8/OoSNckF7DsE/hTRTiN3nnqkdkfHNTjS9r2E1LQsQBFGxVT7sHi56N GABTW4X86jJYnMHRjmDPORCZC1aM5Kpaj34BLZGfRVchAXfgDVsAjf47zSHA1CHobvdE vn/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6e1l9Y/ECE5gJLR0cHfFtNGEhOKinaqvIQUjwSbnIxA=; b=Lu3MHJMGx9kSLuVLXtoIyo0DLwVT29+ZnaEJDrLQNadNlPntgo650jMaC2DG/kks2N OktFF+qLyUe1GsLFlnUIJT6eHhEkh/uEh6fRgYSOqrpMt/YA8FS6suO9FPiqRXiYSQij aWsUVhl8XHEf8QDv2F/WLdA83V8lzpukEhYkeZmuYmmSd5ZgCjinutYsK85nautvR2/6 ca3SCjzHzk+WWdIxptCSfWB6RqDQfz+qkYZETc9zJF9xNHgW2jpgvWffCad5tquax5kk azOUApqHSS0vG002BY7yMHn7tApDpuzEQd2yohuB5mRjZ/7SIRUbSYI5eXvTTcsV77ZA EMaQ== X-Gm-Message-State: AA+aEWYPRRBNPti8Sx29JczP062wfJteey96eRZJk90sKGcGwYB9t4t0 7mMxi1q9DDii+LHlsmwxxGeI7g== X-Received: by 2002:adf:9d4c:: with SMTP id o12mr2491101wre.94.1543337765359; Tue, 27 Nov 2018 08:56:05 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id k73sm6383099wmd.36.2018.11.27.08.56.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Nov 2018 08:56:04 -0800 (PST) From: Andrey Konovalov To: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Catalin Marinas , Will Deacon , Christoph Lameter , Andrew Morton , Mark Rutland , Nick Desaulniers , Marc Zyngier , Dave Martin , Ard Biesheuvel , "Eric W . Biederman" , Ingo Molnar , Paul Lawrence , Geert Uytterhoeven , Arnd Bergmann , "Kirill A . Shutemov" , Greg Kroah-Hartman , Kate Stewart , Mike Rapoport , kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sparse@vger.kernel.org, linux-mm@kvack.org, linux-kbuild@vger.kernel.org Cc: Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Jann Horn , Mark Brand , Chintan Pandya , Vishwath Mohan , Andrey Konovalov Subject: [PATCH v12 09/25] arm64: move untagged_addr macro from uaccess.h to memory.h Date: Tue, 27 Nov 2018 17:55:27 +0100 Message-Id: <432ef6686a25b49244f54c4dfd86bc4b20381d8a.1543337629.git.andreyknvl@google.com> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the untagged_addr() macro from arch/arm64/include/asm/uaccess.h to arch/arm64/include/asm/memory.h to be later reused by KASAN. Also make the untagged_addr() macro accept all kinds of address types (void *, unsigned long, etc.). This allows not to specify type casts in each place where the macro is used. This is done by using __typeof__. Acked-by: Mark Rutland Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/memory.h | 8 ++++++++ arch/arm64/include/asm/uaccess.h | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 05fbc7ffcd31..e2c9857157f2 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -211,6 +211,14 @@ static inline unsigned long kaslr_offset(void) */ #define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT) +/* + * When dealing with data aborts, watchpoints, or instruction traps we may end + * up with a tagged userland pointer. Clear the tag to get a sane pointer to + * pass on to access_ok(), for instance. + */ +#define untagged_addr(addr) \ + ((__typeof__(addr))sign_extend64((u64)(addr), 55)) + /* * Physical vs virtual RAM address space conversion. These are * private definitions which should NOT be used outside memory.h diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 07c34087bd5e..281a1e47263d 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -96,13 +96,6 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si return ret; } -/* - * When dealing with data aborts, watchpoints, or instruction traps we may end - * up with a tagged userland pointer. Clear the tag to get a sane pointer to - * pass on to access_ok(), for instance. - */ -#define untagged_addr(addr) sign_extend64(addr, 55) - #define access_ok(type, addr, size) __range_ok(addr, size) #define user_addr_max get_fs -- 2.20.0.rc0.387.gc7a69e6b6c-goog