From patchwork Mon Dec 10 12:50:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10721251 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 96A5817FE for ; Mon, 10 Dec 2018 12:52:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8771C2A2C4 for ; Mon, 10 Dec 2018 12:52:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AC742A2EB; Mon, 10 Dec 2018 12:52:11 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 93CCB2A2DC for ; Mon, 10 Dec 2018 12:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MKWHOMN/iw4cpmH+SgZuJp9GvGb5dngxv4bxmQHZBPY=; b=QIUz8LaoYSxnXw o9SfxIy3HdkahjV4o4RpkK+ddlsG6CYsHo9pz7sQ4T3m5A1vzzf0cp3b9AdJQ6PnF9qh5VH1Ns8fx qwENkslwvDQlbaXddGb8LMcT6daKAe+jN5iFSSCNNaRTx2FsislM2jbLWwd0EpEsoqsHktDyVwoqN Z3eanC4LDIK3sPGZ+5HjLQBoNKjJ5ka+UWoDCr3saohaWGzKn8R6VlX96qr0NU3LqaE4UOmcy7qW4 NryvtBTCydG8xAOGk7fXjrzFkzLLfnAm4HGmnBxbEaoPJBjqoXl0X+XlLcP6XZJNdZBrmjrCcpoOS xUatPWqeEkHGrnL38Heg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL2S-0001nk-Lq; Mon, 10 Dec 2018 12:51:56 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL1v-0001Bj-12 for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 12:51:24 +0000 Received: by mail-wm1-x344.google.com with SMTP id n190so10864528wmd.0 for ; Mon, 10 Dec 2018 04:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DGAUj6PSqqPDQJ5J6R6pKlBVa6bTvYS48OkmKh4Sulk=; b=gls6f17iFdY+aaMHKZj2c6iqSD/1QrF4roruo3c5l5rPA1aVvvzHjI2CFqg/lmlOS5 QV5WzVIcjFGeG5EZOAQBUSLUhKGejG5O9B8bsP3m0ZDDbDXlypr860QwpgdjRFT3VtOy XxeDJnbsSvMDNeVg7Zd3WWKgfoYfCaUgEKOfQw5HnKoHFqbh4YmdPnz+wYY39XjVd+O7 nOiFe7/AFJYVdSf7VYpOu//HoHkRLNS028ysC6yapgWia3lzb7Jo2WuChJRuNCDkW4mV cPqpApKuM6RsIoZYmQ0wgoKMKNyLL+EL+mT4Ax0maE+25TL9RSBHw3MXHz8+SN4ZTCt0 F53A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DGAUj6PSqqPDQJ5J6R6pKlBVa6bTvYS48OkmKh4Sulk=; b=bA/5M8T+GVPTbB+WVWAAvaPO9/fWGUEgKJp4H1JsppNeIeO2Rlps5lBiyhZHcp/17Q cW7O06jlgBQJZsboVvovUlR59/5ygiFCQtquI2A75XBMXUFlTCXeCZ27NJiG+spDCiyy ZWEpD+O+iTsOA3a2VvZ2FxX2FzpdkwdKYCeJsyTGE+lJj4wxU9BBPuzzeduWmFmlRQYl A+KXHUluMI0JL/sBP4K9XPUXVTR0KOOAqSI/Q34C1RfFp8c3al3J0xmaIT2sGqb2DXog LVh+8yv6ZU+HDBAL9KGGREeTTTF9Lsdd45YzJyI809bmOPRrRsUkmLWsSHAUPSUqdEtL p22w== X-Gm-Message-State: AA+aEWa8Q2NetwTSJHvssjjJvnx2uV8M3vhpOBYDpR9j5lkLI5qbg4hV loV7wtueNiL3DjLUbzTvGG/upw== X-Google-Smtp-Source: AFSGD/Wfd26kZrXesEpia2lo9KfLrUJNSZ6LeKcsVzx9h0ZIx3ectSG+FrTDJ+dLbEuGhtbGIsbJVQ== X-Received: by 2002:a7b:cb18:: with SMTP id u24mr10123577wmj.138.1544446271115; Mon, 10 Dec 2018 04:51:11 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id l197sm36893363wma.44.2018.12.10.04.51.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 04:51:09 -0800 (PST) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , 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 Subject: [PATCH v9 1/8] arm64: add type casts to untagged_addr macro Date: Mon, 10 Dec 2018 13:50:58 +0100 Message-Id: <07836d7852b5c2d9588e28e4081a6f783689377c.1544445454.git.andreyknvl@google.com> X-Mailer: git-send-email 2.20.0.rc2.403.gdbc3b29805-goog In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_045123_085516_606F389C X-CRM114-Status: GOOD ( 14.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chintan Pandya , Jacob Bramley , Ruben Ayrapetyan , Andrey Konovalov , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Luc Van Oostenryck , Evgeniy Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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__. Acked-by: Catalin Marinas 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 07c34087bd5e..3c3864ba3cc1 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -101,7 +101,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 Mon Dec 10 12:50:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10721267 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 B6D7B112E for ; Mon, 10 Dec 2018 12:58:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A669A29D89 for ; Mon, 10 Dec 2018 12:58:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A0072A1B2; Mon, 10 Dec 2018 12:58:55 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4FF3629D89 for ; Mon, 10 Dec 2018 12:58:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZwpqbVkB6mCPNKbnV0EvRsW+R1pvduqh5guSx90LIDw=; b=PtTBx7GAmQuYCZ T88aHainYd4RWvUytDCKbE8qUw/STAropBCpRrm4y3zMA0UpA1o/FQkGNwToKaHIhL9l8oSJleEOJ /9tYaAMjhF2RpoFHDDtWHg+wjVdsQImNaGgAc4F+gDz2wY/VNnsDStwMIFMs4FXnUEDBieer155hq 8t0aBxN6XH5RvMDRDIxA0drsQ/qysBJxBrli5cfuHGKA3RA3bGvHXF9r/TTWTJDky5ffcS94BrBM5 y8NB960zHDa2+J5h7ylhUdARTtfNMSTu/sTXgVYqyRiFSqPvVpGoghJehYr5uJuKylftX6bTaFARW yvDa8glfQ0v0/xqc7abw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL90-0004ze-Hp; Mon, 10 Dec 2018 12:58:42 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL1w-0001Bk-8t for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 12:51:28 +0000 Received: by mail-wm1-x342.google.com with SMTP id f81so11065126wmd.4 for ; Mon, 10 Dec 2018 04:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EnNoEMrMgUcWWKorAen45ktTirJw06vWZl+y3HjnYKc=; b=ZFDzySXH+RcGKbu7apwOJhQV89JvZa+gIzkdi3lCpAr8rANmuaA696lcNSMihz5jsd Mgc8z5GDqlKqPiGIFUGFJV5LZ6mPD1yG7h/fXqDnZeBSJrvzsxOfDPf/WQ2TgUnbPF+K BulPEM7LRkLz/+A0NCyQ10FFjDpEaoS17rWmhBEhu1vWUWzxbXcbBgiYI+GWlU+bKJpF hbHErYklHv8F4KC/8y3KrbRg/WdRewnyb+I6zzpz2QW0JhyjVBllF1qeuzcMDR2q476/ 85vwRgG7I3nE+1b5PDbnOhjIJiH5ILXwm/PcvsVjUrvLOA0sv3kgXe81o9mc0j3Nhaf+ o9oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EnNoEMrMgUcWWKorAen45ktTirJw06vWZl+y3HjnYKc=; b=T8pjNsMDYzINV9Zf9oK1a12euZeJq/YCQTbRiCZuc+FHZryyhsbBzQOznyr1FePRkg jD/RJdjmv0RHHMgVBdM+frCxwErnJc2HpiPQDAXlNzdZcdM8zICHyjtUS7acxoyrkPxh s8aA+kx9pSxUt6ETB1sW9ryCP8IvTsAJCEoRkLC5q+mW1AiHaonuS8KFKrKOrn9j+QbE /cJPn7aFj9p5nu43MwIjyQ16krSI/voVf+PwTgvz/5gToHtqVfNTP8EcsH2VN7mIeBr+ BfEdAckIVEkFrJa1lf1kiyB3H3E0fwrXRoRxKPAfeC/MMcF/gfulhKImXy0xAqyfZtlx 26zg== X-Gm-Message-State: AA+aEWYgv09Mgcv+5ZcsGCleFZ7054UpRWl7X/HXxsNxi0ZXfcAX3ZgZ CLDc4WGQyphwGJTEZmgZIrsvZQ== X-Google-Smtp-Source: AFSGD/XfpH+7b2MBHMbSzaZiRmsmRTBYGLOi6i4h/Gy2a0EmicqS+e3KfIv69EriIxjgI+TvTV5Ofg== X-Received: by 2002:a1c:d08b:: with SMTP id h133mr10494086wmg.8.1544446272635; Mon, 10 Dec 2018 04:51:12 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id l197sm36893363wma.44.2018.12.10.04.51.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 04:51:11 -0800 (PST) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , 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 Subject: [PATCH v9 2/8] uaccess: add untagged_addr definition for other arches Date: Mon, 10 Dec 2018 13:50:59 +0100 Message-Id: <35f97a89d5cc881f0f4052f43d56b3b7ed736581.1544445454.git.andreyknvl@google.com> X-Mailer: git-send-email 2.20.0.rc2.403.gdbc3b29805-goog In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_045124_325154_3C392345 X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chintan Pandya , Jacob Bramley , Ruben Ayrapetyan , Andrey Konovalov , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Luc Van Oostenryck , Evgeniy Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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. Acked-by: Catalin Marinas 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..42b7a4ac65e2 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 Mon Dec 10 12:51:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10721227 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 540681751 for ; Mon, 10 Dec 2018 12:51:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44F932A280 for ; Mon, 10 Dec 2018 12:51:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4265A2A2B3; Mon, 10 Dec 2018 12:51:27 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E57C82A280 for ; Mon, 10 Dec 2018 12:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=K3HZFVq+atwrMuW0B6RUG2QG1BqomrtzP3iAmsuAS4c=; b=P1wZdjVMRhaP0b wNJJtNqSL+f6hn2cmuJLKS1dfDSDIJZXlROL1aw4lJxew803SmZAqUIEYwon+3sZe2CIeyQf4b5Rn tgVAT92lO4GSGWAVKVVQZaMJieXmiBSdzYLFoMg3MUG6WJIJm8gEv6hSDaM3WUxX210YRv/ZBdzCx KrBD/GNFS5b3x100SeMfFUapXqldapN8dt4IRLkvg7cwf6lF0k5DRYaxze7Lh/+pUqGoXqMnlS+i0 lLjFhn4VuENPZ5TNI+AFV/17RTWYMIqxhOTJCln+jELKardbpAuQO5LP0S+Kn5M4H+nRnNRIfjYVG wo7BXrGciPAbqe7nN0Pg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL1w-0001EA-NF; Mon, 10 Dec 2018 12:51:24 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL1t-0001Bt-F9 for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 12:51:23 +0000 Received: by mail-wr1-x441.google.com with SMTP id 96so10369174wrb.2 for ; Mon, 10 Dec 2018 04:51:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=spp1yx5uWvAgxErNR01vKeP4ipxAKNr5cbWijdqL/NI=; b=tvsXwVCKLmRdJsM+euD1t0rVUHOOn+/ZTTi3MnnQ9yebryAkbI4hvbPXubAR8j9xbT rSzx3Kyplc8mI1Q5cCWawts1mVwnbRT/UG0tp4Xvt5MDVVu5AjP34+MyjU+t6RTFt/1F GtjCSp16Bsb0olrw8ju4ga21oFPvQHFAjGiXj06kBSulY2fBvH1/8yimSxJdEzM0IjDe S2UHXqy/PlTnElD5PvCE/Ei8NOK6WhW4AzfjK1G4NAKHmzILpvArpdT0x23Ci7QVw1Jf siaqLTUGCqHPMIili1iJlbBGd6qfhARL0xDVAgzKR2wFfvkvY0Mi96XrFZLLMJ9KfrPg c6gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=spp1yx5uWvAgxErNR01vKeP4ipxAKNr5cbWijdqL/NI=; b=jTk96L8WuVbdarFGR77V6VksLJJCjK3BRS8qx+hPx4/9IIhEgrs9jUoC1lL9Q7qWoZ JRD49fVP0qlXwo1n4TJY/WJGgzQQn9o2V7JOiJVNiI5gUAtgCGg+HAIjAy7Es5X/K1dH 7Kqf68oLtvQTjHsC7jNRZfYP9Fv8b44zmFxji0OzBic67bykQ+mOIGqLjJi/HyBAP6Vv /bwed91QkHeowm5Vvd2yO0O6+MjoSZ6sJVtOCvF66TDcUW+hJQBEVP1QGakIEfP4eEq3 Tk5zwsCreey06C6CYAe1BsAdjBicpHUKiopOZ/AfuhmU4+dCSqV2bdWATmmED8HoSGDj 2Mqw== X-Gm-Message-State: AA+aEWb+TFZF5B3DUkVeZRdtUJqSSK49upeaJZffG/Jmpgr91Iyyfqt8 rF1RzkGwYRfKDrwco3OeuVhatg== X-Google-Smtp-Source: AFSGD/WK6voMtzDjeOrD0p0dIVtqA5GSBJDXWoYR6ofaTs6wbsSMRcTZb/d4/4QZpcv/PkUOjr5HNQ== X-Received: by 2002:a5d:684b:: with SMTP id o11mr9182121wrw.316.1544446274117; Mon, 10 Dec 2018 04:51:14 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id l197sm36893363wma.44.2018.12.10.04.51.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 04:51:13 -0800 (PST) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , 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 Subject: [PATCH v9 3/8] arm64: untag user addresses in access_ok and __uaccess_mask_ptr Date: Mon, 10 Dec 2018 13:51:00 +0100 Message-Id: <674252952827b57f4259876cd4ddf802f3539356.1544445454.git.andreyknvl@google.com> X-Mailer: git-send-email 2.20.0.rc2.403.gdbc3b29805-goog In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_045121_510609_67C26422 X-CRM114-Status: GOOD ( 14.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chintan Pandya , Jacob Bramley , Ruben Ayrapetyan , Andrey Konovalov , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Luc Van Oostenryck , Evgeniy Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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. Reviewed-by: Catalin Marinas 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 3c3864ba3cc1..d28c3b1314ce 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -104,7 +104,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) \ @@ -236,7 +237,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) @@ -244,10 +246,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 Mon Dec 10 12:51:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10721265 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 E94B2112E for ; Mon, 10 Dec 2018 12:58:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D73FD271FD for ; Mon, 10 Dec 2018 12:58:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9F3629AB7; Mon, 10 Dec 2018 12:58:30 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7DDDA271FD for ; Mon, 10 Dec 2018 12:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lVAxV6xCxDOzHorwk1b2WVEgBqASY3Q1jtcNg5gcsr0=; b=h+b9Z6B4ZoY5dP vKLAahh7Rfy0Z7iRpd9bvXOqwIjuzyVOlxdF0HyyIK9/5A141nhAWSMEuwX5wP3nkFRn+TKJOhWQh vjcdbQJluUo7L8ELXiN4vTV7enUHoWlCerWrW5L0sHPAb0B60IWtoYMHzaFrdhX5FkOu0ZSI1AqoO erRtMt8ev46J1uAg++1MrAleN1E6YuTW41pqJzqRWfcIR9lR5ZCZd/WKbfh0+v1r5MkMFPKpE68RQ HIMRd+UmOm6o3xNGE6v0f5y9+a2SNyvliugpI6oNJjvg07Z1ASlDufWLk/Os9usuFS3TQIKQne2gC rcyBBA+3eJFbjJYY6GgQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL8l-0004j5-Kn; Mon, 10 Dec 2018 12:58:27 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL1w-0001CH-8m for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 12:51:29 +0000 Received: by mail-wm1-x342.google.com with SMTP id c126so11082165wmh.0 for ; Mon, 10 Dec 2018 04:51:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O6AqR+kzU7DWQeNGwKtE5aEN5/daSSLGL2wqVNM1I1o=; b=o94crt9sdWRW+Hm+QmVzs2SQOfXkb5I8ZA1YUWGR/rhiyXLta3D09PlbP8iJAgQz4P AaMOg13WCXc/3V43uJSupLTElnHz42/Ee7IzHa1JjP6TjqWFlUNN//X23cnby2HTY/og axjylPN+XFavkTnP0oGFHln3ZwFe2/juKQ5sJAgtxYNAFtsVDFeYuPsBQ0hII0bfcLEK XiMERt9XLjpmq8N8DJ1YK866L0D0OEONbAo9KCgz28iqGOX3iPjmbwdb16LAY28Asm+R C/Nun82fTDPABrkfsixYhSu9EPH9yIADCvsKOyVMjDxIqyFwkkJ/ZzoNiySiBB50PDA4 tGmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O6AqR+kzU7DWQeNGwKtE5aEN5/daSSLGL2wqVNM1I1o=; b=ZS6br9AN0PKdGbLUxvSlmMXnpqfsIMzZwMJdkqAjC95lnRUUFm1ZTydLLhDoqUwlmm dmpX0yUBj6WEMNrAVhiGulr0zECyfKVu3SlKpBXVtu+xCRstYPuRrrB3YkcB6fApbVFb O6baVo+AoO9c3MBGkrbfrpZ5WmIXoiLHPDmdPWy8A4jJlRa+sywzWNXTPN/775Kkv6lw KsZadQq3enpZwgR3NyadVNZPEYzskGLBBwvxZxD92INmGEhZEwpUE71yvCrKfE1EkCw+ apLXOzb0tQ7tTnZP2n4FxDBiAJLOLdBDSoxC4aZa6e4Fe4ZPef/c86ipGtjXLk3/H1g1 VxyA== X-Gm-Message-State: AA+aEWYa6hNx1B1yHvEzErzS7m0Jb8hWIyswqTZoMFZY5XxrcVuMgzjN DZRXYC7kza065NyQNLK2//An1A== X-Google-Smtp-Source: AFSGD/Xve6So/1Ery1o5wmvM73iVMPQ4hP1b6ACBIixN+5CPW479nD99WkZw/3+pQqT8QAsR/mEorA== X-Received: by 2002:a1c:570d:: with SMTP id l13mr11011978wmb.139.1544446275548; Mon, 10 Dec 2018 04:51:15 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id l197sm36893363wma.44.2018.12.10.04.51.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 04:51:14 -0800 (PST) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , 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 Subject: [PATCH v9 4/8] mm, arm64: untag user addresses in mm/gup.c Date: Mon, 10 Dec 2018 13:51:01 +0100 Message-Id: X-Mailer: git-send-email 2.20.0.rc2.403.gdbc3b29805-goog In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_045124_314189_2F3269C7 X-CRM114-Status: GOOD ( 13.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chintan Pandya , Jacob Bramley , Ruben Ayrapetyan , Andrey Konovalov , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Luc Van Oostenryck , Evgeniy Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 8cb68a50dbdf..409aedb1e2d5 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -683,6 +683,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)); /* @@ -845,6 +847,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 Mon Dec 10 12:51:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10721253 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 C31D117FE for ; Mon, 10 Dec 2018 12:52:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B17A72A30F for ; Mon, 10 Dec 2018 12:52:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A52E72A30C; Mon, 10 Dec 2018 12:52:35 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 287462A308 for ; Mon, 10 Dec 2018 12:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sm2WNzwGxO316nkTGYA7izIlicbf7RWd5pJ1s1ZTIOw=; b=EH/9sBt2xjsSrP w77tno2bRScCsi2GhL41mtlBIPguG4ZDnhmT5w4wQjBW+5I+lHsBrrL2NhOcBdexr5RP3Kgeqnz8V 3osxNgOupqPEVMSNRuqtGxQ8Mx4dcvwYigZv0sOl1dl2BNR6KfGNXX1ylHKvo3Yt/fYqYTlWMOAZC xBos/nACl+E0at15xBAl8PB0a1Qu0UTghwti6eafzecm7IJg0OodJqG5QsoTN9aepVXuR1i1TTjIu kskbXPOg1A8+up/XC6og7z+G8tEt9vGf7UsUXuqRVklyoGyRc+Mp3fEPnz8ambejG/u2z4VT0RauB pV8+fFvZGXGUzG/G1rMg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL2z-0002Q7-Pz; Mon, 10 Dec 2018 12:52:29 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL20-0001CW-Mj for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 12:51:34 +0000 Received: by mail-wr1-x444.google.com with SMTP id t27so10336091wra.6 for ; Mon, 10 Dec 2018 04:51:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=THrF65uyQ43y9XI4Oao8ZCD7W0hiODFoiBK2GnkK+6k=; b=PdfHiKV/nw+CfvDzzUmvpjA/YhVLjcLEJGbE4xRNKckctV4ggJLQ09SaEpJOCkc/Wd TsbWeQ7VqNxHNADvOwoiDxubfQDEDS0+PHacVgOSQwfEz02dQXLOTxmV5IykKVkn0f9a qcdjj+pRCBHgfvFs4fxlSCiaYPFMMXTkQUdwp3B9666yUCdbDg9xBDMR3zDN5H2HdY1U EAZ/zAia4HQUr1OpEIgycWmDLiok+qqigVLOzimiWXbPovc2JNH66nE7jrGjj0/pP7Xm u31n4umKu6azySOlPyk4zWiDSNjuQbTXYYgyyZeCL1TW0iqGcwgkW/T/pb9E8YfCUAZ2 045Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=THrF65uyQ43y9XI4Oao8ZCD7W0hiODFoiBK2GnkK+6k=; b=K832jT9mYAhwfPwD3rENKW2yZ96skwja0osCnJboaN3WJ4PAq0zZRevgIEHc9fDvuv +5W85HkQJyg0OMX1/PTbJKD/jR8rX3PWBpRL8hIuSilF/fmO+tN8hC7pz66SlJUsb62x W80gYdmobYUyuHyfWHumHbvuuB9qqdcht7EvYDzdTgfG08960RyslBSkuQ+yQILiXN1y oGuXGpMFTTBz5g4BAfGRe6GCjpkjQZzkjta1rZyCwu49fYOjQ/RF3OqkKI86u0S1BWfk 1gCfoKam1v3XcowXdg6sMiQ3bkVE5xLyckU9B/ApkDCIvNLYk+wrfr/g1qrnLN2s7vw8 yblg== X-Gm-Message-State: AA+aEWYnWX/AFvOc+m0q4KFs0p7Kt9hD50+bmikCYMiAcBtuP2+fvD9B IS0OQjU5ms9LmiqVd0daSu6kGg== X-Google-Smtp-Source: AFSGD/VI/5BMsRXqnw18fB6Gll7b+Eig1k8PMWahNn8bGC0uXwXuMAwRBnIM/ZnTZkzB47NBiSqZdQ== X-Received: by 2002:a5d:538a:: with SMTP id d10mr9405307wrv.202.1544446277017; Mon, 10 Dec 2018 04:51:17 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id l197sm36893363wma.44.2018.12.10.04.51.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 04:51:16 -0800 (PST) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , 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 Subject: [PATCH v9 5/8] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Mon, 10 Dec 2018 13:51:02 +0100 Message-Id: <2c573564b456327708d175f3124256bc71081bd8.1544445454.git.andreyknvl@google.com> X-Mailer: git-send-email 2.20.0.rc2.403.gdbc3b29805-goog In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_045129_336909_981B707C X-CRM114-Status: GOOD ( 13.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chintan Pandya , Jacob Bramley , Ruben Ayrapetyan , Andrey Konovalov , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Luc Van Oostenryck , Evgeniy Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 Mon Dec 10 12:51:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10721269 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 2206F112E for ; Mon, 10 Dec 2018 12:59:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EAC529D89 for ; Mon, 10 Dec 2018 12:59:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F374C2A1B2; Mon, 10 Dec 2018 12:59:04 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AD0AB29D89 for ; Mon, 10 Dec 2018 12:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PHvoF52Si2ZbH7dUIBnrIX5eXKSAgDDSCUpxHMoNsfs=; b=rpq8/znL/Try0t MLzXzPg2pWZ/tu4loH62zux1cpp2I0vZ8+cLkZymq9hQYo7zjTkEmKzHrQMv34HqtmG6LVF8jA659 Cn9JvrCWNmC5RQNvIJ5lYw1Uw1fnPDW8/aMbfzXU/UfGWcDMd8fsMrSdQfpHlU2YLToTctDUQVdns hFTjqJVIuiElAMItH8s9JW2TekFNmb80nrgiiOCKoOASKRDlDVmq17uVEA+hZUgWJ5SuWzo0J9ZAI c5IIet+3ycS7pCa8rkJY4uQ4lFawzlJBS39/UFRGMeTIFHLuVlpSBeoyzfm47ZyCHP1/vfiD+RcWD qD+EQnjY/Yfwm6QbpStA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL9I-0005Jd-9z; Mon, 10 Dec 2018 12:59:00 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL20-0001Ci-N4 for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 12:51:34 +0000 Received: by mail-wr1-x444.google.com with SMTP id j2so10379822wrw.1 for ; Mon, 10 Dec 2018 04:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pdp/ryV9bt4+HrjeOWrdnZnBI6aj8YPFqzbeaIQ9j68=; b=VEgcxLaXoi0dOKDXk3mvZgG3orCXpa3lyeE6CP4OJMDCNte/zoFeg72gBtyYRUM/+z dkdH0FX3oaVuoZ2TdAnAWlMAq2acZqiJrldMEieGTNK+3b5PjuVvTUt13jkyridlEMir ldYCNgQs6aUD15xGtoBy02lnJF80uPmFB1DrhlhknCsVZxjWvFv1RdkV5JJ5GSpCW5Fm 4CiX7I8udlN21IjNRASuq0xeFFDULrKpoEaM9D2i67zp9cQXXr2TQKyBW/cdB/XiSE0/ JddgPffO2wfeBRJJGAVFDqBC6nXfN7M9u/3FUN6B+81x1rMeN5f1CRtoSZFGlT6PrwZW bQNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pdp/ryV9bt4+HrjeOWrdnZnBI6aj8YPFqzbeaIQ9j68=; b=D1QTHApMI9GfDEn7GRriybY4iXo+SwxEQwSfHP+6X2wxtFM4nY7sMkjYL7/UBtHzLU 8wWoBjF/QPSEIMX3d4dK/VdxyH02oABDe1LSVZQGTr2sqm0UzxEtQAQPS5khLKKIujw3 hKEc82o3yXBbPF61WawLHK8BqDn9Bud17lCSAVIhMl9Xtc0XThyZ8qEfwO4ZeziL6eNJ 2nbYy1e1mp/feJlbiR6dzcgw9bIpmIVUpjb0dYbREq5vn9L0Dqc5Fl1GDTISiO1mT0zJ gCpEo8BXAysGLRAecYg8SlZMc3WMdOggKoYO8a6dSWMetkCmKfNiK8HuPSUjv6ldOFnV +1pg== X-Gm-Message-State: AA+aEWY1hfEEPp4nJ/m7YQ9i8LfcUX9qMSAVPqDH5YnyNpniNSD/olMN auBH560tmCPGxew6FvUh9ZGrYg== X-Google-Smtp-Source: AFSGD/WkZ2Ib7xqoZNcfNco/+WzWdTWYInohVyU59jy0CeiifxD2IPgCZSpbiMewGDrt/7AYo1yayA== X-Received: by 2002:a5d:61c4:: with SMTP id q4mr9258512wrv.308.1544446278383; Mon, 10 Dec 2018 04:51:18 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id l197sm36893363wma.44.2018.12.10.04.51.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 04:51:17 -0800 (PST) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , 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 Subject: [PATCH v9 6/8] fs, arm64: untag user address in copy_mount_options Date: Mon, 10 Dec 2018 13:51:03 +0100 Message-Id: <07a4efa5983abec2355b2754812509a73f648332.1544445454.git.andreyknvl@google.com> X-Mailer: git-send-email 2.20.0.rc2.403.gdbc3b29805-goog In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_045129_288865_E7EDF420 X-CRM114-Status: GOOD ( 17.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chintan Pandya , Jacob Bramley , Ruben Ayrapetyan , Andrey Konovalov , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Luc Van Oostenryck , Evgeniy Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 a7f91265ea67..694dcedb7e7d 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2686,7 +2686,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 Mon Dec 10 12:51:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10721257 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 5694617FE for ; Mon, 10 Dec 2018 12:53:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 460052A2FF for ; Mon, 10 Dec 2018 12:53:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43C6A2A31F; Mon, 10 Dec 2018 12:53:00 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA0CF2A2FD for ; Mon, 10 Dec 2018 12:52:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6WEzhUkvicfrvl9meCDmmmvDwLxLK29RkaawVjGon78=; b=iHEqYQ/5/saNnZ OJiqTBry3ycTsXGi7XVktJE4j1hHZM6i/FZ28pF3OtD4sg08J3zhNZdONtMfisEF3M+Ljx+P5Bfjq RXtboQRoLlsBnXS/KRpmP8O3LdwRGRJ7gtM1J3eZqCxS1JV3KUjkFU3m48mM/JoCi/3PgB/X3dNLT sLOvYUrfAwFFcKh4qImVDaOrfduXOPF6SefxmMTgtSpmPsfUmLi1FzhkDfhU9I8E4JRj+5NRo9uWE 1FOp4S4Stp+WOWFn24uQGc+GwYST1sv3goDWHadH5110X3cr4FJrgeq3UtSthY8GG1QeeoYbxzM4i tJn7k2xCFXQSVN57rPfw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL3F-0002hq-Ie; Mon, 10 Dec 2018 12:52:45 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL23-0001Cl-Jf for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 12:51:38 +0000 Received: by mail-wm1-x341.google.com with SMTP id n190so10865009wmd.0 for ; Mon, 10 Dec 2018 04:51:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ngEuYePF0Ik8OjXWCCgTn5YSoHew/I/tp51mGRx8kg4=; b=CmCoquOIItufHfboXmnykNLOniuP3oph0acoA+XTBGrVSB7mLajVT1E+hcpN/loM2U pgTqfe0K46l6v8uQ0po6d+HH/BYTwg03g4AD3w73FEou0gcZfxKBvZoNJNbXyq/i9XXq oWIL8wgRBrxDFD26bNkbcOl20YzQpb3jqpOq4y7dvxu1hztX+EIEmh8/dbUf5WisLWNC nJQM6fa0ao0AoCzQ9ilewLkC5FCYnwtOcEWLjmZXH3V3s+2vp4n9VdbDuwx1wbwkHrB5 jrV/DTMHI0R2v5vA8+fGBVABLCaGz/a67XaqV0DDQBL/XUY+fQXzNAstsF+zSaEwaMrF 3tDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ngEuYePF0Ik8OjXWCCgTn5YSoHew/I/tp51mGRx8kg4=; b=Z7fRo7/hjJ66BD2aUoazyoT2NTAk/cMA4njgaVUhZwztXiAltSbhgagrjSPQw6cF0g RpJNGonkXC55hyLONSFfi7Nxv9MEeS6ajUhlm3/3rEP3AmzH+2J+V9RhfoD285Mv4jJV M/TzvLPi/H7JdL9oNyeqDDfA/Sgm2JFC6s+go+VfjhNqKTw6rpscOQxFTU2edtOpKC3b dBJfEoGEmVn5HmwhK7COzOXsCz2YBrHkOPqsuA3w0XChckIsK3MTN3ZYZfDaJcQzV+EL inSxgNfqQ7isa+V/RBSxz5oKVxEo54sZqe2IMEYIU85nyIvmUo1zwpvJlzgMnah4XZRm gEDQ== X-Gm-Message-State: AA+aEWYHrokUV0KhpEbemeaoZPQZSMrKLWOqiPbTEycDrDhMUmAZy3m2 oVqytBDFnt0QIIhKWum+CIuDQA== X-Google-Smtp-Source: AFSGD/WCzFmonEHgoYAEBEhZecfqFKbM9P4hOtWijVGXyq92rKZT6lTyCBXPbqUfxWdZxWq3rWTdTg== X-Received: by 2002:a1c:da92:: with SMTP id r140mr11005051wmg.136.1544446279827; Mon, 10 Dec 2018 04:51:19 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id l197sm36893363wma.44.2018.12.10.04.51.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 04:51:19 -0800 (PST) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , 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 Subject: [PATCH v9 7/8] arm64: update Documentation/arm64/tagged-pointers.txt Date: Mon, 10 Dec 2018 13:51:04 +0100 Message-Id: <5b08153a9d69a5aa958071dcc5477c881f56dcde.1544445454.git.andreyknvl@google.com> X-Mailer: git-send-email 2.20.0.rc2.403.gdbc3b29805-goog In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_045132_332495_8C9B4D59 X-CRM114-Status: GOOD ( 14.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chintan Pandya , Jacob Bramley , Ruben Ayrapetyan , Andrey Konovalov , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Luc Van Oostenryck , Evgeniy Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Document the changes in Documentation/arm64/tagged-pointers.txt. Signed-off-by: Andrey Konovalov --- Documentation/arm64/tagged-pointers.txt | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Documentation/arm64/tagged-pointers.txt b/Documentation/arm64/tagged-pointers.txt index a25a99e82bb1..f4cf1f5cf362 100644 --- a/Documentation/arm64/tagged-pointers.txt +++ b/Documentation/arm64/tagged-pointers.txt @@ -17,13 +17,22 @@ this byte for application use. Passing tagged addresses to the kernel -------------------------------------- -All interpretation of userspace memory addresses by the kernel assumes -an address tag of 0x00. +The kernel supports tags in pointer arguments (including pointers in +structures) for a limited set of syscalls, the exceptions are: -This includes, but is not limited to, addresses found in: + - memory syscalls: brk, madvise, mbind, mincore, mlock, mlock2, move_pages, + mprotect, mremap, msync, munlock, munmap, pkey_mprotect, process_vm_readv, + process_vm_writev, remap_file_pages; - - pointer arguments to system calls, including pointers in structures - passed to system calls, + - ioctls that accept user pointers that describe virtual memory ranges; + + - TCP_ZEROCOPY_RECEIVE setsockopt. + +The kernel supports tags in user fault addresses. However the fault_address +field in the sigcontext struct will contain an untagged address. + +All other interpretations of userspace memory addresses by the kernel +assume an address tag of 0x00, in particular: - the stack pointer (sp), e.g. when interpreting it to deliver a signal, @@ -33,11 +42,7 @@ This includes, but is not limited to, addresses found in: 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 -strongly discouraged. +of failure. Using a non-zero address tag for sp is strongly discouraged. Programs maintaining a frame pointer and frame records that use non-zero address tags may suffer impaired or inaccurate debug and profiling From patchwork Mon Dec 10 12:51:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10721263 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 F14A6112E for ; Mon, 10 Dec 2018 12:58:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE03D299C0 for ; Mon, 10 Dec 2018 12:58:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D11DC29AB9; Mon, 10 Dec 2018 12:58:26 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7901E299C0 for ; Mon, 10 Dec 2018 12:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ljOXKo+sbi7BHin/R/23uwZojj3Qt4UwGpz3FgNyw0c=; b=q5t0vATgLTgaPd MbDM7aoc/sL9QejQ6HmznoFraDx/YRDdoX4nPWCXNYYjXO9jf76uMS1+kmLRDiCGNHg5r/G7uC9Yz zmiLhSb4kP3mbCMuz6w/W3PnyRZ2SNZ9YFkBYnf0a6CYchrdNYOE/hWma8FVMdHDA9fE9tde47bm4 rbev0Qb9qfJk1ztMKJrINGUaV0gt2PiW6WKQlNwvaglvKdykFBJ8zub5BSfU8RLFX7SOsdpkD/SvL mdmcbOvS7Q81YXd9qQ0VKo3P6lF5M76U8q6NnFRdP0v5b/AvJzERmX8Pg4Lnz4UIE27TGWGoc/DqC mWSR8wueAKoMlUiw5EYA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL8c-0004Zk-MY; Mon, 10 Dec 2018 12:58:18 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWL1v-0001DF-14 for linux-arm-kernel@lists.infradead.org; Mon, 10 Dec 2018 12:51:24 +0000 Received: by mail-wm1-x344.google.com with SMTP id y1so10752811wmi.3 for ; Mon, 10 Dec 2018 04:51:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=htNgLuq9Zq22KIFtx4RRYdIKYt1PSRPcUvgmlifjwvU=; b=IPY0J0E2deGNCT3dMOHF3Bmylp3aWY/zWUIg1jI0VvEQ2WNai/QLbBSKwAlBlxyEsB +x7Icd34IAQh1eF1POy95Vl5O6jDMzTp1nprbJN/LwulyKw9RmKKZUd6mVT/EGhyqmHa 1tqsX3hNorl6Tem5io1S6kqEJWfpPsISCeDrIXsyYkRRxsiPCNzyartzWj8dTdelCgJD fkYjz2H7kaii4gNRKpGJEs53NjdE6xRgRvcqDrxjXexI2aLvcXhZlFL+oZSfMiIVZd6K QapQS8fhNfIYapc7kpsxaiLrqB/DRPgKAVgCG7yBsEJmJrBewQ3SV+sI+HCdlSJlv52G zPDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=htNgLuq9Zq22KIFtx4RRYdIKYt1PSRPcUvgmlifjwvU=; b=aqIo+qytST5ZMm2GTC3YD4wKfxZbStj9rC4fGTMNCvYJs6M2XpMhHYgS5JoPEDwSBw XK3vwLMEVNFe+W2hgggBAKyDVv7a9KxSWCR2DrdrKZInfg9U65DUAu16j4Rz9gANuZrd vhSHVhFcGmmLFN5BBtMBo3dwry9VNLBmxu8PjGrtV+y2T5xUCdPycqrtxfEct+9OTD0q zLEm0t5VhMN1xmhVFVU7mwg5oUqJCpPKABXe2hDTaHi5x1UuawIqySX9kNMsVzmfmD3B CWyyNsPP2jsoL+k5t0qeeZwTJDwfHV1Tw7oaU7qbnjj67R74qKfRNyM25PGL2Hh3akfj pvCQ== X-Gm-Message-State: AA+aEWZjfPRxBdTZnBW27FPP2gjancCGk4uI6a73V2LjLDexJOwgl2ck gRIOHySOrCdY1cZ1DvXdDBFoxw== X-Google-Smtp-Source: AFSGD/Wvuhf6G6eOpW5vjcIUpM8htygFR/RVEC5RbfnAeJGyaCuDNPuFXX3LyyAqxNCgS6H6SuCQtA== X-Received: by 2002:a1c:d08b:: with SMTP id h133mr10494550wmg.8.1544446281211; Mon, 10 Dec 2018 04:51:21 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:3180:41f8:3010:ff61]) by smtp.gmail.com with ESMTPSA id l197sm36893363wma.44.2018.12.10.04.51.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 04:51:20 -0800 (PST) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , 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 Subject: [PATCH v9 8/8] selftests, arm64: add a selftest for passing tagged pointers to kernel Date: Mon, 10 Dec 2018 13:51:05 +0100 Message-Id: <502466b9652c57a23af3bd72124144319212f30b.1544445454.git.andreyknvl@google.com> X-Mailer: git-send-email 2.20.0.rc2.403.gdbc3b29805-goog In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_045123_084799_58ABB6F8 X-CRM114-Status: GOOD ( 16.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chintan Pandya , Jacob Bramley , Ruben Ayrapetyan , Andrey Konovalov , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Luc Van Oostenryck , Evgeniy Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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; +}