From patchwork Thu Aug 30 11:41:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10581511 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B3603139B for ; Thu, 30 Aug 2018 11:41:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A171B2BA60 for ; Thu, 30 Aug 2018 11:41:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92A0C2BA68; Thu, 30 Aug 2018 11:41:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 378552BA60 for ; Thu, 30 Aug 2018 11:41:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B45756B5133; Thu, 30 Aug 2018 07:41:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A2CF06B5134; Thu, 30 Aug 2018 07:41:24 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A6A36B5135; Thu, 30 Aug 2018 07:41:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id 2BA9F6B5134 for ; Thu, 30 Aug 2018 07:41:24 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id 40-v6so5604872wrb.23 for ; Thu, 30 Aug 2018 04:41:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=83X0Ly3GNFYkIBH/BFHbUkVhejW7zXmTm47ETsZa+AI=; b=NlC1zSveEaIvjWRuqxW7UidWvFE9SW50De/sH+POlbybmOHSLjhkY+NOW/wHETSCgK GbjQySc7C6bL3w81UOtBBgF51dmpV2inp4oqyWQU7kK0rk3PKTxhh0G1E2s6KIA/ECPm r0zl/XGw29sg1zlPxN9fKTrZVTUF30HH78vwIF7zINuqLZ/Hq2Tdhi+reESzDk65xgiz IwVPO0g0iNlvsP1YdCzBd0byX1JkULUBpXlWrqdSTWSV6QPQPCjTusTpVRfHkRkLwzlq ySyDKECg/wKm3+0eQf9Dkln4o23Xa7Zj2wpTMPBLN05Q5dbrvWyH+NvjPDwWX4udmtDA dptQ== X-Gm-Message-State: APzg51C2TPY00M/42wf+4fCMrxeOPDGTLfYzewviOxwQTMYzrSQGPHnM XOXdp4VYoeoRkOqadD+2oWFvXfC0GdQ4UEWcRqsAEwnRRm4Tw0QpShylS3WvPtqUvwdw6V3RYZR smno8Nep9/XivRWDnIpHMjmJ4DT/1f+u90ica3tgSklsHiNvSFvHIhJqN0HLjbQT1/bC7lPBdkA DXmcwhYc68pJsOh1M4BNh8gZSSoV2bF6m7jWMUUWHcckPW2fkRWW2uyFgub1I1NUG/Dax7SxW6h cNCWkI9+L3SSE37KQlu3bLzR6bFJ0qpnr674cx/slgS0FCrY0vkLe2eWdgjoiOZ8BT/2DBdCzFB /THRT7AHaJosp9rHQdTqgk0C7DyIlVZ+cqjo9jkMeJhHANBwaWYMozOzf6Dq+w8WXz+6nvY/K1B 4 X-Received: by 2002:adf:9464:: with SMTP id 91-v6mr7051346wrq.231.1535629283673; Thu, 30 Aug 2018 04:41:23 -0700 (PDT) X-Received: by 2002:adf:9464:: with SMTP id 91-v6mr7051314wrq.231.1535629282922; Thu, 30 Aug 2018 04:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629282; cv=none; d=google.com; s=arc-20160816; b=fXQYIl3VOBmb0BooP+SZf0ZR+3PFBCfZWgG2rhPf4TkmPUf55MzLUApeJWQtyqRifs PMFn3rDgrWPpeXEQWgLr5vTr6oLLddYIS3dnVCUxnuU+wwoC6b26RphoNo5m9tNZv1BI WLNWtx6P9MiZ66Irz9HXUFJQl/4Ri2W9wtTfKJ0lMNedTyuMJRe6pVUWMaVxk4EWiD0d +gwm82Go7WNuV/g04LAZmirsbi+06irkkCN3TzD6lGiev9lalcI4Q7ap1eiKOnSqR9lR AA41yRgg1Jjk0ZKxq4FyIK6NicBAUUKWbdUf/TIX9G20F33K2Xh+eGjTJN29nmrCwS68 kVfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=83X0Ly3GNFYkIBH/BFHbUkVhejW7zXmTm47ETsZa+AI=; b=XNYXv79vZp1fkj+DmU1lJgiXQScQsEVBB+dD11O/s/oDNb0LOFgckxlqISgDEuBZbj finCJ+YNhyfUyxEaruFQhOZgaoUL2c2Xy9XJWAICMjGPNM0fubCPRt1j+kP48BDczZ/J QuZi/AYF5WJwaPY4ROp6KmaShvQFk4aa+nJAi/TOWEm/BvoLOwx1x3CZaMkwKDtVJUR4 a33+3Wi5rX58byuNySlVXwsq/vYc1JZnHrCDdlo/retSS6YSR5aKwb8v26GbnXql8c9e k2RjCvMv0+rjb+po34cj14M8m8zXWSZE/oQ0uIZHVpiqQtd1XceqWEdp66DkKmTn1djc FGTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=K+wpn7aJ; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 143-v6sor53688wmb.14.2018.08.30.04.41.22 for (Google Transport Security); Thu, 30 Aug 2018 04:41:22 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=K+wpn7aJ; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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=83X0Ly3GNFYkIBH/BFHbUkVhejW7zXmTm47ETsZa+AI=; b=K+wpn7aJOFLmPZBtmJEtbDEIz8wwRyqKm90YcGp+HMvxjAN9pVZ9cCtV/gejD6CHx8 CCRwiS6KNOavKWrpApClDZVkUNnM1PpPI0sPj53nn54bQD/sBRG7JsNHHoX4PU66BtJs sWQPtl9p71g3J5ENln6J0XiGFBCetgKOUOzChKveAkosXimFhJVQQlzelgwZoNQSSMrk bcDUcVPQoIRyS/FnXWMTu46L+C5BZMmJ8YmSSpruskuUgtBE+n6hxzvCGEZKPoQmzw5o IloxmtP6GY49QXdlXgn3aXUqKYfzJKfo4M4OVXaCo+jBOHmqanbdshjSYmo4j7v976ox Mgrg== X-Google-Smtp-Source: ANB0VdblrnnClBYraLmPvStLXRnR3nCTmyxCJTD1zNjyPyVzvdcT/vtJe4+4mlXiStIG6mJaA/B2LQ== X-Received: by 2002:a1c:9e4d:: with SMTP id h74-v6mr1596295wme.70.1535629282357; Thu, 30 Aug 2018 04:41:22 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:21 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya Subject: [PATCH v6 01/11] arm64: add type casts to untagged_addr macro Date: Thu, 30 Aug 2018 13:41:06 +0200 Message-Id: X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This patch makes the untagged_addr macro accept all kinds of address types (void *, unsigned long, etc.) and allows not to specify type casts in each place where it is used. This is done by using __typeof__. Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/uaccess.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index e66b0fca99c2..2d6451cbaa86 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -102,7 +102,8 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si * 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 untagged_addr(addr) \ + ((__typeof__(addr))sign_extend64((__u64)(addr), 55)) #define access_ok(type, addr, size) __range_ok(addr, size) #define user_addr_max get_fs From patchwork Thu Aug 30 11:41:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10581515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 795DC174C for ; Thu, 30 Aug 2018 11:41:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69B262BA60 for ; Thu, 30 Aug 2018 11:41:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D8A12BA68; Thu, 30 Aug 2018 11:41:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 027CF2BA64 for ; Thu, 30 Aug 2018 11:41:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 947EB6B5135; Thu, 30 Aug 2018 07:41:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8802E6B5136; Thu, 30 Aug 2018 07:41:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D54D6B5137; Thu, 30 Aug 2018 07:41:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 059CC6B5135 for ; Thu, 30 Aug 2018 07:41:26 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id l4-v6so1168494wme.7 for ; Thu, 30 Aug 2018 04:41:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=KfYH6Tzsb0z/vmKFOXCsrYnHaggF5QU419/lUUKCb/M=; b=YKPoIr0QMqxNXnEqdheSKtZaWjxPutRgqoHdmrHBWIMzu2biTjkjAuLJE+vP7L+1We BfYtvD+tlWjkPnvOFKLuLX5uDObo9G2ij8HT7MmA2RbV4hoFp5/W7SSn6+t8CMAlyMyj +4xueTX58t1OnuB78Mt7kjdbAnDroU/9ShReWE5tLW8y3ydec9BcPz1TrVLSkm+dcDcS 7kFe6rn6cg8QncR+2xPY9kl/obgRVeco7643O8oP0WZPquvl6gqpWTaKTvDQ7UPUFknF Ub0+5WdQTGmzHqsARwXDuEjWTGEwt2at9wihhBSNJ33MeCmjR/J+64r/D2JQIoB1SN6J 6Yow== X-Gm-Message-State: APzg51Bm/6yUk9yA9n+LfQvwRzmMPJwiQQ23B2i5QkL7L5b5BmQ9fxZ3 6UjjqyV4tI0ldnKo3Dp1OvBjdTQB9/XF6UsC+GHClL0tUiaszCu/h4TIqbjBW1iTvE0rcpANIJ2 zOYDhJ7DdQRetMIxQNdsFNSsHhoeaf3Z2SXBOTAzWoLhNQea7AYqcBtm7mkOUxVn0wUWKjdjpq6 D5agyGpSc2Dp2NnhHfWzx5IaEEGZdKjw2VnwokPlwTuy7VwFc76YIS6ESkppwC8rC6kpA+OU2nu me/1U6HSVHjdsPoLHwVMOs/zMC72dZ+idw5qxDfggycMhlf+4Eq0NOa+HAqU5hrHbJ2zId/ptHx TmlRwQg1YSjiyUz1mpvK2aSab7NKR04oYchVX7yA3+kHISJbXwSxHj3ZaYfTk6bfvRS5LD22R9y x X-Received: by 2002:adf:e6c2:: with SMTP id y2-v6mr7310735wrm.35.1535629285271; Thu, 30 Aug 2018 04:41:25 -0700 (PDT) X-Received: by 2002:adf:e6c2:: with SMTP id y2-v6mr7310696wrm.35.1535629284547; Thu, 30 Aug 2018 04:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629284; cv=none; d=google.com; s=arc-20160816; b=MMsuW1A4u6qnKBCkLRkkW7y0NrEG1rCXcVtFYX9OIv+IEC9YbsPNH/yUNPTo0mEn0z bzrJec8S9pfkqSqTQ4sAD4fC8/Asa5238HC8SkjG6vaayL0C8tM7N86jKJ+sD4dg0Bhu 2o7ZfiFB35+3HmldZakewA3p0HO8s9uU2gEK0MtHKCpWV2b0QUmTdDVSjpXqCturs2yU Atc/xo8AwneFhgiRk+0GAVIV/FY96vd3z9WDzPU+lvJDKQE1i0XU3yTajnqgQFL9FZQB UbmYqA2ygMYVO3+6ZrVN2HYAokxuxrIAs36H5uj+C7rTENXI1i6CYKM/DjobWHF/dG/4 Sc3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=KfYH6Tzsb0z/vmKFOXCsrYnHaggF5QU419/lUUKCb/M=; b=URLRZL6faXg/GAaAPneIkFgy/PG2OQ0hWO4WMtuQv9t62KBe1pHCpODDOltlirc8IJ +rNFF90GIgYd805tv8hkmpugvnUAELFEbp6tUNwCre6soPvju1gy/dAb2dBNud2JFcWX EqWE+HkF3Zs4/XGG2vibghuAyylSgkyiE//G2tzp8I7dRhkBzxWBlOeqcW0K061HCPsG UaP6jB0DwCbr8UFP9rQ71nuQ4SRk4huR6TPg85YvUz6u3q9K9o58mFc/EgJjk/Oyb/Db PrWUbtWfVEjA0wj82qOK9E18CdXc8SBdRnV2XGDVwkUxWPOIYxXDm883LLC5OESksBFC Yl4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SlVrQke1; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id w35-v6sor3702496wrc.46.2018.08.30.04.41.24 for (Google Transport Security); Thu, 30 Aug 2018 04:41:24 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SlVrQke1; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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=KfYH6Tzsb0z/vmKFOXCsrYnHaggF5QU419/lUUKCb/M=; b=SlVrQke1WhZ6O7NRIVjFhSxayQWj+0CsRGKGIwkcT2jBX14NAIHkWVjXQWA2EUGecR 8YqeRKcb8aU1JvFpetpYruAgMrf4QvtMgcPKs2lMwrnQ6FIp+2emSvfGBtjXPmoanpE8 OgWrUG9Oc+AUrCcm5yUGPEAYrCSRnOYb1EPJRWzGK2ELv7RFjTJkVuUxlpj+FaR0K4Fm T26n780JhZ9e07DlSfaMe4HZCX09HrgO6FY/a8g4OjQ2ZtelwTDFoRt5VxT22TP9pWpS zR5Dfk+GoIfpdC6OSm47yVm6eaduuRwduGf5yZ7D1k8y8Qfc/Ij6G6VYWM9MeB801lDc YfLQ== X-Google-Smtp-Source: ANB0VdbfT2UavtupUozQmcxh4AV9vSkbNDCltsV+0dOIrgUtBjrUTRDGUHsynILgINfK356aYp5UZg== X-Received: by 2002:adf:add0:: with SMTP id w74-v6mr7745481wrc.73.1535629283942; Thu, 30 Aug 2018 04:41:23 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:23 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya Subject: [PATCH v6 02/11] uaccess: add untagged_addr definition for other arches Date: Thu, 30 Aug 2018 13:41:07 +0200 Message-Id: X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP To allow arm64 syscalls accept tagged pointers from userspace, we must untag them when they are passed to the kernel. Since untagging is done in generic parts of the kernel, the untagged_addr macro needs to be defined for all architectures. Define it as a noop for other architectures besides arm64. Signed-off-by: Andrey Konovalov --- include/linux/uaccess.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index efe79c1cdd47..c045b4eff95e 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -13,6 +13,10 @@ #include +#ifndef untagged_addr +#define untagged_addr(addr) addr +#endif + /* * Architectures should provide two primitives (raw_copy_{to,from}_user()) * and get rid of their private instances of copy_{to,from}_user() and From patchwork Thu Aug 30 11:41:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10581519 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 098A6139B for ; Thu, 30 Aug 2018 11:41:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED0E12BA60 for ; Thu, 30 Aug 2018 11:41:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFF112BA68; Thu, 30 Aug 2018 11:41:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 791362BA60 for ; Thu, 30 Aug 2018 11:41:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A812E6B5136; Thu, 30 Aug 2018 07:41:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A09286B5137; Thu, 30 Aug 2018 07:41:27 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E5206B5138; Thu, 30 Aug 2018 07:41:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by kanga.kvack.org (Postfix) with ESMTP id 1CDAD6B5136 for ; Thu, 30 Aug 2018 07:41:27 -0400 (EDT) Received: by mail-wm0-f72.google.com with SMTP id s18-v6so1172120wmc.5 for ; Thu, 30 Aug 2018 04:41:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=LhBQZOJZ5CY1iejYHh5r+OO80KOFbC9w+x7Kw+7XH2c=; b=EIQ5i5Ci6dHOTxATrXXZWVE5tV9ZcnL70B6WxiLEG8Cpcz6zWfbLEYAfriZMh14pqk jRbyndykHWItBCvxIfENBzW6x1yY4cP52jY75P5qs5kta+x8RIzMnhH0wMQwIYUHK3iO rm0YGr02MB0LfptjymJenuJGnAWRhlGzt7wz7s3+DleWauUI3Q334aTModNXBUiF57FQ O//D9isOqxQSTphDRRKC0LFue0vUg7Cqv3RYIxvtonawg8PCqMUrzqJhjRfNJW6q5tH8 /YxdX48ffjh27C4WgBFcXuW2yva+LmRaW+HZZsj3m2t32xfFt5LSSYAsZiofYmfMHS2i yELg== X-Gm-Message-State: APzg51D9sjeALmAJpOQEGC2+3TAuN3TaYs8ioJpLqJzq/VU6cibrR4Gw mPHQmxcQQkNp7wFxV5HSVTR/fv7GV8Er5EngClKIDdji2mOp1CwDnH8m5ThOztq1J/N+/MY0lxu b0j98Copols9CxPHIJh+Rzewbr5+PW93M6K+2LTUxExfhuPWgRv+2wB6s6QSfWVqNHib4q/J/l6 zOyx4Ujdaszka5qB4YC7QKu/b/7exjedtoTlkpthsHsnXMXO9rwJ9FiScPkoW8oH0MEmyVeeYA5 P2Q0XxPktNah1t3GtyJQfD8sNTF8IM7tk6AEnOPTwjosLJmlwi0SWxtq7iKvwMqLPU3apibudic uxLLTdOPb4xlCm25fuf50wl1IcMgByboMP+1nSbzWY/kdEPS4MFLHYmpMbDGUS2wS1RBRgCapyv a X-Received: by 2002:a1c:9215:: with SMTP id u21-v6mr1546937wmd.106.1535629286600; Thu, 30 Aug 2018 04:41:26 -0700 (PDT) X-Received: by 2002:a1c:9215:: with SMTP id u21-v6mr1546914wmd.106.1535629285912; Thu, 30 Aug 2018 04:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629285; cv=none; d=google.com; s=arc-20160816; b=iJxXaqG/ZpXXCjKqdY1UQpCyC7ET8Dmzj+TM9UeP2HrI4XTjWyMIc3ne9pvRjkF29o +Z5kvTqdcrD3MjyBNtkE8qF68dnlcHPrDjVRVjPMQvTSTu/i6eiOmgdrLOzOPm+OWlf0 4OTrxkukhwlJ2fcQ+AhsJiYhF1fyb3FP07KpNtN+NDrsW9r9tbGWY4zk5ppGAQWhtajt kiQ0ZqSRONJmfJZk0aatsBwVqmb1h0+2B8zVMyr4+d2h9mBK8idQMVuhQzRoNKJTP3Cl A4QLDai83DB3ZLU/T4mdKnF9rjk5tcunyWJ2KXqg3C5XUI7KFBhLteKUYGqnUbwipUm2 NhMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=LhBQZOJZ5CY1iejYHh5r+OO80KOFbC9w+x7Kw+7XH2c=; b=jUhm0n9vmfbF9K7MyjyP7LCZQ20GASx+FC9ygtlQZGEeQ35Fd82w3zF7VzMPQUNdDi BxOzGzh+ArY66EA6kHUqrv8n3JoM5SGJ8fdVit98CA3FQHBxKmsPUlgFGpB5b5gUGfz2 Jc6SXiBZzZ/lTyh7h+a7Q7cs9oVzmzpBLRkOCK6VJES7yUpeoiYB2frDiIk4m+EEyg6k 6fQ79QQWlAOvvy15kn05epNWy0Xzjq/9DIY5R7Z+1euZqXp/puXfBXHqq3gbw8r3Tg1J E3708+RAZk59Tlj7c7Fj+O3S6Kf5Y162wpwHOxXINg0XYxvSaCA/mOfXZxIcUu5piYky 2aoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qhLN0+Xl; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a3-v6sor63003wmh.13.2018.08.30.04.41.25 for (Google Transport Security); Thu, 30 Aug 2018 04:41:25 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qhLN0+Xl; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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=LhBQZOJZ5CY1iejYHh5r+OO80KOFbC9w+x7Kw+7XH2c=; b=qhLN0+XlBq6jHDTlSlKfMMmJjUqASaVSiAZ0zywVXpAg+VpUOeqdiJHj/wArfR65XG Ut3JLptVruN/PBv/xjcMUVNG81WIKCO+dMG9qK6HWxTAtR/EtQB8CpaH9QF+IGCW4BWn YSmQMOUq6FSuRhvb8AempV8E+YLZPSUlE4hF2263DyPfege/APAPyWSrGUaOUqwNEiw3 O4IibHRF1/nN9/UDdjKaDCSYnTyG5+kjDhFJC2srV9nASdDLL5E5WdrKISQHKKrQN0eP M8nLl+weFtfn/3yYYPWxYTFB3bviLyYR2P+BrZHk7c4uvaVyPrL5NiMZclTO4/7ZClBg Xtfg== X-Google-Smtp-Source: ANB0Vdb475utvdy0BbImRrjLj8t24oq22bP1K+3VkFe8W8AFPMSWX/v25NfkMksN2tme/fdtdkw3XA== X-Received: by 2002:a1c:7915:: with SMTP id l21-v6mr1693369wme.136.1535629285313; Thu, 30 Aug 2018 04:41:25 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:24 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya Subject: [PATCH v6 03/11] arm64: untag user addresses in access_ok and __uaccess_mask_ptr Date: Thu, 30 Aug 2018 13:41:08 +0200 Message-Id: <7a37e7363328f4aa10706c0294242eaa5e4e9e89.1535629099.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP copy_from_user (and a few other similar functions) are used to copy data from user memory into the kernel memory or vice versa. Since a user can provided a tagged pointer to one of the syscalls that use copy_from_user, we need to correctly handle such pointers. Do this by untagging user pointers in access_ok and in __uaccess_mask_ptr, before performing access validity checks. Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/uaccess.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 2d6451cbaa86..fa7318d3d7d5 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -105,7 +105,8 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si #define untagged_addr(addr) \ ((__typeof__(addr))sign_extend64((__u64)(addr), 55)) -#define access_ok(type, addr, size) __range_ok(addr, size) +#define access_ok(type, addr, size) \ + __range_ok(untagged_addr(addr), size) #define user_addr_max get_fs #define _ASM_EXTABLE(from, to) \ @@ -237,7 +238,8 @@ static inline void uaccess_enable_not_uao(void) /* * Sanitise a uaccess pointer such that it becomes NULL if above the - * current addr_limit. + * current addr_limit. In case the pointer is tagged (has the top byte set), + * untag the pointer before checking. */ #define uaccess_mask_ptr(ptr) (__typeof__(ptr))__uaccess_mask_ptr(ptr) static inline void __user *__uaccess_mask_ptr(const void __user *ptr) @@ -245,10 +247,11 @@ static inline void __user *__uaccess_mask_ptr(const void __user *ptr) void __user *safe_ptr; asm volatile( - " bics xzr, %1, %2\n" + " bics xzr, %3, %2\n" " csel %0, %1, xzr, eq\n" : "=&r" (safe_ptr) - : "r" (ptr), "r" (current_thread_info()->addr_limit) + : "r" (ptr), "r" (current_thread_info()->addr_limit), + "r" (untagged_addr(ptr)) : "cc"); csdb(); From patchwork Thu Aug 30 11:41:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10581523 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D910114BD for ; Thu, 30 Aug 2018 11:41:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA6C72BA60 for ; Thu, 30 Aug 2018 11:41:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDA4C2BA68; Thu, 30 Aug 2018 11:41:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62EF22BA60 for ; Thu, 30 Aug 2018 11:41:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9C7F6B5137; Thu, 30 Aug 2018 07:41:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E4B986B5138; Thu, 30 Aug 2018 07:41:28 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CEDF06B513A; Thu, 30 Aug 2018 07:41:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 6826A6B5138 for ; Thu, 30 Aug 2018 07:41:28 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id d10-v6so5636726wrw.6 for ; Thu, 30 Aug 2018 04:41:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=peFGwkj0AlthOK6WcLkPIvSBY/FDPlGLSABrTryAHcY=; b=m26KFxzxiGE9f4WZPjAZlCmt5w+oXa98ovmZbkOUcY9DXirf6vziASibHYalz1bNXL 0pbR5Sq2K0qEynLo6jKpCDQksU/nUV0M3u1wuawtIHKOo/P1fHPFKdYUcmmMKZ+YCyqT mP2+q7EWDfR4BRQbzqMqc+vGYMr7pO6pFGKurObRi6E2SDrvM7dfey9tJLr9OEntT1UX 7nF9ptie5lBb+GcUuSTQhoaWVcikcrx3Nb3WHussCHSbuWT3va6RkptGEFjrCYtM7TMA fzW3goYdpvKzyiEhEpibgpVaE+hbyrkFuybUeAjwamNvsG8sMyYqnv6kXMYymOClPMsP 70Iw== X-Gm-Message-State: APzg51BHPFGBkB1c/Ep6jgnE7yqsSbDHXSxFmFCN3QGqIPTfAwOqKkjM 23p4T+gATxD3xIg5nVdvmn90GKFt8i3VFwAEOJ4+9l3Fs+0pAJz97eSMimTgvZu4h28rwDDX31s JyY1mBrZxFhC7u4U/pG9qhRUYdRrJgCJ2qaukOqrSestOm871R+vB3paHySD6NLn5qR1z7Gnfm0 n3BfNYn8UKPvuaab8O6pxOvHQhLrQ2q24BNTGxmRY7zTL0PupwEg207Vl2KWZ6RYHZ1BSHWsFWw NVG7Jd5LaVVhfftiiWxwXnbjR7yWAYsdp68J4I8MEEuqg1Ably/QTgyQMysCLJAUAda2gtce1zo n1q9iF55u6e8DBalxvJrg3SI9jDp5ZMaPO2bQ4kK83ZBqxLIxzfrSEoTHS/BVEz3JwMRY44fdxF T X-Received: by 2002:a1c:cb4d:: with SMTP id b74-v6mr1667294wmg.123.1535629287936; Thu, 30 Aug 2018 04:41:27 -0700 (PDT) X-Received: by 2002:a1c:cb4d:: with SMTP id b74-v6mr1667265wmg.123.1535629287261; Thu, 30 Aug 2018 04:41:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629287; cv=none; d=google.com; s=arc-20160816; b=uCN/WfHMXx6kAw5eZcooq8t7mPggPHvDXIQhiklmkERQI+9rkoa/cgojP10YI4hsfd 47sJVfHKJDNW4iIIRWlsgbZVB6AyNoWpKGHct3TlRtlw4clx16fenRpOH6OSWUuratZy zR3sd+TTjipuTHc/uQSTb66MVuXwRM5nJ7WuSLHn81zCc62ggONNetFQmXvh12k4CiIt N6NCzfHhxn878j5Ylmy5Y2akSilUBoGxqE6qT/E1RTnnzdmJ4cUnqo1oWWSoJOIbrawN 1dpeN6/QFyJuL/vPpHfGC2IKuKsCLP+b/+2017QHu/EMWwQv75GxPou4mb+RIAHPmRRv bA8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=peFGwkj0AlthOK6WcLkPIvSBY/FDPlGLSABrTryAHcY=; b=I0nVUKRLM+GZRCKU7JQKQhFr2qKyhaRV5kHicF86C8ZceUBfoHl3fSutxBR1j9Ltpz a3J4+ZFOwI/gOccG7ytVWr5bI2Ulu7cYPzLTzK3KA7+Q1n43tZMDAIbSv9Dku1IW4ZgJ Kud2Nrobq2BIZmlUlrYpkjjGj87y/zQjwPUSQqeJzhRYM/hXJXMIhQb2u4Y53k2XuZHx CzR4UQew7KOlpIpCjpG572wkuHp4OwSZctdBt0vQl5vEiACRZdXATwkDjgFZ/QeWrkrH 2YyznRujSg9U2gjJ/i9x0kBSzc/oABTM7P/BNwL6tKZwwxpMgZShdNrhIx8yv9K2A22R lvmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qutDpDCE; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q11-v6sor4701533wrp.1.2018.08.30.04.41.27 for (Google Transport Security); Thu, 30 Aug 2018 04:41:27 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qutDpDCE; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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=peFGwkj0AlthOK6WcLkPIvSBY/FDPlGLSABrTryAHcY=; b=qutDpDCEJxZdQJGRz9onfIyHIbFL8b17YWKAy3SacXtKLfSDNYNiVlv1hK56myHKVG TpyquPNOuTBxR6l698HxJDFXuGfJTfgvMYNFFkc9/TXqGxKm8UfZZF8EYjbSu9sRM6Sv MeNf7eh1j8Y9rENXz6JmOCnaZ5acljWvTf1sWUnXx/3QzkRf3sWTGcV0uHPXYOL47Jwf fQ+ZkBLNcijn0SXu94/W9cZckIe0NxQsbfFYrLBOM2UywIlnvrmBr/qpaYtLINQomi0w NTY9nCRgU5N/y2QOVTs7v+xMJkt10JdgERM5cVwoecykkVi8kZaSlsRfS3mO1P/oW9A+ Kbbg== X-Google-Smtp-Source: ANB0VdbPh4x5K+d73YTy+PJV6jm5VPTOj5FyfmaIwEvpFsYUqWJo2UphtTMIpDCNqc7+l23bjsiZqQ== X-Received: by 2002:a5d:5009:: with SMTP id e9-v6mr7782028wrt.18.1535629286664; Thu, 30 Aug 2018 04:41:26 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:26 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya Subject: [PATCH v6 04/11] mm, arm64: untag user addresses in mm/gup.c Date: Thu, 30 Aug 2018 13:41:09 +0200 Message-Id: <163681302d7380fde6717daa26739965295f636a.1535629099.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP mm/gup.c provides a kernel interface that accepts user addresses and manipulates user pages directly (for example get_user_pages, that is used by the futex syscall). Since a user can provided tagged addresses, we need to handle such case. Add untagging to gup.c functions that use user addresses for vma lookup. Signed-off-by: Andrey Konovalov --- mm/gup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/gup.c b/mm/gup.c index 1abc8b4afff6..6f09132c654e 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -666,6 +666,8 @@ static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, if (!nr_pages) return 0; + start = untagged_addr(start); + VM_BUG_ON(!!pages != !!(gup_flags & FOLL_GET)); /* @@ -820,6 +822,8 @@ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm, struct vm_area_struct *vma; vm_fault_t ret, major = 0; + address = untagged_addr(address); + if (unlocked) fault_flags |= FAULT_FLAG_ALLOW_RETRY; From patchwork Thu Aug 30 11:41:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10581527 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D6283139B for ; Thu, 30 Aug 2018 11:41:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7ECF2BA60 for ; Thu, 30 Aug 2018 11:41:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBA5E2BA68; Thu, 30 Aug 2018 11:41:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FAB92BA60 for ; Thu, 30 Aug 2018 11:41:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE89D6B5138; Thu, 30 Aug 2018 07:41:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AD3336B513C; Thu, 30 Aug 2018 07:41:30 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91CCF6B513D; Thu, 30 Aug 2018 07:41:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 2D02F6B5138 for ; Thu, 30 Aug 2018 07:41:30 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id p105-v6so5613107wrc.11 for ; Thu, 30 Aug 2018 04:41:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5dvluYXXhbs3bkFHe7bYXbDtGM4AV4lqI04lFKRyGa0=; b=JEDdMSb5WF/DdZfHaLdlCo981MUERcBLELfFfE1r5aC2568oYNxjlFoD5Fmg4WSLoJ ZwiV63y76J9hZYWAsD7IiobWQBpYKE02ReYFV7An1Ux3pOhdnfj5ckA5MBuR5cvTlofQ IadciNAUHtv9ReWwyFRVOkgNuPZU5xLULE+lwtRGapZYMO7AEgXaWAmpNKvvuMBr1K6B sSGUgwswoyvVOCkUFmwF3rqFMH+podlnNdIPi295XFGdfm+O2Nyfo/zDeFCDibYpomx4 zel6DSuNz73LnKw3+Fu2sRs4pE5TQXNNvjR+xsypn+fVtlYXOK9t58m3Mi9B0uir8zxm royw== X-Gm-Message-State: APzg51A91pI8H6DuAWOpYBBB/qQSXWgD4rcQa5se/IugJi2jgu496gOY o5nddVlYF2FCTZiptg5qqhTqu3Tm4MKSygMgk4G9aUmvTgdKjHxOuDs3/+azQmbtvuHsG4EVEg3 RkXeQ0nWHQuTw8jsNFe6MGfMX5BJdIgW0TIM2LIhvYIcxhWSe0jX9kf4QwbadSiPpRIS5T11UDP VHgBT2vK4t860itQ5LrdOWQ4fHzw1tXAXXvoozOllVAQ0o7NQXd+W6tOHHovnwwyaFjUkDTUTyS ucjwhSfKzuJCuDNSF/PZvmI83dI6wqw2s86vQComAzFnjRin1d5cZ28mMq+b1Y4gFU57hN4RzXI w7Cy4AgSescS5rA7qs0WcawqmPrmNHofUcfARFPyGxaPRHZ5g9/GX7tA19iRFejSU9kZG0umLYs P X-Received: by 2002:a5d:4401:: with SMTP id z1-v6mr7762042wrq.227.1535629289712; Thu, 30 Aug 2018 04:41:29 -0700 (PDT) X-Received: by 2002:a5d:4401:: with SMTP id z1-v6mr7762015wrq.227.1535629289010; Thu, 30 Aug 2018 04:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629288; cv=none; d=google.com; s=arc-20160816; b=rAblaMdJPnKyKZ9DQG7K65S8MpAwQ3xdWsjSuB9GH3HjV2HiB8Xgt1gyv9FZIeAb0D MJAMggRr3FklBXOkmetA1MnBWZbyLipYEFKz0eMTjP0H/j25kt4OTJoUXb692NnXcqvz 2TA9SFBKpQ6qdTEMMRhMs4CCsrfSoClVA9u9ydBUGrdNYgS+gF7P3hD1ioVMbWBeiOYM L/f0pYfiMHDA3LGZgOe9ABeXOPT7DbIVpwP/FoC/EMfw6scView9Edv6nDic8MibIFwC WlZmdRsSf2pBAg9K+ENCY3d0W0KIgMvJ8HMjEJg1ZA0vRBGqLeXSqy6XJTkFOJsH0JyI rkGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=5dvluYXXhbs3bkFHe7bYXbDtGM4AV4lqI04lFKRyGa0=; b=Yu+LmPZWYmcxenl9EZxfLJ3RsBahg4zrzjDT8rDnoMtqiyGSdlRsvQBoDGBOcoVD85 1J8QQI5K9m2y/W4j4mhs0f+Vu44TQ8vZu4DPhmFO0WfHd/MhJADO3zObasx+QKim9UZK u39qzJNhv0O+sWuj43GGxdi/fb4SjDgTfIFWEJQWl5Cy0MdTqwADQG5o9tT/PgScGeUe 41chIuP8AIEeOU2GrRPmmqEP47kvXkDFf6eJOx6PLaRswoxL7eecSdrryE1DROiaDGa2 1u3R5jaGaDo20IxFYydxenqoxEbTDudQNpa/+hDsNqw9RsY+jC9oT6AAREPSyDQcymjY nL0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FrgdPh5T; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id o139-v6sor62279wmd.23.2018.08.30.04.41.28 for (Google Transport Security); Thu, 30 Aug 2018 04:41:28 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FrgdPh5T; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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=5dvluYXXhbs3bkFHe7bYXbDtGM4AV4lqI04lFKRyGa0=; b=FrgdPh5TBPIr4rtMd7tklQtyRgar4ZAsFHKz1PwEj3+VC5jau9Dry3d3VxRWxcx9DN aM7aeZudTWm7p/kNyIHKV/3zc+Y5VxHMcMOGT00Raehj8yCHK4qQRjbgPVV2KLJMxAqa 3Rgdu4UCrXM9AqoS+dFhMRoW3rJ0nq+cpf74SiEB/jzedt9fBg4Hfm/m/pENAIQSu++0 oMrCJovZb3IkPM50eWmd/9DzfAZugaZLcIZhmav9Cf0kn8UP4YxUMn9mjnercwABxtdG oWWF4BHN5MPrFvo1HQRM1riSm10AId1VXqNCaVpDU0IN56koQpJ+E8OSG+nLyWo4zchm X6TQ== X-Google-Smtp-Source: ANB0VdaAurM5wWvTbuaKJB5Eic+D12Dz24+pkaychw8uSDgku8eMYRWKoLaud5DLPVltKXfKUxcYpw== X-Received: by 2002:a1c:b143:: with SMTP id a64-v6mr1645342wmf.114.1535629288159; Thu, 30 Aug 2018 04:41:28 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:27 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya Subject: [PATCH v6 05/11] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Thu, 30 Aug 2018 13:41:10 +0200 Message-Id: X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP strncpy_from_user and strnlen_user accept user addresses as arguments, and do not go through the same path as copy_from_user and others, so here we need to handle the case of tagged user addresses separately. Untag user pointers passed to these functions. Signed-off-by: Andrey Konovalov --- lib/strncpy_from_user.c | 2 ++ lib/strnlen_user.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c index b53e1b5d80f4..97467cd2bc59 100644 --- a/lib/strncpy_from_user.c +++ b/lib/strncpy_from_user.c @@ -106,6 +106,8 @@ long strncpy_from_user(char *dst, const char __user *src, long count) if (unlikely(count <= 0)) return 0; + src = untagged_addr(src); + max_addr = user_addr_max(); src_addr = (unsigned long)src; if (likely(src_addr < max_addr)) { diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c index 60d0bbda8f5e..8b5f56466e00 100644 --- a/lib/strnlen_user.c +++ b/lib/strnlen_user.c @@ -108,6 +108,8 @@ long strnlen_user(const char __user *str, long count) if (unlikely(count <= 0)) return 0; + str = untagged_addr(str); + max_addr = user_addr_max(); src_addr = (unsigned long)str; if (likely(src_addr < max_addr)) { From patchwork Thu Aug 30 11:41:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10581529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E798014BD for ; Thu, 30 Aug 2018 11:41:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D66452BA60 for ; Thu, 30 Aug 2018 11:41:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9F342BA68; Thu, 30 Aug 2018 11:41:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7302F2BA60 for ; Thu, 30 Aug 2018 11:41:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A02E6B513B; Thu, 30 Aug 2018 07:41:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id ECA486B513C; Thu, 30 Aug 2018 07:41:31 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA19F6B513E; Thu, 30 Aug 2018 07:41:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by kanga.kvack.org (Postfix) with ESMTP id 5BB7F6B513B for ; Thu, 30 Aug 2018 07:41:31 -0400 (EDT) Received: by mail-wm0-f72.google.com with SMTP id b186-v6so1137240wmh.8 for ; Thu, 30 Aug 2018 04:41:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QaAF7azGCBxdq6iEEzNBoAuvrmN85mP7cm3lHvX0lL0=; b=IBQbzk+4MJKguqrz0PhzETdQ3FQsrRCxjERbpeor0hRzAUs7ofq8naceKQYlQdCBDZ p5Hf2Y8oOWlVmgH2XIR1uT9HVOrZQL11Wct0v5lpDiOTR+h5fZAVKkBVXB0N83EafuMH c92AVAme37Y4mqbZqTvlSHKNe8/kVZGuaj9DcADg9phUqp5aLfUy6BmpCUd4eQWlTuQI HxwR483Htr4XyWE6bypwvtzKkmh2UucI1N0wsNYRRh5Dy1RrHcBbh9SpL3STz29gpHNo 52P60dXHvRFmlYaMuoHcPUFOSBPKZwrw1PtBgoi4CIzfi4XfiNsM8sXLYn3oVcfKhYIz 5bKQ== X-Gm-Message-State: APzg51DnP14yUHeOFCtKu4wIe7ViSrtYuabwi84xQmYhfOk4Wp9DmDZX j1CERUq5rKVWLYCVsktQxeLb5XPH4OMN3JhfKQvW1YHQHwyY1n5R4x8xkt/uEZtxIfcuTOru4G6 DwxmCititRVUx8tKUHaMhnuauDHkJTZkugux09DKLBFK3YC+01uVBFnII8/82vmhtq0/MQAj50a uwb3uzmoNAtSxq5PEmaYzwRt6HhcE6Q8PO50to1j+LMLPg2wQXsEzcj5R+UfQD5bAA9UBUTa66F jUwmOrqTSIh36MjcATDEQ6cODGRHwpPwzgg1IrhqMlr3tTeLmPUhMnkqQn3PHqnHx9PI50sAJxd B1qQgl93bVWmJplE8OX0lII995fdT4oC5iKDnYti9zq6bDxXsPpPidqPFRmG/pg68DXUYtDIINu N X-Received: by 2002:adf:83c6:: with SMTP id 64-v6mr7320945wre.5.1535629290912; Thu, 30 Aug 2018 04:41:30 -0700 (PDT) X-Received: by 2002:adf:83c6:: with SMTP id 64-v6mr7320915wre.5.1535629290171; Thu, 30 Aug 2018 04:41:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629290; cv=none; d=google.com; s=arc-20160816; b=J4lvjN2JvaxkQK3LLeuHjMKGwNEuEJXTqFVOce9mumszUrmNu69VLDGSnXnKqeVxoW p6d0hvQIv6Eubnee/toWH+F8eYDlVg3dhyTYWl+woEyIY2RJxOjvLIoZIDoiRqCboxrX 0+/gZzLA4qJ3BhGARHl/pbRT9hOihseL15+kT8yvBR5TphfycvBdmX4IHt3vYpMdsAlZ Lo6hTOPUiTmAsXGeytov1QawWX/lZD+OshqVmDy5CAbzWDpEQ74hu1W76onMnvvGURPW Uxx6wH4DJn20dkWUiVAV+uPiObd/1n3zaNH3q4OZqeAggXR7TZ4+fg6ejtyZP3BCCZ1a z6PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=QaAF7azGCBxdq6iEEzNBoAuvrmN85mP7cm3lHvX0lL0=; b=gWIcwlhfK3KUPA8O2ML79rgday4QNu0eylex+d54PTSC7b2FRznRz7baB002egtayE iytgs30xmE9zTqr95eIX0BHxnFfk+94G5J1fNZnxi1K77ClkZDRK6uUQIUAKIBOqrCOW Bx/hxjzLEbKUkfxTJSGeXw1JP3XLKTRxu65lJ+2E6q6iu25Iom5mnpJb6yPUSfhmArio 1gP+s9nrp7gjIR2LLOUkLJHfHoMtLNf1oyL3uL6PzbqTFyI/ImXIbqeJs+ugja7NN7dg v9+Qu9HLdDuekxs4aSNqyqD7fpLIlT518XnzVmfDQLfNF4oepQ1b+Kf25/MeysI082/G Ri0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=akbNH9Dh; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id k12-v6sor4755432wrl.2.2018.08.30.04.41.30 for (Google Transport Security); Thu, 30 Aug 2018 04:41:30 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=akbNH9Dh; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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=QaAF7azGCBxdq6iEEzNBoAuvrmN85mP7cm3lHvX0lL0=; b=akbNH9Dh33OFp1Yfxft1/iAWWvJdMIyZlPJJ1bI0TCj69lznWK3PI54Ty8g0gacvcP VTI4KEwgIwjURL8e5z8lVSK5LXhpqWNEr9yq465J29bgrU8yZ1vOIjdWB8SBL55Ktaw+ 8Adr/XBoiIXlbE4KMMggbcpFWiFvuTQu8b/9+ZEy2JKekcqtBUZQUbpHiHx/F7cdzpHc SCsOWLH9Oo7s3BL0RMzwMg6Pyb7eImoM78fpbnUZafChxGJqjAGAblnQ35NEWyWvHgzx Tucj0Yxt1kjv9ZOtZ2XgP81Y13NrW0z+E5TMYVyvGsqMLpUxSwRAqIkbptaHRxFhZXd9 qdow== X-Google-Smtp-Source: ANB0Vdaqqjdd90OaOAwZrqHj8elm7AVweBzpTBqr0QeZInQNaIkAj+Q8mqFZIzcP+cnkSEyeBYYIhg== X-Received: by 2002:adf:d20a:: with SMTP id g10-v6mr7876598wri.66.1535629289628; Thu, 30 Aug 2018 04:41:29 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:28 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya Subject: [PATCH v6 06/11] arm64: untag user address in __do_user_fault Date: Thu, 30 Aug 2018 13:41:11 +0200 Message-Id: X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP In __do_user_fault the fault address is being compared to TASK_SIZE to find out whether the address lies in the kernel or in user space. Since the fault address is coming from a user it can be tagged. Untag the pointer before comparing. Signed-off-by: Andrey Konovalov --- arch/arm64/mm/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 50b30ff30de4..871fb3c38b23 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -313,7 +313,7 @@ static void __do_user_fault(struct siginfo *info, unsigned int esr) * type", so we ignore this wrinkle and just return the translation * fault.) */ - if (current->thread.fault_address >= TASK_SIZE) { + if (untagged_addr(current->thread.fault_address) >= TASK_SIZE) { switch (ESR_ELx_EC(esr)) { case ESR_ELx_EC_DABT_LOW: /* From patchwork Thu Aug 30 11:41:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10581531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 21CE2139B for ; Thu, 30 Aug 2018 11:41:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13C362BA64 for ; Thu, 30 Aug 2018 11:41:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 078352BA69; Thu, 30 Aug 2018 11:41:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2B932BA64 for ; Thu, 30 Aug 2018 11:41:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D186A6B513C; Thu, 30 Aug 2018 07:41:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C772D6B513D; Thu, 30 Aug 2018 07:41:33 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B1A716B513E; Thu, 30 Aug 2018 07:41:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id 52A5C6B513C for ; Thu, 30 Aug 2018 07:41:33 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id u12-v6so5721236wrc.1 for ; Thu, 30 Aug 2018 04:41:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ppVHi2qDpVAko4oywEUyVH03nYNtDWMaAZh6pkh+TAI=; b=JT8wSpOTGn0zUupYdA1QRNteeVPfNP1QbT7n9FKH6tGRPhyQgVNx1VW8LmgZWO4L1n 3BigYTm7fHEFt5V9zZsB/JnYnjLno98I4afUmvebDdtYKuLfEgzmivHNRkCY0ph5bqnH JuuMqhH1M4XQuUYBXG6e3GMac8PM/XA32sO+4Z1U2Cxl5qS44+aTawXkofm3UCmflEbG rscGJ+SmAbjqgo3eOrPX9va6ns4rv5hvxsZvVMs+Kz+xxpqr7KBV+RR7jDj/48BxtLz/ 4mh7TNIhDG0V74sypJxUk85wzfwqLFUG+Wh0ageGOlhYJKaLRRF2T+EaZLbjTwgqYSby 2sdQ== X-Gm-Message-State: APzg51BUR6KqB8zbn7/Yc/Z+oy7rQjPAfoY8LkHf/NlNjaOals9QH/YH bZYENGqmT2NcI48YeSuSaqz+xdWaOonzs9sBwP3shLUxzSJKv8qrLb71wRgpR9SdEleJxsTOMUn PH9Q/T9gvTGIQwNPTl8dGj1YDFKY0lEcrRisX/ZguOsbmem4kjzXGz3WZqRsGxnX/unra+PJj5D fhYBs1042KfSBm3WFDOrukr6l/+Jvybhl2h101nG1gODbDqnD4FfZrclyKUWmDfV+4jgvBwrKw7 PO34z2L2AlxkugupuzynbWlOLMjVb5kQxx+FQYeLpJYbuWB8eoT3/RIkChChSRKnCBvXwpyFj70 lkGBwGdo72xqSBhbu5+thelQw/cru6uN8gT4kGXpr9LbTI3knVcMm9TacEOX2Ol9dlIrhRqgodR a X-Received: by 2002:a5d:55ca:: with SMTP id i10-v6mr7220223wrw.38.1535629292851; Thu, 30 Aug 2018 04:41:32 -0700 (PDT) X-Received: by 2002:a5d:55ca:: with SMTP id i10-v6mr7220175wrw.38.1535629291582; Thu, 30 Aug 2018 04:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629291; cv=none; d=google.com; s=arc-20160816; b=0HNqqfm2QpJ+1dHQEd3X8TxO983w6JEYZxtuXpYYsN+1d1QzKzv82KHegaN7apoCyX zeTNVi/L6soDT+noo8sRU4/RMCHxjtoBNZo5sBkixPdzxOm6Z4gDKcbDv9kQM7Pypsyb 2wdzz2UvDQKcY5jOzQ89N/SruUUkqKTRaj7KURuwiqGu/dd5Ym6FaAaEjZQz6/5BK35c O02aWgDHU7KmxWudN52qXISsvOn93SXDi9RGHNuJo76HJEtbwDRZFGSYcfuXxeRcYthi vv/BPDS/e05o+DTqU7SZdkDigpz5cTZn98qZtTr2CtipUDACnHuUWIPAw+Mcp9BK7pz7 0+jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ppVHi2qDpVAko4oywEUyVH03nYNtDWMaAZh6pkh+TAI=; b=DuqaEwvYZrg67Ueq3nFaK+ci4ZNTQxceq6wGq3XnZi3jyMgqycH9ILf+zkS5fCLxjq D8N24/93+yAWMugAUrR+502sTGRYSb0uE81/XkCQ/JwOtYq5HQ2SkZ7NYwxVmiHpsT7V GLWQxevUtXW1xujYMlkOkdjyJBBYv0RLrFMDG/QEnP7i4KERluYT1WFDDcsLSYLxULJY nUtIU1tpFsuHOgZRMmhF27cpPIQHtE889Kg6G/FTwv4GT+dGyd8wCkz2ddedwTiDdTdf 80QTxyN5RRgT+CATihefwAMOoUEtGE4rqjI3t77pbIvDRBxBFDvATbhz6r11kFZ/05Je oWMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=vM2W1vbB; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r10-v6sor51084wmh.19.2018.08.30.04.41.31 for (Google Transport Security); Thu, 30 Aug 2018 04:41:31 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=vM2W1vbB; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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=ppVHi2qDpVAko4oywEUyVH03nYNtDWMaAZh6pkh+TAI=; b=vM2W1vbB7o60flHuNJ/bgTQROh+Zt2m1p0PT33/imyxEkZK1/Esv7iYw9LpWqbIh3m hobo1vU1c+v0Sblwfgp+dimNnJPZy/F0NvOautf7atu0tq8HTohJpgdmmMrdl4AYk151 y1FKxABUZJiw/FShkiF4Vjx+avpapwRzC5R32XJn5fMZrR+LCeV7OWD7REcGraJpxEGx pZQS5IbOZ+yijKZDr2ka3/sxT/vVG5mZpKvFVey/NkAxEkpyZY7MDNEqyN0Dv5ql+VJW 4UYj6K8/zcqE3BRWKLrn8aXymf+gcl3zDhnzQaYNb/VkQUlbBIQ8Zyx56geVgZccD9MO FSxw== X-Google-Smtp-Source: ANB0VdYOFoy1sxoEnv1Wgj/+prhG1/Y/jGlov/9lPGGe6D7gsNtu3J1gP5Nihdp90zj4LxikZG+9lw== X-Received: by 2002:a1c:4c0c:: with SMTP id z12-v6mr1615687wmf.57.1535629291034; Thu, 30 Aug 2018 04:41:31 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:30 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya Subject: [PATCH v6 07/11] fs, arm64: untag user address in copy_mount_options Date: Thu, 30 Aug 2018 13:41:12 +0200 Message-Id: <89806bc1c1f85fa97c62887075cc2d46b8bdeee2.1535629099.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP In copy_mount_options a user address is being subtracted from TASK_SIZE. If the address is lower than TASK_SIZE, the size is calculated to not allow the exact_copy_from_user() call to cross TASK_SIZE boundary. However if the address is tagged, then the size will be calculated incorrectly. Untag the address before subtracting. Signed-off-by: Andrey Konovalov --- fs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index 99186556f8d3..51f763fb9430 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2672,7 +2672,7 @@ void *copy_mount_options(const void __user * data) * the remainder of the page. */ /* copy_from_user cannot cross TASK_SIZE ! */ - size = TASK_SIZE - (unsigned long)data; + size = TASK_SIZE - (unsigned long)untagged_addr(data); if (size > PAGE_SIZE) size = PAGE_SIZE; From patchwork Thu Aug 30 11:41:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10581533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2EB214BD for ; Thu, 30 Aug 2018 11:41:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B40962BA68 for ; Thu, 30 Aug 2018 11:41:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A86EC2BA6B; Thu, 30 Aug 2018 11:41:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40F4A2BA68 for ; Thu, 30 Aug 2018 11:41:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC4966B513D; Thu, 30 Aug 2018 07:41:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E25486B513F; Thu, 30 Aug 2018 07:41:34 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDF686B5142; Thu, 30 Aug 2018 07:41:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 4AB516B513D for ; Thu, 30 Aug 2018 07:41:34 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id 4-v6so5573794wra.18 for ; Thu, 30 Aug 2018 04:41:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZXrp1luYhJIP4n0GyXQgKnJADxNlE5pIywVcPCMS+cU=; b=QCUlIoywcLn+JJPpSdwyDAycLFKtv2krySIpHmbplXr04FeVzisTDjLczbaXnhnHPi l1PI4ZVMtCF2bJDBn/wJ3D9hcxRX3smo71XdZAXL5pDd5QEFWlAASHT9DRs5EFT19R/q Pj7hlVogfiV4c1pqXYsAwp6khx1IgFziE64v4f0SC5YGbmphnbaCqdMRCTi5NYLfk7dd RhE16Qgy5FzWYWjVl8Au8oGU188jtvXjOiCN4NVpOa7+wUP5RaqLpUZwRMKp9lnzksyJ 7Xql5XBjDuLMZv8DhpEOy/lW08eBF9W65FOvOPcL9cfXmuPy91JEfXIbJa8YjJiOYlDX nx/g== X-Gm-Message-State: APzg51BgT+hW1R3h1M39kML6sGZuaa4HglmpAR4DCUorJYfKjbDCssmV bSryJi+mL6/wtbQ5Ytj1fryFCwdKCG1C3sNklEgE1cnXO/MK+5wTeLDRqcrlCEXgCgaDYVaiDFk YZdqoKKd6PubyQyCQozO7+waLtGUGhyPL0epUKaY68qtkdiAp1L0kGTQvDM+JrKOYtVlrrSUdt6 QX1c1Bp7fsLsuP2/OPFs+tJedeFxPJ5N0/f+ErJSiqw+kE2YGglMrLRpH1RCOgm97mnBCr6AZHr 6C2WiJlSa5HeUfOjY2M8CTeCW1JqiqJV5Auz/6utYKypUx5uzbJlWxKVUCih6vCZ/khvRQmyTR2 gR1aEExhz/QgAQJ3xXRuJn8yJDLZYsEXsuUEAQz09hD4Q7BDitD9R91R3dyEDU6C0vA3nNYdYfV W X-Received: by 2002:a1c:ef0f:: with SMTP id n15-v6mr1496819wmh.116.1535629293815; Thu, 30 Aug 2018 04:41:33 -0700 (PDT) X-Received: by 2002:a1c:ef0f:: with SMTP id n15-v6mr1496787wmh.116.1535629293116; Thu, 30 Aug 2018 04:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629293; cv=none; d=google.com; s=arc-20160816; b=MCwsr40bEOsSWekkA7ESIFfJDDbkgKxbXr+3/UyZV5u1BMjkMbECo6oxVKLu5+pFgJ ZpFhk7VWny+y5qTksyFRW45qovKSJvl6mhNgfqkTY6t8MNkw4hUA2t53TAiJs+g/8OnQ jY3Gu/zQanQ5Lv7/T1dz/AXo5Yx+ryVHcuO185qbK4xD+APpRc/QUZK1H7LWJPEaK8bl T/SbbJ5hBiKqREB3NlVN4x3AVWVzeeR749DMAQ7g9LLGFTQmDMndas/iFxT36jweB6tX Ec3VfktyoPrYvMqpPora/75Prg5viH94spBA8Y/bog6hyo/y9j8TtP11eaAizv8SJrAE BQVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=ZXrp1luYhJIP4n0GyXQgKnJADxNlE5pIywVcPCMS+cU=; b=BNoQlKxHHGfRp5qS4Bgo0fv7pxoESgtNOG2Ei44Rtd/OTTp3T0UY2vIil6oj4NWG5a IYoNhhPW50jd/MIOmDm2Q4rsqlRIOim7iZYINhBwZnf/6wWp4367VzGlpoXDS5IkDwdQ Z1LtiraLtyMVm36MqGEBACCgK5TdOoJuctioK3NS7wUcXT038Yk+4ZUcRzVPobfqSMr3 nfxE7E1oii6gtp3KlttUzkSmIanFF+cvJB5U12K/A1w56ILdGCBH3FB9aotX/YZXOi3f Fr8gDLHmvxJ3F0uvxPgjywXcLIlggbI+M23q3wdhZZC2I787fazLYRVUs2B8DIN6ka8u kOLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CQDTthRq; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y6-v6sor4673827wrh.27.2018.08.30.04.41.32 for (Google Transport Security); Thu, 30 Aug 2018 04:41:33 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CQDTthRq; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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=ZXrp1luYhJIP4n0GyXQgKnJADxNlE5pIywVcPCMS+cU=; b=CQDTthRqqtcN1ufs2a01fqxdr/kNs6fWI4tuV05Bl51I45yCRaOhwJeuVLq2COoKxl frBJ/N/y1s89YtLmD61lAycbLOLLTF0db8371mdV5CkrUHIB4OqvgwpMqa2HqEJ5erXV cz73I1vf0Q3YRNllcJW9lajKpvoVIc6JFbWD0GQ32BBzzM/YZKvg69fdsbCB+jAY2CJ4 qa5p1DPRxkB3fubKdY5z69yjcIW9inj4czCTZ8Pk2Y9ND/FF3DeAxxNEolW//bI2AMaQ R4nqHfd2pTi6R4MWd0G82haf4q4xC1vvoOFkFWodc62D052G9nhiMGMdvmjrksHp4cNx yWyg== X-Google-Smtp-Source: ANB0VdZIxUKmp3XzvRVWDwkfAyMU2reSwM08s9a8no0z5/OE5Qno5M+2uM5JSbSFxxrvsRq8MTkiyA== X-Received: by 2002:adf:ff0b:: with SMTP id k11-v6mr7791832wrr.15.1535629292576; Thu, 30 Aug 2018 04:41:32 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:31 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya Subject: [PATCH v6 08/11] usb, arm64: untag user addresses in devio Date: Thu, 30 Aug 2018 13:41:13 +0200 Message-Id: X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP devio allows to mmap memory regions and keeps them in a list. It also accepts a user address through an ioctl call and searches the memory region list for the region that contains this address. Since the addresses provided to mmap must not be tagged, and the addresses provided to ioctl might be tagged, we might compare tagged and untagged addresses during the search. Untag the provided addresses before searching. Signed-off-by: Andrey Konovalov --- drivers/usb/core/devio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 6ce77b33da61..ed5ab7c8100b 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -1405,7 +1405,7 @@ find_memory_area(struct usb_dev_state *ps, const struct usbdevfs_urb *uurb) { struct usb_memory *usbm = NULL, *iter; unsigned long flags; - unsigned long uurb_start = (unsigned long)uurb->buffer; + unsigned long uurb_start = (unsigned long)untagged_addr(uurb->buffer); spin_lock_irqsave(&ps->lock, flags); list_for_each_entry(iter, &ps->memory_list, memlist) { @@ -1634,7 +1634,8 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb } } else if (uurb->buffer_length > 0) { if (as->usbm) { - unsigned long uurb_start = (unsigned long)uurb->buffer; + unsigned long uurb_start = + (unsigned long)untagged_addr(uurb->buffer); as->urb->transfer_buffer = as->usbm->mem + (uurb_start - as->usbm->vm_start); @@ -1713,7 +1714,8 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb as->ps = ps; as->userurb = arg; if (as->usbm) { - unsigned long uurb_start = (unsigned long)uurb->buffer; + unsigned long uurb_start = + (unsigned long)untagged_addr(uurb->buffer); as->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; as->urb->transfer_dma = as->usbm->dma_handle + From patchwork Thu Aug 30 11:41:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10581539 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38E8F174C for ; Thu, 30 Aug 2018 11:41:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A7F02BA60 for ; Thu, 30 Aug 2018 11:41:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DDFE2BA68; Thu, 30 Aug 2018 11:41:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C64F52BA60 for ; Thu, 30 Aug 2018 11:41:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46C4D6B513F; Thu, 30 Aug 2018 07:41:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 378C66B5142; Thu, 30 Aug 2018 07:41:36 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F3FA6B5143; Thu, 30 Aug 2018 07:41:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by kanga.kvack.org (Postfix) with ESMTP id B04C96B513F for ; Thu, 30 Aug 2018 07:41:35 -0400 (EDT) Received: by mail-wm0-f70.google.com with SMTP id s205-v6so1132956wmf.7 for ; Thu, 30 Aug 2018 04:41:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=W/jdbb2Vq3Kiym03/gav3BOUvcnL67E9+cfyfM7MhIU=; b=CnFVxBiHxk4E61UncnNeqW8OsR8nY3KuuC+q0QVsqPIRd90t2+jK9javVtrKSIxLqs 0MOOirhbHgySE4R6ilEtXbcbHwIatz/C93YM2MQLfisFtFBM+qrKXNUK2G1c3VhwfNnM Zg8UaBQfNFFLh27EaPVjMAaLfbkjWlm3UfDbp7rOddkVr/F6reSE5a6ah3IluOQvQzoL S65ZDaqHB5Dxd//U0/QS7AVHboaNBqZLe4QaB3rqIy/bayBwS/EKB26nZFNJGrLGEQtS ZxLyMzYdoAqmN7MHQz86NT+tIyQjZIAFkBycmpVwgC5DrFkUequQnLuQC8Pa/Ax10PC+ ykEQ== X-Gm-Message-State: APzg51CFT9z9Ejb0h1Ze0+SRPjqVkW7PWqVCrgA+PJ4EqrHEU/tFQOv4 57t6JQszpQ4ACnufnrYh4V1PyIbaKeh5Q9JqaHeoYi5q7NDbQ98jSaDyIn+IkPW/J4A3MyOajPf ic9PWihdJaRuy8ac4q1tWKIziRTMslAW+C44HtElmNdhEBOLqpApzlfiwEqB59ujPUDsTNZzPv9 5ZClf+9+7bGRuBBo8OhSzSlbpNKaimQyxZ1PjrXkjicnn897mL5xG6TafxBQwICY1gqqzqZkUzH jnVJM2rIaRhdXC1qtKLSYm8WeU4p6bZ5F6H4ZIKzALklEEq4uCiTuC7mSXOB29XiDMUtjlPiLn1 G2bvxCkC06MW59PoMH1Q+pvAX4KhWw0B7J6utNn/ZrSYaJ4lHybKdHcrtaSLBOBE7J+JVGfM06B 6 X-Received: by 2002:a1c:1f48:: with SMTP id f69-v6mr1480308wmf.152.1535629295173; Thu, 30 Aug 2018 04:41:35 -0700 (PDT) X-Received: by 2002:a1c:1f48:: with SMTP id f69-v6mr1480280wmf.152.1535629294530; Thu, 30 Aug 2018 04:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629294; cv=none; d=google.com; s=arc-20160816; b=ESHBXLmQ6EYnLe4ZtyE4qftAERQMM7BSBk7Uei1/8fsXol9Ua+hufo04vbEkdg1OQS EBWBNUZHHmFl/1tIb2i4jc9txXXFuC9S3AnycCtSeWjmIqyuYpuvQgV6uxiRYhZQ+VBF K9mQyGuE2zR2VPoy0RM2+a8UJK0VqB5/erkgAAjtNltuzzMv9QKQFUK0rtGmMDrrLJbC 7X9eY5ZzdBaBuVYVFi8JDSfSe0bs1YqB9T3bzhzGhiPHK/WeGmHg8eR1OTtTor2WKzae X0cQZ9LrHX0hwdojjETVM8U7QVYPAJXjcky83HYBvwCwZZedxgqrkZf75KBTBhGAj8dV l1Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=W/jdbb2Vq3Kiym03/gav3BOUvcnL67E9+cfyfM7MhIU=; b=NLR360+yQmfOQiSdDGDnXGm/Bi/kGeygsovYKA6hQTcmaPK3HHD8nIol4CNZ8K7FQ+ qZ0cgckE6OJ+d9mMGRV4n5o45RrwQASipTieA0TcxEhh5DL10eMBlKTHmEARvny+bU5S KX5DR2526pQVi5XsszpNQP8i5mm/aXeP21eRD+CP7K0lKspB3Co+mlCTLM6S9NFGV16z UQaEVpIb8PujUeKw6Wwz0EgLgAK9BY+ltOtaJ3GqT+pIe9CcK8jmMgV/Xuh173VD1EyA xym8/Io6kcKepQWHGrWNymzieaGmIMHjGHVb57oQOMbBX/5fWY32VRkml4OpaqvFDBtW RMIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="DMD4I/SS"; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r196-v6sor56908wmg.11.2018.08.30.04.41.34 for (Google Transport Security); Thu, 30 Aug 2018 04:41:34 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="DMD4I/SS"; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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=W/jdbb2Vq3Kiym03/gav3BOUvcnL67E9+cfyfM7MhIU=; b=DMD4I/SS8lJ+d3U1+HP9Yl6kLLZHPhvAdJS/JxxXCHjmDxUF/UgLbg2LpoqOkcwLuR wQQPHq4FCtWNS5xr7a3yBgBLJiWBX59b39kyQUx1OqIRTZZTjyRpftdyJmGkxbABZFU6 5KDwphISdpfEXbTOa+4UH4EiTU/0Wi30p9H0GhSfdYr6ze+w3YzNJGGCjrGlYOzyxLmh iWSjewMZmvPQ1GwgRIhyGXsGTzAm8HlL91OxzULxqV+6QAR/5fdqnSyQQBmOZsTukWgi 9+fmCsSQzqxxTagM+2Wx2wT5yLGsY3A4DZXaZsUTAtgiarABDJqijOFj2slq5uuV7G9d s3yw== X-Google-Smtp-Source: ANB0VdZJCY9SDGNv4X5vQQOPslJfwglBfynr1JnV8gKw4PAQtLtDlI07kC0OD66facMHWBf1VWf6KA== X-Received: by 2002:a1c:e54:: with SMTP id 81-v6mr1614151wmo.84.1535629293894; Thu, 30 Aug 2018 04:41:33 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:33 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya Subject: [PATCH v6 09/11] arm64: update Documentation/arm64/tagged-pointers.txt Date: Thu, 30 Aug 2018 13:41:14 +0200 Message-Id: <594756b2aa9fea948f4da3cd01ffa8a5acbc5805.1535629099.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Add a note that work on passing tagged user pointers to the kernel via syscalls has started, but might not be complete yet. Signed-off-by: Andrey Konovalov --- Documentation/arm64/tagged-pointers.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/arm64/tagged-pointers.txt b/Documentation/arm64/tagged-pointers.txt index a25a99e82bb1..361481283f00 100644 --- a/Documentation/arm64/tagged-pointers.txt +++ b/Documentation/arm64/tagged-pointers.txt @@ -35,8 +35,9 @@ Using non-zero address tags in any of these locations may result in an error code being returned, a (fatal) signal being raised, or other modes of failure. -For these reasons, passing non-zero address tags to the kernel via -system calls is forbidden, and using a non-zero address tag for sp is +Some initial work for supporting non-zero address tags passed to the +kernel via system calls has been done, but the kernel doesn't provide +any guarantees at this point. Using a non-zero address tag for sp is strongly discouraged. Programs maintaining a frame pointer and frame records that use non-zero From patchwork Thu Aug 30 11:41:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10581543 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8694514BD for ; Thu, 30 Aug 2018 11:41:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 781C62BA64 for ; Thu, 30 Aug 2018 11:41:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B71A2BA69; Thu, 30 Aug 2018 11:41:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0147D2BA64 for ; Thu, 30 Aug 2018 11:41:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B22646B5140; Thu, 30 Aug 2018 07:41:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A811B6B5142; Thu, 30 Aug 2018 07:41:37 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D2546B5144; Thu, 30 Aug 2018 07:41:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 2B1626B5140 for ; Thu, 30 Aug 2018 07:41:37 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id r14-v6so1154755wmh.0 for ; Thu, 30 Aug 2018 04:41:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7j7XmdTnSVmbmp015wk6qie+oiQQcCjLk4bzMit5h2s=; b=p/BOUCiwDppyzMJaU/O4blNiGwLjo6MN3vaAP+WaIPjta2Vj+EBuIJz2YE/Cavv8SC 0PbRUtfrxS6CWPbl1S9mj0WdWDbjQUaFWudsS7+TbxOSfYRC6V0z3s5cyA75URSXTVoZ QPAvC6AH1zGhOyV4JRijZuTJYuisBUTavbCDzsKBDOWHI7MhvAFoS5206Bk66zvm8arB HAYi4SDHVkRyrpl7sL6TN3WK+p1ISFbG6Te6Nj79Ma6X9bk1c7ER4w+0cCQXlN8kChKs gqyN5XyVHRfRQKIoC2aBEJFoDQXhLNhnQQ/k1Fp6WnMJ7iybG5hoKU5NyjyYwFE1BNnm ticA== X-Gm-Message-State: APzg51BDQVHvhvvSaOxNZL2eWHauAjmbhWAVXJ/QtEnCTWAH+MJrNwy0 L5CbZp298I5FHPEika+3jMBmalNeAfpksU5KddM0jzHZzIcpLNTgs97sJvu4Bd6Fb6IbRrTK5tm JIM5aZHcDf0lWrtGY05jIgrFbbZyHHxetHmHBAE8E5YgfNWJok9p593Hrqm9HM+IXWXL5fDITAI GBRfptvA019bpadmRlY7oL6qVf/9I6uyfMtsaN30bD34pnAuNI1ArvFiJXen4f3ASB/u3OLDAQi 5dOXusEnE3AdCbam/9lqnJgtW38DwdalWus7oVbgYDZlfUo2MyMsPsWDudv83utff6x1U0S1x7x 8W1w32O58XYfyTsWd8pvMeYkA0QIOv/5Jcj3GSDNSRkTjL5Jo0ICBOAsac41zEnsOy/6n3L5ZPr / X-Received: by 2002:a5d:5450:: with SMTP id w16-v6mr7759196wrv.4.1535629296689; Thu, 30 Aug 2018 04:41:36 -0700 (PDT) X-Received: by 2002:a5d:5450:: with SMTP id w16-v6mr7759156wrv.4.1535629295827; Thu, 30 Aug 2018 04:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629295; cv=none; d=google.com; s=arc-20160816; b=vQGgnJGf/bh0sndx6XHBg5eNk5HnAwxz5cMWLifGFYVg+pSqAhELt8SvB3ap8podnh 6UfTzzGmIwzPTjwRvHZOVhn9GIYd9zEUHO9d5Y786yDyxIFk68PPYO6h+4chP9HFjqll EVUTtWw8VlMV9+kC4AWK33kPdHCcDzXwabHK0lHNfNW4E8pcJ+NaFmDhZ3E82dDBbpF3 mWX85gMx9fmvYVyEZ/mKD40BJVkOj2AfeA7cgfhA4BLqMRS76tKoEAFtmEuEFf58bN5k uqaTbaQAuarBlROD0MXbVKXfcKuUGPdO71M+sYr6P0REv4g0KeMLF3uxNUxWlb8S6yb4 SD9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=7j7XmdTnSVmbmp015wk6qie+oiQQcCjLk4bzMit5h2s=; b=CE6VAY3mXyxSHSNb/ZIl9RXMEOVVqvjdHIA+pxP/lVaNg5m4nSy1+yl6mp6EYBwr7W onfRzl3cs8cgEtlI+L0lhH5ML03UdGSUm2HT0tFc/sa+DxeY4B5kOjtJpW5ew/SDpeng 4f08UmygDS2mPb2NGFSFG5/gsiURVnzSECvGvThY6PsrO77RivoQO8ymj0Rbs/5nI0Iz mXMkdsI9d4+VARfHPFl9z0O3F+BFNEjkw94g5Pr2Ro4ytjM+iClrMr3shMEQk8K6EicE wMtcRZ4uF+iq/Pe9aGUKI/5LaOuNEN6o25ryHJnW8pisWcRB6+10ISkL7TAgARc14Imc bEJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BVW0OkFl; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id k12-v6sor4755602wrl.2.2018.08.30.04.41.35 for (Google Transport Security); Thu, 30 Aug 2018 04:41:35 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BVW0OkFl; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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=7j7XmdTnSVmbmp015wk6qie+oiQQcCjLk4bzMit5h2s=; b=BVW0OkFljrINNZdwpZG1fLFvC/nUNg+PNl5V7e4irtxMf/8ds5fOmDiRg0jiFxSrpC AoYJuALMe+AwwNcfL+XFZr5OzegbBxhqq4zyR3efYXh1fkP+iudAXgQaGXgjA0W+3l/D WukQPVBIbghbxssWNq1MCLUOyqolxuuPzS34fFrWgLDrwmu1SE0O2z3sdJMrXC1j3irA q1hnmunuGfmDepy467DjEY/c1lMVlc9uRJcbBb/wHYMZetaFrAnnEbaGp+N/IU4nvYzN ELf+B+wUUsGUHENjxGoO9fJ1uoV7CDg40dpQ2QR74jOyv51pz1LyZw4GDWYM8APpnIYu zuMA== X-Google-Smtp-Source: ANB0VdaasFCpPPAdrf+W+nL5HWuIz30Gs7DZp4dQAqVCpoXf0LEuYlfMYwsCQB2tjDdTqw5MKflljw== X-Received: by 2002:adf:ad8e:: with SMTP id w14-v6mr7818521wrc.178.1535629295169; Thu, 30 Aug 2018 04:41:35 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:34 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya Subject: [PATCH v6 10/11] selftests, arm64: add a selftest for passing tagged pointers to kernel Date: Thu, 30 Aug 2018 13:41:15 +0200 Message-Id: <087a7b141ae275a2ea2b53c9df96a1fbce9dc79a.1535629099.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a simple test, that calls the uname syscall with a tagged user pointer as an argument. Without the kernel accepting tagged user pointers the test fails with EFAULT. Signed-off-by: Andrey Konovalov --- tools/testing/selftests/arm64/.gitignore | 1 + tools/testing/selftests/arm64/Makefile | 11 +++++++++++ .../testing/selftests/arm64/run_tags_test.sh | 12 ++++++++++++ tools/testing/selftests/arm64/tags_test.c | 19 +++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 tools/testing/selftests/arm64/.gitignore create mode 100644 tools/testing/selftests/arm64/Makefile create mode 100755 tools/testing/selftests/arm64/run_tags_test.sh create mode 100644 tools/testing/selftests/arm64/tags_test.c diff --git a/tools/testing/selftests/arm64/.gitignore b/tools/testing/selftests/arm64/.gitignore new file mode 100644 index 000000000000..e8fae8d61ed6 --- /dev/null +++ b/tools/testing/selftests/arm64/.gitignore @@ -0,0 +1 @@ +tags_test diff --git a/tools/testing/selftests/arm64/Makefile b/tools/testing/selftests/arm64/Makefile new file mode 100644 index 000000000000..a61b2e743e99 --- /dev/null +++ b/tools/testing/selftests/arm64/Makefile @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0 + +# ARCH can be overridden by the user for cross compiling +ARCH ?= $(shell uname -m 2>/dev/null || echo not) + +ifneq (,$(filter $(ARCH),aarch64 arm64)) +TEST_GEN_PROGS := tags_test +TEST_PROGS := run_tags_test.sh +endif + +include ../lib.mk diff --git a/tools/testing/selftests/arm64/run_tags_test.sh b/tools/testing/selftests/arm64/run_tags_test.sh new file mode 100755 index 000000000000..745f11379930 --- /dev/null +++ b/tools/testing/selftests/arm64/run_tags_test.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +echo "--------------------" +echo "running tags test" +echo "--------------------" +./tags_test +if [ $? -ne 0 ]; then + echo "[FAIL]" +else + echo "[PASS]" +fi diff --git a/tools/testing/selftests/arm64/tags_test.c b/tools/testing/selftests/arm64/tags_test.c new file mode 100644 index 000000000000..1452ed7d33f9 --- /dev/null +++ b/tools/testing/selftests/arm64/tags_test.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include + +#define SHIFT_TAG(tag) ((uint64_t)(tag) << 56) +#define SET_TAG(ptr, tag) (((uint64_t)(ptr) & ~SHIFT_TAG(0xff)) | \ + SHIFT_TAG(tag)) + +int main(void) +{ + struct utsname utsname; + void *ptr = &utsname; + void *tagged_ptr = (void *)SET_TAG(ptr, 0x42); + int err = uname(tagged_ptr); + return err; +} From patchwork Thu Aug 30 11:41:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10581547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 85E2E14BD for ; Thu, 30 Aug 2018 11:42:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72C3B2BA60 for ; Thu, 30 Aug 2018 11:42:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6526E2BA68; Thu, 30 Aug 2018 11:42:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 870CE2BA64 for ; Thu, 30 Aug 2018 11:41:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E76266B5144; Thu, 30 Aug 2018 07:41:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DFEBE6B5145; Thu, 30 Aug 2018 07:41:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C29C16B5146; Thu, 30 Aug 2018 07:41:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 2C62F6B5144 for ; Thu, 30 Aug 2018 07:41:42 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id m28-v6so5744013wrf.14 for ; Thu, 30 Aug 2018 04:41:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=lv7ND5exX638DQEvypjIGET4j+Zey23iCggxJFO+HIE=; b=KF8XqWvTLE7hg36yrsV04tLKtVsWx3nwe6GQg8SrPjwwKtXoUmS+G7lIKzujjjWQhc Q6Kllg6q/BuoTTwaEDfLTRUTgIO+IlNneVXH+QajElg5Ee5x4+f56atwlYyTxu91dUd9 Z1sftN2qLeXMkcKD7U1Q4wCFY86XjnlqNSEetXZjBVGN3IdcHpAHPclQEF7R9zSPr54g 0QFzqOzW65ye2wU4BiHAOJVzroqsAdDjSRcavQibbj197F0r7UHsDwOkk2cWCjQwBRQp WG/BARVIaD6+GjI2O/kuZxhrYmLVOh0wTAJf8UOZlpFFmgc2DexnHoNIO0z5B4TW4Ldq 7iWg== X-Gm-Message-State: APzg51Dy5NqDKIG/ztag3jMYLQovFE+AXFDziO7PKaWss8R1/XdB2lAt G3lTDKtJgJaLWPhOYoR0QXkKMUWeDdrGszUe6f3NQKWU0Q9ehveg+UeRWNqt0dG/BujjfQf5Cu/ bJYbx6zQJhNhMkYH70pzF+4fYsmGplyUEic35aEwmbRgpnGxyq5vZLG1nJzf1OymaNsEhEEqcMq RRmyEWudNAtDuSSQ/ziBhwqTBbwUTqpdCLklZyQ5Vn72EHwbrIWK1NA1pf/kI3CzZw8FKtdvWLl +M9H1IYX8noOya6DiVQQxFyg83rej0IRVjIIu1VUa7pVU5x68orAS+jZBc3gwxQVkPxmpCR4Fmm 2OKREfHV/7/oCLq0G8NgH/NQ7RJqYkSjY4QM2h7OT0/rm9yxVOUGGGu0jfRd0pgSthhgUW2e/He 5 X-Received: by 2002:a1c:8153:: with SMTP id c80-v6mr1643145wmd.123.1535629301519; Thu, 30 Aug 2018 04:41:41 -0700 (PDT) X-Received: by 2002:a1c:8153:: with SMTP id c80-v6mr1643007wmd.123.1535629298379; Thu, 30 Aug 2018 04:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629298; cv=none; d=google.com; s=arc-20160816; b=X1+AHy1e+7Q2Hs2232/GH18vwTVHf7UHGmRlOkUCs/QqRjGmyncmWkmo0aNdxCTtUs ZCXviMZMlsqNAkKKSgLxpPw58LrSPDnSZnkdVlwHzNZnIwytWlKomxsjMCkzHKKu72Hl T0yHhl3QmjM4YQulouEjXYDgbN/bLWjR6f0FCgNsa4i2GW9f9SfBqBV0apTTOpgpEdff zHZ11fVmwh21Bt2nR3Fhd9UOvQRu3jC43wZHIqWlS/E4Ta3Sg3p6XhB3UQmRi4v3mLVY zm6/3erRlhRmpH/OnJfcbB5zCFXrV22h54G56TlLy5Q7NFBEuLwUGBEdOQIamKYqAwk5 dwLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=lv7ND5exX638DQEvypjIGET4j+Zey23iCggxJFO+HIE=; b=NTvDONnIVd4uoTouZZhU740gguskMa/aC1vT0a6AA83Ug8GfS9Ce/7ZFl86dlB/hxO Vm3f7S2BKtUMN0h84JoC5czUDyfsvhexXfUr7tUvYCUb2hsyBy2OFKGVMusOG86MOL0R 1kHovRhgyGO9XO0DYP+3BSmLDQXX7mSAf+G3qGRp2hrZZrn+GVEBWyi5TAWGV/iT5cue v/w3f0C7b8T7PHCebXacEdkbd6D6UHEdDRha/phFW4tUpsXb5sr/q35wIcY5DKrU3SY9 mFGP8ocUC+aODiDsnWWn4IQOfrIXmqxa92iM6oaFvpjyx4GC2/Rpj2mLMkyp8jQC/rT7 TkZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TuM82Y9y; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a12-v6sor49826wmb.16.2018.08.30.04.41.38 for (Google Transport Security); Thu, 30 Aug 2018 04:41:38 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TuM82Y9y; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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=lv7ND5exX638DQEvypjIGET4j+Zey23iCggxJFO+HIE=; b=TuM82Y9yLQ8Bg7KAGaBbJfAO8HnAiZpFQrN8Z4S8AX8ZjoLvkr/B7Ldoye835EEBxw 70Gtr5epiSKBhf/vLv1MP/wJIkuw8PYFDKKGTxbCoE/iikFvBvhipdWZVh+B/hYttMnD 35q2ksgx6+iZDhKmw2YphG2j4IH1yetsJ/6gxB7+F/hnljIphH2gZO6mL8zfiTtJslh7 +R14OhucVZdLREu4SLOPjgh/l/5mzXIO5KfhFm/mgWbof27CGaPMrIL16uE0aAswyING xRhSWWHty5GVqIRNBOqTlAP6Q37O/Pqx+g+ouqJQNdbewCG1kHsxcDmlXQik5Yac0mB3 78Hg== X-Google-Smtp-Source: ANB0Vdbo3jB/9YiwQMSuS0mFv3ZpJ1FtJ9e4pThSdKcmM5vAJJkHY1T4IBcfm7N/l1VrmGYyzBpRTg== X-Received: by 2002:a1c:168a:: with SMTP id 132-v6mr1650573wmw.13.1535629296715; Thu, 30 Aug 2018 04:41:36 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:35 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya Subject: [PATCH v6 11/11] arm64: annotate user pointers casts detected by sparse Date: Thu, 30 Aug 2018 13:41:16 +0200 Message-Id: <5d54526e5ff2e5ad63d0dfdd9ab17cf359afa4f2.1535629099.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This patch adds __force annotations for __user pointers casts detected by sparse with the -Wcast-from-as flag enabled (added in [1]). [1] https://github.com/lucvoo/sparse-dev/commit/5f960cb10f56ec2017c128ef9d16060e0145f292 Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/compat.h | 2 +- arch/arm64/include/asm/uaccess.h | 4 +-- arch/arm64/kernel/perf_callchain.c | 4 +-- arch/arm64/kernel/signal.c | 16 +++++----- arch/arm64/kernel/signal32.c | 6 ++-- arch/arm64/mm/fault.c | 2 +- block/compat_ioctl.c | 15 +++++---- drivers/ata/libata-scsi.c | 2 +- drivers/block/loop.c | 2 +- drivers/gpio/gpiolib.c | 8 +++-- drivers/input/evdev.c | 2 +- drivers/media/dvb-core/dvb_frontend.c | 3 +- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 9 +++--- drivers/mmc/core/block.c | 6 ++-- drivers/mtd/mtdchar.c | 2 +- drivers/net/tap.c | 2 +- drivers/net/tun.c | 2 +- drivers/spi/spidev.c | 6 ++-- drivers/tty/tty_ioctl.c | 3 +- drivers/tty/vt/vt_ioctl.c | 5 +-- drivers/usb/core/devio.c | 8 +++-- drivers/vfio/vfio.c | 6 ++-- drivers/video/fbdev/core/fbmem.c | 4 +-- drivers/xen/gntdev.c | 6 ++-- drivers/xen/privcmd.c | 4 +-- fs/aio.c | 2 +- fs/autofs/dev-ioctl.c | 3 +- fs/autofs/root.c | 2 +- fs/binfmt_elf.c | 10 +++--- fs/btrfs/ioctl.c | 2 +- fs/compat_ioctl.c | 32 ++++++++++--------- fs/ext2/ioctl.c | 2 +- fs/ext4/ioctl.c | 2 +- fs/fat/file.c | 3 +- fs/fuse/file.c | 2 +- fs/namespace.c | 2 +- fs/readdir.c | 4 +-- fs/signalfd.c | 10 +++--- include/linux/mm.h | 2 +- include/linux/pagemap.h | 8 ++--- include/linux/socket.h | 2 +- ipc/shm.c | 4 +-- kernel/futex.c | 6 ++-- kernel/futex_compat.c | 2 +- kernel/power/user.c | 2 +- kernel/signal.c | 2 +- lib/iov_iter.c | 16 +++++----- lib/strncpy_from_user.c | 2 +- lib/strnlen_user.c | 4 +-- lib/test_kasan.c | 2 +- mm/memory.c | 2 +- mm/migrate.c | 4 +-- mm/process_vm_access.c | 13 ++++---- net/bluetooth/hidp/sock.c | 2 +- net/compat.c | 12 ++++--- sound/core/control_compat.c | 5 +-- sound/core/pcm_native.c | 5 +-- sound/core/timer_compat.c | 3 +- 58 files changed, 163 insertions(+), 140 deletions(-) diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h index 1a037b94eba1..66e023fcea0a 100644 --- a/arch/arm64/include/asm/compat.h +++ b/arch/arm64/include/asm/compat.h @@ -155,7 +155,7 @@ static inline void __user *compat_ptr(compat_uptr_t uptr) static inline compat_uptr_t ptr_to_compat(void __user *uptr) { - return (u32)(unsigned long)uptr; + return (u32)(__force unsigned long)uptr; } #define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current))) diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index fa7318d3d7d5..9b22c0be5c0b 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -76,7 +76,7 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si { unsigned long ret, limit = current_thread_info()->addr_limit; - __chk_user_ptr(addr); + __chk_user_ptr((void __force *)addr); asm volatile( // A + B <= C + 1 for all A,B,C, in four easy steps: // 1: X = A + B; X' = X % 2^64 @@ -103,7 +103,7 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si * pass on to access_ok(), for instance. */ #define untagged_addr(addr) \ - ((__typeof__(addr))sign_extend64((__u64)(addr), 55)) + ((__typeof__(addr))sign_extend64((__force __u64)(addr), 55)) #define access_ok(type, addr, size) \ __range_ok(untagged_addr(addr), size) diff --git a/arch/arm64/kernel/perf_callchain.c b/arch/arm64/kernel/perf_callchain.c index bcafd7dcfe8b..e2d781b9e7ea 100644 --- a/arch/arm64/kernel/perf_callchain.c +++ b/arch/arm64/kernel/perf_callchain.c @@ -123,7 +123,7 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry, tail = (struct frame_tail __user *)regs->regs[29]; while (entry->nr < entry->max_stack && - tail && !((unsigned long)tail & 0xf)) + tail && !((__force unsigned long)tail & 0xf)) tail = user_backtrace(tail, entry); } else { #ifdef CONFIG_COMPAT @@ -133,7 +133,7 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry, tail = (struct compat_frame_tail __user *)regs->compat_fp - 1; while ((entry->nr < entry->max_stack) && - tail && !((unsigned long)tail & 0x3)) + tail && !((__force unsigned long)tail & 0x3)) tail = compat_user_backtrace(tail, entry); #endif } diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 5dcc942906db..da67d0bd1628 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -351,7 +351,7 @@ static int parse_user_sigframe(struct user_ctxs *user, user->fpsimd = NULL; user->sve = NULL; - if (!IS_ALIGNED((unsigned long)base, 16)) + if (!IS_ALIGNED((__force unsigned long)base, 16)) goto invalid; while (1) { @@ -450,7 +450,7 @@ static int parse_user_sigframe(struct user_ctxs *user, have_extra_context = true; base = (__force void __user *)extra_datap; - if (!IS_ALIGNED((unsigned long)base, 16)) + if (!IS_ALIGNED((__force unsigned long)base, 16)) goto invalid; if (!IS_ALIGNED(extra_size, 16)) @@ -742,16 +742,16 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka, __sigrestore_t sigtramp; regs->regs[0] = usig; - regs->sp = (unsigned long)user->sigframe; - regs->regs[29] = (unsigned long)&user->next_frame->fp; - regs->pc = (unsigned long)ka->sa.sa_handler; + regs->sp = (__force unsigned long)user->sigframe; + regs->regs[29] = (__force unsigned long)&user->next_frame->fp; + regs->pc = (__force unsigned long)ka->sa.sa_handler; if (ka->sa.sa_flags & SA_RESTORER) sigtramp = ka->sa.sa_restorer; else sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp); - regs->regs[30] = (unsigned long)sigtramp; + regs->regs[30] = (__force unsigned long)sigtramp; } static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, @@ -777,8 +777,8 @@ static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set, setup_return(regs, &ksig->ka, &user, usig); if (ksig->ka.sa.sa_flags & SA_SIGINFO) { err |= copy_siginfo_to_user(&frame->info, &ksig->info); - regs->regs[1] = (unsigned long)&frame->info; - regs->regs[2] = (unsigned long)&frame->uc; + regs->regs[1] = (__force unsigned long)&frame->info; + regs->regs[2] = (__force unsigned long)&frame->uc; } } diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c index 24b09003f821..184178a552d6 100644 --- a/arch/arm64/kernel/signal32.c +++ b/arch/arm64/kernel/signal32.c @@ -483,8 +483,10 @@ int compat_setup_rt_frame(int usig, struct ksignal *ksig, if (err == 0) { compat_setup_return(regs, &ksig->ka, frame->sig.retcode, frame, usig); - regs->regs[1] = (compat_ulong_t)(unsigned long)&frame->info; - regs->regs[2] = (compat_ulong_t)(unsigned long)&frame->sig.uc; + regs->regs[1] = + (compat_ulong_t)(__force unsigned long)&frame->info; + regs->regs[2] = + (compat_ulong_t)(__force unsigned long)&frame->sig.uc; } return err; diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 871fb3c38b23..0978b838f46e 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -299,7 +299,7 @@ static void __do_kernel_fault(unsigned long addr, unsigned int esr, static void __do_user_fault(struct siginfo *info, unsigned int esr) { - current->thread.fault_address = (unsigned long)info->si_addr; + current->thread.fault_address = (__force unsigned long)info->si_addr; /* * If the faulting address is in the kernel, we must sanitize the ESR. diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index 6ca015f92766..35aa46e0e289 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c @@ -85,7 +85,7 @@ static int compat_hdio_ioctl(struct block_device *bdev, fmode_t mode, p = compat_alloc_user_space(sizeof(unsigned long)); error = __blkdev_driver_ioctl(bdev, mode, - cmd, (unsigned long)p); + cmd, (__force unsigned long)p); if (error == 0) { unsigned int __user *uvp = compat_ptr(arg); unsigned long v; @@ -138,7 +138,7 @@ static int compat_cdrom_read_audio(struct block_device *bdev, fmode_t mode, return -EFAULT; return __blkdev_driver_ioctl(bdev, mode, cmd, - (unsigned long)cdread_audio); + (__force unsigned long)cdread_audio); } static int compat_cdrom_generic_command(struct block_device *bdev, fmode_t mode, @@ -170,7 +170,8 @@ static int compat_cdrom_generic_command(struct block_device *bdev, fmode_t mode, put_user(compat_ptr(data), &cgc->reserved[0])) return -EFAULT; - return __blkdev_driver_ioctl(bdev, mode, cmd, (unsigned long)cgc); + return __blkdev_driver_ioctl(bdev, mode, cmd, + (__force unsigned long)cgc); } struct compat_blkpg_ioctl_arg { @@ -199,7 +200,7 @@ static int compat_blkpg_ioctl(struct block_device *bdev, fmode_t mode, if (err) return err; - return blkdev_ioctl(bdev, mode, cmd, (unsigned long)a); + return blkdev_ioctl(bdev, mode, cmd, (__force unsigned long)a); } #define BLKBSZGET_32 _IOR(0x12, 112, int) @@ -276,7 +277,7 @@ static int compat_blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode, case DVD_READ_STRUCT: case DVD_WRITE_STRUCT: case DVD_AUTH: - arg = (unsigned long)compat_ptr(arg); + arg = (__force unsigned long)compat_ptr(arg); /* These intepret arg as an unsigned long, not as a pointer, * so we must not do compat_ptr() conversion. */ case HDIO_SET_MULTCOUNT: @@ -355,10 +356,10 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) */ case BLKRRPART: return blkdev_ioctl(bdev, mode, cmd, - (unsigned long)compat_ptr(arg)); + (__force unsigned long)compat_ptr(arg)); case BLKBSZSET_32: return blkdev_ioctl(bdev, mode, BLKBSZSET, - (unsigned long)compat_ptr(arg)); + (__force unsigned long)compat_ptr(arg)); case BLKPG: return compat_blkpg_ioctl(bdev, mode, cmd, compat_ptr(arg)); case BLKRAGET: diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 1984fc78c750..9d4528ec8b43 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -792,7 +792,7 @@ int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *scsidev, return put_user(val, (unsigned long __user *)arg); case HDIO_SET_32BIT: - val = (unsigned long) arg; + val = (__force unsigned long) arg; rc = 0; spin_lock_irqsave(ap->lock, flags); if (ap->pflags & ATA_PFLAG_PIO32CHANGE) { diff --git a/drivers/block/loop.c b/drivers/block/loop.c index ea9debf59b22..910f7910ab12 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1608,7 +1608,7 @@ static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode, case LOOP_CLR_FD: case LOOP_GET_STATUS64: case LOOP_SET_STATUS64: - arg = (unsigned long) compat_ptr(arg); + arg = (__force unsigned long) compat_ptr(arg); /* fall through */ case LOOP_SET_FD: case LOOP_CHANGE_FD: diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e8f8a1999393..1f678dffe159 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -477,7 +477,8 @@ static long linehandle_ioctl(struct file *filep, unsigned int cmd, static long linehandle_ioctl_compat(struct file *filep, unsigned int cmd, unsigned long arg) { - return linehandle_ioctl(filep, cmd, (unsigned long)compat_ptr(arg)); + return linehandle_ioctl(filep, cmd, + (__force unsigned long)compat_ptr(arg)); } #endif @@ -792,7 +793,8 @@ static long lineevent_ioctl(struct file *filep, unsigned int cmd, static long lineevent_ioctl_compat(struct file *filep, unsigned int cmd, unsigned long arg) { - return lineevent_ioctl(filep, cmd, (unsigned long)compat_ptr(arg)); + return lineevent_ioctl(filep, cmd, + (__force unsigned long)compat_ptr(arg)); } #endif @@ -1091,7 +1093,7 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) static long gpio_ioctl_compat(struct file *filp, unsigned int cmd, unsigned long arg) { - return gpio_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); + return gpio_ioctl(filp, cmd, (__force unsigned long)compat_ptr(arg)); } #endif diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 370206f987f9..61947c834e01 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -1108,7 +1108,7 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, return 0; case EVIOCRMFF: - return input_ff_erase(dev, (int)(unsigned long) p, file); + return input_ff_erase(dev, (int)(__force unsigned long)p, file); case EVIOCGEFFECTS: i = test_bit(EV_FF, dev->evbit) ? diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index c4e7ebfe4d29..ec97b26cbd72 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -2180,7 +2180,8 @@ static long dvb_frontend_compat_ioctl(struct file *file, unsigned int cmd, return err; } - return dvb_frontend_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); + return dvb_frontend_ioctl(file, cmd, + (__force unsigned long)compat_ptr(arg)); } #endif diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c index 6481212fda77..97a4e84e2070 100644 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c @@ -505,7 +505,8 @@ static int get_v4l2_plane32(struct v4l2_plane __user *p64, break; case V4L2_MEMORY_USERPTR: if (get_user(p, &p32->m.userptr) || - put_user((unsigned long)compat_ptr(p), &p64->m.userptr)) + put_user((__force unsigned long)compat_ptr(p), + &p64->m.userptr)) return -EFAULT; break; case V4L2_MEMORY_DMABUF: @@ -657,7 +658,7 @@ static int get_v4l2_buffer32(struct v4l2_buffer __user *p64, compat_ulong_t userptr; if (get_user(userptr, &p32->m.userptr) || - put_user((unsigned long)compat_ptr(userptr), + put_user((__force unsigned long)compat_ptr(userptr), &p64->m.userptr)) return -EFAULT; break; @@ -1340,9 +1341,9 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar * Otherwise, it will pass the newly allocated @new_p64 argument. */ if (compatible_arg) - err = native_ioctl(file, cmd, (unsigned long)p32); + err = native_ioctl(file, cmd, (__force unsigned long)p32); else - err = native_ioctl(file, cmd, (unsigned long)new_p64); + err = native_ioctl(file, cmd, (__force unsigned long)new_p64); if (err == -ENOTTY) return err; diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index a0b9102c4c6e..eb2c21b55fe6 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -799,7 +799,8 @@ static int mmc_blk_ioctl(struct block_device *bdev, fmode_t mode, static int mmc_blk_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { - return mmc_blk_ioctl(bdev, mode, cmd, (unsigned long) compat_ptr(arg)); + return mmc_blk_ioctl(bdev, mode, cmd, + (__force unsigned long) compat_ptr(arg)); } #endif @@ -2491,7 +2492,8 @@ static long mmc_rpmb_ioctl(struct file *filp, unsigned int cmd, static long mmc_rpmb_ioctl_compat(struct file *filp, unsigned int cmd, unsigned long arg) { - return mmc_rpmb_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); + return mmc_rpmb_ioctl(filp, cmd, + (__force unsigned long)compat_ptr(arg)); } #endif diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 02389528f622..d493647821d5 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -1090,7 +1090,7 @@ static long mtdchar_compat_ioctl(struct file *file, unsigned int cmd, } default: - ret = mtdchar_ioctl(file, cmd, (unsigned long)argp); + ret = mtdchar_ioctl(file, cmd, (__force unsigned long)argp); } mutex_unlock(&mtd_mutex); diff --git a/drivers/net/tap.c b/drivers/net/tap.c index f0f7cd977667..eb710bc2d19d 100644 --- a/drivers/net/tap.c +++ b/drivers/net/tap.c @@ -1128,7 +1128,7 @@ static long tap_ioctl(struct file *file, unsigned int cmd, static long tap_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - return tap_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); + return tap_ioctl(file, cmd, (__force unsigned long)compat_ptr(arg)); } #endif diff --git a/drivers/net/tun.c b/drivers/net/tun.c index ebd07ad82431..29be50de0d3d 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -3191,7 +3191,7 @@ static long tun_chr_compat_ioctl(struct file *file, case TUNSETSNDBUF: case SIOCGIFHWADDR: case SIOCSIFHWADDR: - arg = (unsigned long)compat_ptr(arg); + arg = (__force unsigned long)compat_ptr(arg); break; default: arg = (compat_ulong_t)arg; diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index cda10719d1d1..d9a91676a406 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -524,8 +524,8 @@ spidev_compat_ioc_message(struct file *filp, unsigned int cmd, /* Convert buffer pointers */ for (n = 0; n < n_ioc; n++) { - ioc[n].rx_buf = (uintptr_t) compat_ptr(ioc[n].rx_buf); - ioc[n].tx_buf = (uintptr_t) compat_ptr(ioc[n].tx_buf); + ioc[n].rx_buf = (__force uintptr_t) compat_ptr(ioc[n].rx_buf); + ioc[n].tx_buf = (__force uintptr_t) compat_ptr(ioc[n].tx_buf); } /* translate to spi_message, execute */ @@ -546,7 +546,7 @@ spidev_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) && _IOC_DIR(cmd) == _IOC_WRITE) return spidev_compat_ioc_message(filp, cmd, arg); - return spidev_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); + return spidev_ioctl(filp, cmd, (__force unsigned long)compat_ptr(arg)); } #else #define spidev_compat_ioctl NULL diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index d99fec44036c..5abd148bb459 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c @@ -949,7 +949,8 @@ long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file, switch (cmd) { case TIOCGLCKTRMIOS: case TIOCSLCKTRMIOS: - return tty_mode_ioctl(tty, file, cmd, (unsigned long) compat_ptr(arg)); + return tty_mode_ioctl(tty, file, cmd, + (__force unsigned long) compat_ptr(arg)); default: return -ENOIOCTLCMD; } diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c index a78ad10a119b..794445d10965 100644 --- a/drivers/tty/vt/vt_ioctl.c +++ b/drivers/tty/vt/vt_ioctl.c @@ -1132,7 +1132,8 @@ compat_kdfontop_ioctl(struct compat_console_font_op __user *fontop, i = con_font_op(vc, op); if (i) return i; - ((struct compat_console_font_op *)op)->data = (unsigned long)op->data; + ((struct compat_console_font_op *)op)->data = + (__force unsigned long)op->data; if (copy_to_user(fontop, op, sizeof(struct compat_console_font_op))) return -EFAULT; return 0; @@ -1239,7 +1240,7 @@ long vt_compat_ioctl(struct tty_struct *tty, * but we have to convert it to a proper 64 bit pointer. */ default: - arg = (unsigned long)compat_ptr(arg); + arg = (__force unsigned long)compat_ptr(arg); goto fallback; } out: diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index ed5ab7c8100b..e2fd6ca2d7a3 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -1405,7 +1405,8 @@ find_memory_area(struct usb_dev_state *ps, const struct usbdevfs_urb *uurb) { struct usb_memory *usbm = NULL, *iter; unsigned long flags; - unsigned long uurb_start = (unsigned long)untagged_addr(uurb->buffer); + unsigned long uurb_start = + (__force unsigned long)untagged_addr(uurb->buffer); spin_lock_irqsave(&ps->lock, flags); list_for_each_entry(iter, &ps->memory_list, memlist) { @@ -1635,7 +1636,8 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb } else if (uurb->buffer_length > 0) { if (as->usbm) { unsigned long uurb_start = - (unsigned long)untagged_addr(uurb->buffer); + (__force unsigned long)untagged_addr( + uurb->buffer); as->urb->transfer_buffer = as->usbm->mem + (uurb_start - as->usbm->vm_start); @@ -1715,7 +1717,7 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb as->userurb = arg; if (as->usbm) { unsigned long uurb_start = - (unsigned long)untagged_addr(uurb->buffer); + (__force unsigned long)untagged_addr(uurb->buffer); as->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; as->urb->transfer_dma = as->usbm->dma_handle + diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 64833879f75d..8f69175eba0e 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1204,7 +1204,7 @@ static long vfio_fops_unl_ioctl(struct file *filep, static long vfio_fops_compat_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) { - arg = (unsigned long)compat_ptr(arg); + arg = (__force unsigned long)compat_ptr(arg); return vfio_fops_unl_ioctl(filep, cmd, arg); } #endif /* CONFIG_COMPAT */ @@ -1576,7 +1576,7 @@ static long vfio_group_fops_unl_ioctl(struct file *filep, static long vfio_group_fops_compat_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) { - arg = (unsigned long)compat_ptr(arg); + arg = (__force unsigned long)compat_ptr(arg); return vfio_group_fops_unl_ioctl(filep, cmd, arg); } #endif /* CONFIG_COMPAT */ @@ -1707,7 +1707,7 @@ static int vfio_device_fops_mmap(struct file *filep, struct vm_area_struct *vma) static long vfio_device_fops_compat_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) { - arg = (unsigned long)compat_ptr(arg); + arg = (__force unsigned long)compat_ptr(arg); return vfio_device_fops_unl_ioctl(filep, cmd, arg); } #endif /* CONFIG_COMPAT */ diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 20405421a5ed..a267f41378c9 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1274,7 +1274,7 @@ static int fb_getput_cmap(struct fb_info *info, unsigned int cmd, put_user(compat_ptr(data), &cmap->transp)) return -EFAULT; - err = do_fb_ioctl(info, cmd, (unsigned long) cmap); + err = do_fb_ioctl(info, cmd, (__force unsigned long) cmap); if (!err) { if (copy_in_user(&cmap32->start, @@ -1346,7 +1346,7 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd, case FBIOPAN_DISPLAY: case FBIOGET_CON2FBMAP: case FBIOPUT_CON2FBMAP: - arg = (unsigned long) compat_ptr(arg); + arg = (__force unsigned long) compat_ptr(arg); /* fall through */ case FBIOBLANK: ret = do_fb_ioctl(info, cmd, arg); diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index 57390c7666e5..fc5f60935f92 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -843,7 +843,7 @@ struct gntdev_copy_batch { static int gntdev_get_page(struct gntdev_copy_batch *batch, void __user *virt, bool writeable, unsigned long *gfn) { - unsigned long addr = (unsigned long)virt; + unsigned long addr = (__force unsigned long)virt; struct page *page; unsigned long xen_pfn; int ret; @@ -953,7 +953,7 @@ static int gntdev_grant_copy_seg(struct gntdev_copy_batch *batch, op->flags |= GNTCOPY_source_gref; } else { virt = seg->source.virt + copied; - off = (unsigned long)virt & ~XEN_PAGE_MASK; + off = (__force unsigned long)virt & ~XEN_PAGE_MASK; len = min(len, (size_t)XEN_PAGE_SIZE - off); ret = gntdev_get_page(batch, virt, false, &gfn); @@ -972,7 +972,7 @@ static int gntdev_grant_copy_seg(struct gntdev_copy_batch *batch, op->flags |= GNTCOPY_dest_gref; } else { virt = seg->dest.virt + copied; - off = (unsigned long)virt & ~XEN_PAGE_MASK; + off = (__force unsigned long)virt & ~XEN_PAGE_MASK; len = min(len, (size_t)XEN_PAGE_SIZE - off); ret = gntdev_get_page(batch, virt, true, &gfn); diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index 7e6e682104dc..d4b5dab8a80f 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c @@ -558,7 +558,7 @@ static long privcmd_ioctl_mmap_batch( if (state.global_error) { /* Write back errors in second pass. */ - state.user_gfn = (xen_pfn_t *)m.arr; + state.user_gfn = (xen_pfn_t __user *)m.arr; state.user_err = m.err; ret = traverse_pages_block(m.num, sizeof(xen_pfn_t), &pagelist, mmap_return_errors, &state); @@ -596,7 +596,7 @@ static int lock_pages( return -ENOSPC; pinned = get_user_pages_fast( - (unsigned long) kbufs[i].uptr, + (__force unsigned long) kbufs[i].uptr, requested, FOLL_WRITE, pages); if (pinned < 0) return pinned; diff --git a/fs/aio.c b/fs/aio.c index b9350f3360c6..bcf431f3e029 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1084,7 +1084,7 @@ static void aio_complete(struct aio_kiocb *iocb, long res, long res2) ev_page = kmap_atomic(ctx->ring_pages[pos / AIO_EVENTS_PER_PAGE]); event = ev_page + pos % AIO_EVENTS_PER_PAGE; - event->obj = (u64)(unsigned long)iocb->ki_user_iocb; + event->obj = (u64)(__force unsigned long)iocb->ki_user_iocb; event->data = iocb->ki_user_data; event->res = res; event->res2 = res2; diff --git a/fs/autofs/dev-ioctl.c b/fs/autofs/dev-ioctl.c index 86eafda4a652..f30c7dfec42b 100644 --- a/fs/autofs/dev-ioctl.c +++ b/fs/autofs/dev-ioctl.c @@ -709,7 +709,8 @@ static long autofs_dev_ioctl(struct file *file, unsigned int command, static long autofs_dev_ioctl_compat(struct file *file, unsigned int command, unsigned long u) { - return autofs_dev_ioctl(file, command, (unsigned long) compat_ptr(u)); + return autofs_dev_ioctl(file, command, + (__force unsigned long) compat_ptr(u)); } #else #define autofs_dev_ioctl_compat NULL diff --git a/fs/autofs/root.c b/fs/autofs/root.c index 782e57b911ab..c8ebdeab6708 100644 --- a/fs/autofs/root.c +++ b/fs/autofs/root.c @@ -956,7 +956,7 @@ static long autofs_root_compat_ioctl(struct file *filp, ret = autofs_root_ioctl_unlocked(inode, filp, cmd, arg); else ret = autofs_root_ioctl_unlocked(inode, filp, cmd, - (unsigned long) compat_ptr(arg)); + (__force unsigned long) compat_ptr(arg)); return ret; } diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index efae2fb0930a..0292555d19a4 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -258,18 +258,18 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec, NEW_AUX_ENT(AT_GID, from_kgid_munged(cred->user_ns, cred->gid)); NEW_AUX_ENT(AT_EGID, from_kgid_munged(cred->user_ns, cred->egid)); NEW_AUX_ENT(AT_SECURE, bprm->secureexec); - NEW_AUX_ENT(AT_RANDOM, (elf_addr_t)(unsigned long)u_rand_bytes); + NEW_AUX_ENT(AT_RANDOM, (elf_addr_t)(__force unsigned long)u_rand_bytes); #ifdef ELF_HWCAP2 NEW_AUX_ENT(AT_HWCAP2, ELF_HWCAP2); #endif NEW_AUX_ENT(AT_EXECFN, bprm->exec); if (k_platform) { NEW_AUX_ENT(AT_PLATFORM, - (elf_addr_t)(unsigned long)u_platform); + (elf_addr_t)(__force unsigned long)u_platform); } if (k_base_platform) { NEW_AUX_ENT(AT_BASE_PLATFORM, - (elf_addr_t)(unsigned long)u_base_platform); + (elf_addr_t)(__force unsigned long)u_base_platform); } if (bprm->interp_flags & BINPRM_FLAGS_EXECFD) { NEW_AUX_ENT(AT_EXECFD, bprm->interp_data); @@ -285,12 +285,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec, sp = STACK_ADD(p, ei_index); items = (argc + 1) + (envc + 1) + 1; - bprm->p = STACK_ROUND(sp, items); + bprm->p = STACK_ROUND((__force unsigned long)sp, items); /* Point sp at the lowest address on the stack */ #ifdef CONFIG_STACK_GROWSUP sp = (elf_addr_t __user *)bprm->p - items - ei_index; - bprm->exec = (unsigned long)sp; /* XXX: PARISC HACK */ + bprm->exec = (__force unsigned long)sp; /* XXX: PARISC HACK */ #else sp = (elf_addr_t __user *)bprm->p; #endif diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 63600dc2ac4c..da884159b169 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -5971,6 +5971,6 @@ long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; } - return btrfs_ioctl(file, cmd, (unsigned long) compat_ptr(arg)); + return btrfs_ioctl(file, cmd, (__force unsigned long) compat_ptr(arg)); } #endif diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index a9b00942e87d..675a5e862a68 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -152,7 +152,7 @@ static int do_video_get_event(struct file *file, if (kevent == NULL) return -EFAULT; - err = do_ioctl(file, cmd, (unsigned long)kevent); + err = do_ioctl(file, cmd, (__force unsigned long)kevent); if (!err) { err = convert_in_user(&kevent->type, &up->type); err |= convert_in_user(&kevent->timestamp, &up->timestamp); @@ -193,7 +193,7 @@ static int do_video_stillpicture(struct file *file, if (err) return -EFAULT; - err = do_ioctl(file, cmd, (unsigned long) up_native); + err = do_ioctl(file, cmd, (__force unsigned long) up_native); return err; } @@ -264,7 +264,7 @@ static int sg_ioctl_trans(struct file *file, unsigned int cmd, if (get_user(interface_id, &sgio32->interface_id)) return -EFAULT; if (interface_id != 'S') - return do_ioctl(file, cmd, (unsigned long)sgio32); + return do_ioctl(file, cmd, (__force unsigned long)sgio32); if (get_user(iovec_count, &sgio32->iovec_count)) return -EFAULT; @@ -324,7 +324,7 @@ static int sg_ioctl_trans(struct file *file, unsigned int cmd, if (put_user(compat_ptr(data), &sgio->usr_ptr)) return -EFAULT; - err = do_ioctl(file, cmd, (unsigned long) sgio); + err = do_ioctl(file, cmd, (__force unsigned long) sgio); if (err >= 0) { void __user *datap; @@ -332,7 +332,7 @@ static int sg_ioctl_trans(struct file *file, unsigned int cmd, if (copy_in_user(&sgio32->pack_id, &sgio->pack_id, sizeof(int)) || get_user(datap, &sgio->usr_ptr) || - put_user((u32)(unsigned long)datap, + put_user((u32)(__force unsigned long)datap, &sgio32->usr_ptr) || copy_in_user(&sgio32->status, &sgio->status, (4 * sizeof(unsigned char)) + @@ -361,7 +361,7 @@ static int sg_grt_trans(struct file *file, int err, i; sg_req_info_t __user *r; r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE); - err = do_ioctl(file, cmd, (unsigned long)r); + err = do_ioctl(file, cmd, (__force unsigned long)r); if (err < 0) return err; for (i = 0; i < SG_MAX_QUEUE; i++) { @@ -371,7 +371,7 @@ static int sg_grt_trans(struct file *file, if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) || get_user(ptr, &r[i].usr_ptr) || get_user(d, &r[i].duration) || - put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) || + put_user((u32)(__force unsigned long)(ptr), &o[i].usr_ptr) || put_user(d, &o[i].duration)) return -EFAULT; } @@ -410,7 +410,7 @@ static int ppp_sock_fprog_ioctl_trans(struct file *file, else cmd = PPPIOCSACTIVE; - return do_ioctl(file, cmd, (unsigned long) u_fprog64); + return do_ioctl(file, cmd, (__force unsigned long) u_fprog64); } struct ppp_option_data32 { @@ -435,7 +435,7 @@ static int ppp_gidle(struct file *file, unsigned int cmd, idle = compat_alloc_user_space(sizeof(*idle)); - err = do_ioctl(file, PPPIOCGIDLE, (unsigned long) idle); + err = do_ioctl(file, PPPIOCGIDLE, (__force unsigned long) idle); if (!err) { if (get_user(xmit, &idle->xmit_idle) || @@ -467,7 +467,7 @@ static int ppp_scompress(struct file *file, unsigned int cmd, sizeof(__u32) + sizeof(int))) return -EFAULT; - return do_ioctl(file, PPPIOCSCOMPRESS, (unsigned long) odata); + return do_ioctl(file, PPPIOCSCOMPRESS, (__force unsigned long) odata); } #ifdef CONFIG_BLOCK @@ -607,7 +607,7 @@ static int serial_struct_ioctl(struct file *file, put_user(0UL, &ss->iomap_base)) return -EFAULT; } - err = do_ioctl(file, cmd, (unsigned long)ss); + err = do_ioctl(file, cmd, (__force unsigned long)ss); if (cmd == TIOCGSERIAL && err >= 0) { if (copy_in_user(ss32, ss, offsetof(SS32, iomem_base)) || get_user(iomem_base, &ss->iomem_base)) @@ -641,14 +641,16 @@ static int rtc_ioctl(struct file *file, case RTC_EPOCH_READ32: ret = do_ioctl(file, (cmd == RTC_IRQP_READ32) ? RTC_IRQP_READ : RTC_EPOCH_READ, - (unsigned long)valp); + (__force unsigned long)valp); if (ret) return ret; return convert_in_user(valp, (unsigned int __user *)argp); case RTC_IRQP_SET32: - return do_ioctl(file, RTC_IRQP_SET, (unsigned long)argp); + return do_ioctl(file, RTC_IRQP_SET, + (__force unsigned long)argp); case RTC_EPOCH_SET32: - return do_ioctl(file, RTC_EPOCH_SET, (unsigned long)argp); + return do_ioctl(file, RTC_EPOCH_SET, + (__force unsigned long)argp); } return -ENOIOCTLCMD; @@ -1436,7 +1438,7 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, goto out_fput; found_handler: - arg = (unsigned long)compat_ptr(arg); + arg = (__force unsigned long)compat_ptr(arg); do_ioctl: error = do_vfs_ioctl(f.file, fd, cmd, arg); out_fput: diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c index 0367c0039e68..5cf6e2666107 100644 --- a/fs/ext2/ioctl.c +++ b/fs/ext2/ioctl.c @@ -183,6 +183,6 @@ long ext2_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) default: return -ENOIOCTLCMD; } - return ext2_ioctl(file, cmd, (unsigned long) compat_ptr(arg)); + return ext2_ioctl(file, cmd, (__force unsigned long) compat_ptr(arg)); } #endif diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index a7074115d6f6..02c9ffbbb209 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -1107,6 +1107,6 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) default: return -ENOIOCTLCMD; } - return ext4_ioctl(file, cmd, (unsigned long) compat_ptr(arg)); + return ext4_ioctl(file, cmd, (__force unsigned long) compat_ptr(arg)); } #endif diff --git a/fs/fat/file.c b/fs/fat/file.c index 4f3d72fb1e60..88f267d5042f 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -176,7 +176,8 @@ static long fat_generic_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { - return fat_generic_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); + return fat_generic_ioctl(filp, cmd, + (__force unsigned long)compat_ptr(arg)); } #endif diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 32d0b883e74f..4c0ccfeb2e24 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1255,7 +1255,7 @@ static inline void fuse_page_descs_length_init(struct fuse_req *req, static inline unsigned long fuse_get_user_addr(const struct iov_iter *ii) { - return (unsigned long)ii->iov->iov_base + ii->iov_offset; + return (__force unsigned long)ii->iov->iov_base + ii->iov_offset; } static inline size_t fuse_get_frag_size(const struct iov_iter *ii, diff --git a/fs/namespace.c b/fs/namespace.c index 51f763fb9430..8307bd0399f3 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2672,7 +2672,7 @@ void *copy_mount_options(const void __user * data) * the remainder of the page. */ /* copy_from_user cannot cross TASK_SIZE ! */ - size = TASK_SIZE - (unsigned long)untagged_addr(data); + size = TASK_SIZE - (__force unsigned long)untagged_addr(data); if (size > PAGE_SIZE) size = PAGE_SIZE; diff --git a/fs/readdir.c b/fs/readdir.c index d97f548e6323..d5de36c3cc66 100644 --- a/fs/readdir.c +++ b/fs/readdir.c @@ -366,8 +366,8 @@ static int compat_fillonedir(struct dir_context *ctx, const char *name, buf->result++; dirent = buf->dirent; if (!access_ok(VERIFY_WRITE, dirent, - (unsigned long)(dirent->d_name + namlen + 1) - - (unsigned long)dirent)) + (__force unsigned long)(dirent->d_name + namlen + 1) - + (__force unsigned long)dirent)) goto efault; if ( __put_user(d_ino, &dirent->d_ino) || __put_user(offset, &dirent->d_offset) || diff --git a/fs/signalfd.c b/fs/signalfd.c index 4fcd1498acf5..23bc1d4d870a 100644 --- a/fs/signalfd.c +++ b/fs/signalfd.c @@ -105,7 +105,7 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo, case SIL_TIMER: new.ssi_tid = kinfo->si_tid; new.ssi_overrun = kinfo->si_overrun; - new.ssi_ptr = (long) kinfo->si_ptr; + new.ssi_ptr = (__force long) kinfo->si_ptr; new.ssi_int = kinfo->si_int; break; case SIL_POLL: @@ -122,13 +122,13 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo, * it as SIL_FAULT. */ case SIL_FAULT: - new.ssi_addr = (long) kinfo->si_addr; + new.ssi_addr = (__force long) kinfo->si_addr; #ifdef __ARCH_SI_TRAPNO new.ssi_trapno = kinfo->si_trapno; #endif break; case SIL_FAULT_MCEERR: - new.ssi_addr = (long) kinfo->si_addr; + new.ssi_addr = (__force long) kinfo->si_addr; #ifdef __ARCH_SI_TRAPNO new.ssi_trapno = kinfo->si_trapno; #endif @@ -147,11 +147,11 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo, */ new.ssi_pid = kinfo->si_pid; new.ssi_uid = kinfo->si_uid; - new.ssi_ptr = (long) kinfo->si_ptr; + new.ssi_ptr = (__force long) kinfo->si_ptr; new.ssi_int = kinfo->si_int; break; case SIL_SYS: - new.ssi_call_addr = (long) kinfo->si_call_addr; + new.ssi_call_addr = (__force long) kinfo->si_call_addr; new.ssi_syscall = kinfo->si_syscall; new.ssi_arch = kinfo->si_arch; break; diff --git a/include/linux/mm.h b/include/linux/mm.h index a61ebe8ad4ca..0cfd80983fea 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1297,7 +1297,7 @@ static inline void clear_page_pfmemalloc(struct page *page) */ extern void pagefault_out_of_memory(void); -#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) +#define offset_in_page(p) ((__force unsigned long)(p) & ~PAGE_MASK) /* * Flags passed to show_mem() and show_free_areas() to suppress output in diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index b1bd2186e6d2..26d08d4ed59b 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -579,8 +579,8 @@ static inline int fault_in_pages_writeable(char __user *uaddr, int size) } while (uaddr <= end); /* Check whether the range spilled into the next page. */ - if (((unsigned long)uaddr & PAGE_MASK) == - ((unsigned long)end & PAGE_MASK)) + if (((__force unsigned long)uaddr & PAGE_MASK) == + ((__force unsigned long)end & PAGE_MASK)) return __put_user(0, end); return 0; @@ -604,8 +604,8 @@ static inline int fault_in_pages_readable(const char __user *uaddr, int size) } while (uaddr <= end); /* Check whether the range spilled into the next page. */ - if (((unsigned long)uaddr & PAGE_MASK) == - ((unsigned long)end & PAGE_MASK)) { + if (((__force unsigned long)uaddr & PAGE_MASK) == + ((__force unsigned long)end & PAGE_MASK)) { return __get_user(c, end); } diff --git a/include/linux/socket.h b/include/linux/socket.h index 7ed4713d5337..529f526bca1c 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -93,7 +93,7 @@ struct cmsghdr { #define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) ) -#define CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + sizeof(struct cmsghdr))) +#define CMSG_DATA(cmsg) ((void *)((char __force *)(cmsg) + sizeof(struct cmsghdr))) #define CMSG_SPACE(len) (sizeof(struct cmsghdr) + CMSG_ALIGN(len)) #define CMSG_LEN(len) (sizeof(struct cmsghdr) + (len)) diff --git a/ipc/shm.c b/ipc/shm.c index b0eb3757ab89..310096ffe8c4 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -1392,7 +1392,7 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr, unsigned long shmlba) { struct shmid_kernel *shp; - unsigned long addr = (unsigned long)shmaddr; + unsigned long addr = (__force unsigned long)shmaddr; unsigned long size; struct file *file, *base; int err; @@ -1600,7 +1600,7 @@ long ksys_shmdt(char __user *shmaddr) { struct mm_struct *mm = current->mm; struct vm_area_struct *vma; - unsigned long addr = (unsigned long)shmaddr; + unsigned long addr = (__force unsigned long)shmaddr; int retval = -EINVAL; #ifdef CONFIG_MMU loff_t size = 0; diff --git a/kernel/futex.c b/kernel/futex.c index 11fc3bb456d6..8bb0858c795a 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -499,7 +499,7 @@ static void drop_futex_key_refs(union futex_key *key) static int get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw) { - unsigned long address = (unsigned long)uaddr; + unsigned long address = (__force unsigned long)uaddr; struct mm_struct *mm = current->mm; struct page *page, *tail; struct address_space *mapping; @@ -727,7 +727,7 @@ static int fault_in_user_writeable(u32 __user *uaddr) int ret; down_read(&mm->mmap_sem); - ret = fixup_user_fault(current, mm, (unsigned long)uaddr, + ret = fixup_user_fault(current, mm, (__force unsigned long)uaddr, FAULT_FLAG_WRITE, NULL); up_read(&mm->mmap_sem); @@ -3584,7 +3584,7 @@ SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, */ if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP) - val2 = (u32) (unsigned long) utime; + val2 = (u32) (__force unsigned long) utime; return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); } diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c index 83f830acbb5f..b6052ae7b349 100644 --- a/kernel/futex_compat.c +++ b/kernel/futex_compat.c @@ -196,7 +196,7 @@ COMPAT_SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val, } if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE || cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP) - val2 = (int) (unsigned long) utime; + val2 = (int) (__force unsigned long) utime; return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); } diff --git a/kernel/power/user.c b/kernel/power/user.c index 2d8b60a3c86b..10a578efc892 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c @@ -431,7 +431,7 @@ snapshot_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case SNAPSHOT_CREATE_IMAGE: return snapshot_ioctl(file, cmd, - (unsigned long) compat_ptr(arg)); + (__force unsigned long) compat_ptr(arg)); case SNAPSHOT_SET_SWAP_AREA: { struct compat_resume_swap_area __user *u_swap_area = diff --git a/kernel/signal.c b/kernel/signal.c index 5843c541fda9..2bc6d7fdeaec 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -3494,7 +3494,7 @@ do_sigaltstack (const stack_t *ss, stack_t *oss, unsigned long sp) return -ENOMEM; } - t->sas_ss_sp = (unsigned long) ss_sp; + t->sas_ss_sp = (__force unsigned long) ss_sp; t->sas_ss_size = ss_size; t->sas_ss_flags = ss_flags; } diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 8be175df3075..6b1f373d241d 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -1112,9 +1112,9 @@ unsigned long iov_iter_alignment(const struct iov_iter *i) return size; } iterate_all_kinds(i, size, v, - (res |= (unsigned long)v.iov_base | v.iov_len, 0), + (res |= (__force unsigned long)v.iov_base | v.iov_len, 0), res |= v.bv_offset | v.bv_len, - res |= (unsigned long)v.iov_base | v.iov_len + res |= (__force unsigned long)v.iov_base | v.iov_len ) return res; } @@ -1131,11 +1131,11 @@ unsigned long iov_iter_gap_alignment(const struct iov_iter *i) } iterate_all_kinds(i, size, v, - (res |= (!res ? 0 : (unsigned long)v.iov_base) | + (res |= (!res ? 0 : (__force unsigned long)v.iov_base) | (size != v.iov_len ? size : 0), 0), (res |= (!res ? 0 : (unsigned long)v.bv_offset) | (size != v.bv_len ? size : 0)), - (res |= (!res ? 0 : (unsigned long)v.iov_base) | + (res |= (!res ? 0 : (__force unsigned long)v.iov_base) | (size != v.iov_len ? size : 0)) ); return res; @@ -1196,7 +1196,7 @@ ssize_t iov_iter_get_pages(struct iov_iter *i, if (unlikely(i->type & ITER_PIPE)) return pipe_get_pages(i, pages, maxsize, maxpages, start); iterate_all_kinds(i, maxsize, v, ({ - unsigned long addr = (unsigned long)v.iov_base; + unsigned long addr = (__force unsigned long)v.iov_base; size_t len = v.iov_len + (*start = addr & (PAGE_SIZE - 1)); int n; int res; @@ -1273,7 +1273,7 @@ ssize_t iov_iter_get_pages_alloc(struct iov_iter *i, if (unlikely(i->type & ITER_PIPE)) return pipe_get_pages_alloc(i, pages, maxsize, start); iterate_all_kinds(i, maxsize, v, ({ - unsigned long addr = (unsigned long)v.iov_base; + unsigned long addr = (__force unsigned long)v.iov_base; size_t len = v.iov_len + (*start = addr & (PAGE_SIZE - 1)); int n; int res; @@ -1457,7 +1457,7 @@ int iov_iter_npages(const struct iov_iter *i, int maxpages) if (npages >= maxpages) return maxpages; } else iterate_all_kinds(i, size, v, ({ - unsigned long p = (unsigned long)v.iov_base; + unsigned long p = (__force unsigned long)v.iov_base; npages += DIV_ROUND_UP(p + v.iov_len, PAGE_SIZE) - p / PAGE_SIZE; if (npages >= maxpages) @@ -1467,7 +1467,7 @@ int iov_iter_npages(const struct iov_iter *i, int maxpages) if (npages >= maxpages) return maxpages; }),({ - unsigned long p = (unsigned long)v.iov_base; + unsigned long p = (__force unsigned long)v.iov_base; npages += DIV_ROUND_UP(p + v.iov_len, PAGE_SIZE) - p / PAGE_SIZE; if (npages >= maxpages) diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c index 97467cd2bc59..2dc90838a594 100644 --- a/lib/strncpy_from_user.c +++ b/lib/strncpy_from_user.c @@ -109,7 +109,7 @@ long strncpy_from_user(char *dst, const char __user *src, long count) src = untagged_addr(src); max_addr = user_addr_max(); - src_addr = (unsigned long)src; + src_addr = (__force unsigned long)src; if (likely(src_addr < max_addr)) { unsigned long max = max_addr - src_addr; long retval; diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c index 8b5f56466e00..10cc31f41064 100644 --- a/lib/strnlen_user.c +++ b/lib/strnlen_user.c @@ -42,7 +42,7 @@ static inline long do_strnlen_user(const char __user *src, unsigned long count, * Do everything aligned. But that means that we * need to also expand the maximum.. */ - align = (sizeof(long) - 1) & (unsigned long)src; + align = (sizeof(long) - 1) & (__force unsigned long)src; src -= align; max += align; @@ -111,7 +111,7 @@ long strnlen_user(const char __user *str, long count) str = untagged_addr(str); max_addr = user_addr_max(); - src_addr = (unsigned long)str; + src_addr = (__force unsigned long)str; if (likely(src_addr < max_addr)) { unsigned long max = max_addr - src_addr; long retval; diff --git a/lib/test_kasan.c b/lib/test_kasan.c index ec657105edbf..e6a6ad7cc054 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -476,7 +476,7 @@ static noinline void __init copy_user_test(void) pr_info("out-of-bounds in strncpy_from_user()\n"); unused = strncpy_from_user(kmem, usermem, size + 1); - vm_munmap((unsigned long)usermem, PAGE_SIZE); + vm_munmap((__force unsigned long)usermem, PAGE_SIZE); kfree(kmem); } diff --git a/mm/memory.c b/mm/memory.c index c467102a5cbc..eb7606ab3620 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4728,7 +4728,7 @@ long copy_huge_page_from_user(struct page *dst_page, unsigned int pages_per_huge_page, bool allow_pagefault) { - void *src = (void *)usr_src; + void *src = (__force void *)usr_src; void *page_kaddr; unsigned long i, rc = 0; unsigned long ret_val = pages_per_huge_page * PAGE_SIZE; diff --git a/mm/migrate.c b/mm/migrate.c index d6a2e89b086a..9786b5f827cf 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1582,7 +1582,7 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, goto out_flush; if (get_user(node, nodes + i)) goto out_flush; - addr = (unsigned long)p; + addr = (__force unsigned long)p; err = -ENODEV; if (node < 0 || node >= MAX_NUMNODES) @@ -1656,7 +1656,7 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages, down_read(&mm->mmap_sem); for (i = 0; i < nr_pages; i++) { - unsigned long addr = (unsigned long)(*pages); + unsigned long addr = (__force unsigned long)(*pages); struct vm_area_struct *vma; struct page *page; int err = -EFAULT; diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c index a447092d4635..4a7a55f4614d 100644 --- a/mm/process_vm_access.c +++ b/mm/process_vm_access.c @@ -175,10 +175,10 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter, for (i = 0; i < riovcnt; i++) { iov_len = rvec[i].iov_len; if (iov_len > 0) { - nr_pages_iov = ((unsigned long)rvec[i].iov_base - + iov_len) - / PAGE_SIZE - (unsigned long)rvec[i].iov_base - / PAGE_SIZE + 1; + nr_pages_iov = ((__force unsigned long)rvec[i].iov_base + + iov_len) / PAGE_SIZE - + (__force unsigned long)rvec[i].iov_base + / PAGE_SIZE + 1; nr_pages = max(nr_pages, nr_pages_iov); } } @@ -218,8 +218,9 @@ static ssize_t process_vm_rw_core(pid_t pid, struct iov_iter *iter, for (i = 0; i < riovcnt && iov_iter_count(iter) && !rc; i++) rc = process_vm_rw_single_vec( - (unsigned long)rvec[i].iov_base, rvec[i].iov_len, - iter, process_pages, mm, task, vm_write); + (__force unsigned long)rvec[i].iov_base, + rvec[i].iov_len, iter, process_pages, mm, task, + vm_write); /* copied = space before - space after */ total_len -= iov_iter_count(iter); diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c index 1eaac01f85de..a07dc6ad085f 100644 --- a/net/bluetooth/hidp/sock.c +++ b/net/bluetooth/hidp/sock.c @@ -185,7 +185,7 @@ static int hidp_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigne copy_to_user(&uca->name[0], &ca.name[0], 128)) return -EFAULT; - arg = (unsigned long) uca; + arg = (__force unsigned long) uca; /* Fall through. We don't actually write back any _changes_ to the structure anyway, so there's no need to copy back diff --git a/net/compat.c b/net/compat.c index 3b2105f6549d..786c71c44f99 100644 --- a/net/compat.c +++ b/net/compat.c @@ -103,7 +103,7 @@ int get_compat_msghdr(struct msghdr *kmsg, ((ucmlen) >= sizeof(struct compat_cmsghdr) && \ (ucmlen) <= (unsigned long) \ ((mhdr)->msg_controllen - \ - ((char *)(ucmsg) - (char *)(mhdr)->msg_control))) + ((char __force *)(ucmsg) - (char __force *)(mhdr)->msg_control))) static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg, struct compat_cmsghdr __user *cmsg, int cmsg_len) @@ -582,7 +582,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname, case MCAST_JOIN_GROUP: case MCAST_LEAVE_GROUP: { - struct compat_group_req __user *gr32 = (void *)optval; + struct compat_group_req __user *gr32 = (__force void *)optval; struct group_req __user *kgr = compat_alloc_user_space(sizeof(struct group_req)); u32 interface; @@ -603,7 +603,8 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname, case MCAST_BLOCK_SOURCE: case MCAST_UNBLOCK_SOURCE: { - struct compat_group_source_req __user *gsr32 = (void *)optval; + struct compat_group_source_req __user *gsr32 = + (__force void *)optval; struct group_source_req __user *kgsr = compat_alloc_user_space( sizeof(struct group_source_req)); u32 interface; @@ -624,7 +625,8 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname, } case MCAST_MSFILTER: { - struct compat_group_filter __user *gf32 = (void *)optval; + struct compat_group_filter __user *gf32 = + (__force void *)optval; struct group_filter __user *kgf; u32 interface, fmode, numsrc; @@ -662,7 +664,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname, char __user *optval, int __user *optlen, int (*getsockopt)(struct sock *, int, int, char __user *, int __user *)) { - struct compat_group_filter __user *gf32 = (void *)optval; + struct compat_group_filter __user *gf32 = (__force void *)optval; struct group_filter __user *kgf; int __user *koptlen; u32 interface, fmode, numsrc; diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c index 507fd5210c1c..eae6af108bf2 100644 --- a/sound/core/control_compat.c +++ b/sound/core/control_compat.c @@ -418,7 +418,8 @@ static int snd_ctl_elem_add_compat(struct snd_ctl_file *file, sizeof(data->value.enumerated))) goto error; data->value.enumerated.names_ptr = - (uintptr_t)compat_ptr(data->value.enumerated.names_ptr); + (__force uintptr_t)compat_ptr( + data->value.enumerated.names_ptr); break; default: break; @@ -465,7 +466,7 @@ static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, uns case SNDRV_CTL_IOCTL_TLV_READ: case SNDRV_CTL_IOCTL_TLV_WRITE: case SNDRV_CTL_IOCTL_TLV_COMMAND: - return snd_ctl_ioctl(file, cmd, (unsigned long)argp); + return snd_ctl_ioctl(file, cmd, (__force unsigned long)argp); case SNDRV_CTL_IOCTL_ELEM_LIST32: return snd_ctl_elem_list_compat(ctl->card, argp); case SNDRV_CTL_IOCTL_ELEM_INFO32: diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 66c90f486af9..6bf7fc29d6a0 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2888,7 +2888,8 @@ static int snd_pcm_common_ioctl(struct file *file, case SNDRV_PCM_IOCTL_START: return snd_pcm_start_lock_irq(substream); case SNDRV_PCM_IOCTL_LINK: - return snd_pcm_link(substream, (int)(unsigned long) arg); + return snd_pcm_link(substream, + (int)(__force unsigned long) arg); case SNDRV_PCM_IOCTL_UNLINK: return snd_pcm_unlink(substream); case SNDRV_PCM_IOCTL_RESUME: @@ -2925,7 +2926,7 @@ static int snd_pcm_common_ioctl(struct file *file, case SNDRV_PCM_IOCTL_PAUSE: return snd_pcm_action_lock_irq(&snd_pcm_action_pause, substream, - (int)(unsigned long)arg); + (int)(__force unsigned long)arg); case SNDRV_PCM_IOCTL_WRITEI_FRAMES: case SNDRV_PCM_IOCTL_READI_FRAMES: return snd_pcm_xferi_frames_ioctl(substream, arg); diff --git a/sound/core/timer_compat.c b/sound/core/timer_compat.c index e00f7e399e46..b7bf8a99f883 100644 --- a/sound/core/timer_compat.c +++ b/sound/core/timer_compat.c @@ -154,7 +154,8 @@ static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, case SNDRV_TIMER_IOCTL_PAUSE: case SNDRV_TIMER_IOCTL_PAUSE_OLD: case SNDRV_TIMER_IOCTL_NEXT_DEVICE: - return __snd_timer_user_ioctl(file, cmd, (unsigned long)argp); + return __snd_timer_user_ioctl(file, cmd, + (__force unsigned long)argp); case SNDRV_TIMER_IOCTL_GPARAMS32: return snd_timer_user_gparams_compat(file, argp); case SNDRV_TIMER_IOCTL_INFO32: