From patchwork Mon Aug 6 16:40:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10557481 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 D248D90E3 for ; Mon, 6 Aug 2018 16:55:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0A8A29101 for ; Mon, 6 Aug 2018 16:55:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3B9229896; Mon, 6 Aug 2018 16:55:25 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI 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 6075B29101 for ; Mon, 6 Aug 2018 16:55:25 +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=WDJL0QjVRn0QQfrIPXYB+7FMi2pz40w6Vl5q5YXmDqE=; b=cHDGXMb0x462qn lENdTfdB273RvGMV9VTtbejZDgEGEsPZAXhzAkIjkgunJizZ20DqfD3s9YGhYc/hkFAh1PM2Pz1Oz +SX0wvn28OezhktwXTlTgGYjpM89hB+EqJB0NQpQ/6W0cGdyaUwOXOFGo8SwTQsRbk3vYVJARgmSn hEs7DGeYBWB4I2JlPqzMxPoUSl7D480jAe4+8xDm4VmOa2972KGeBpT0JfAqtLhMg7DIAHEuQjl3k 0HZr4xJEwG1KAV/nA06rYlUJ/Vtmwqvhg8dbHPIxDzU+GpTRXGxF7zaCVyfjKeE4uSmYt8eb6gjKq sn3Fcb/+GW4mqnVE2aPg==; 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 1fmimw-0000Dw-UF; Mon, 06 Aug 2018 16:55:22 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmiZC-0007Tv-Ag for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2018 16:41:16 +0000 Received: by mail-wm0-x243.google.com with SMTP id y9-v6so15088409wma.5 for ; Mon, 06 Aug 2018 09:40:56 -0700 (PDT) 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=GegTTjbmNjbsX4HChAan54mquc/Z0XI1PkIXzAwJIOA=; b=vwCS2rS+pYmdg61bP8gDqGFfjdo/PBgT6JVV1eg1zZd9Nr82b0S2clR0RH2K9s8WZb lnWNV7aUQhgx6ozlH2TgLTj8ytb3Gbl/BbeMPpAYV9WOz45c2GWctVCc+0N88H5Go1DV rD7PN/GFtJgW1ZKKhPcgh/1w3TJCnnxeios0hCtkgXFGbIZ9WiU821qQgiiDf1vvJ6Ck dg4ElQes4DdNeBtawrfXt8Py9CeCHaFfZElhvErprQq4g+cVxwUqfhrZuceiB8lvps7e evQ7YS8E34ofUmAzfr6OXPU/0Put4HaH/XQyRfpB6Tbwh2n9YjSEjmLbiSHYQZ/AAk7P bgng== 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=GegTTjbmNjbsX4HChAan54mquc/Z0XI1PkIXzAwJIOA=; b=TfoUajNlJpbiTYT6QMVh4XKK89qAkreBtgXSwvfB7Wrh+Xs+0vUVkSzn1kUv/q5gN7 b+HANLdw8rduSpxQWTNVdbV4H9fcsxEIH/pr3IOkGA9t+63U/mofy8TR1rmXjAtq/Wsc vi2JWt3545RqN3HnUK+Fgb7crgtH+wj184vWjwt0LcIgR5nowy1awqME8vfMn4OfqbIl AZojr7vueYweUbX2+XZPIhtjS407bRGZOPOteJYBgZbi/nSCyBBiEJEbvEqhlwuYGLv5 /mgYdCCsVFdHkgjGQ5uPAW16aguZHJhYd7BwgrGgETTAnG5YLu8l/x+AhS//ar5Xi04A 7SkA== X-Gm-Message-State: AOUpUlF5UAQxLgY8PX2Mrkp35kNKRG3+H06/gD/yAkcT+6zzHdgLxz08 +eb33ETP+qEuPXyHA0XKzJiRSQ== X-Google-Smtp-Source: AAOMgpdCs/vJ4E8irRmzR7MSfblRn+1H6Z0RIGz3mXzRBYhElgG2TSHw5K1OwojBrGMLhngHuZnOFQ== X-Received: by 2002:a1c:a691:: with SMTP id p139-v6mr12041466wme.42.1533573655186; Mon, 06 Aug 2018 09:40:55 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 66-v6sm16385790wmw.34.2018.08.06.09.40.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 09:40:54 -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 Subject: [PATCH v5 01/10] arm64: add type casts to untagged_addr macro Date: Mon, 6 Aug 2018 18:40:36 +0200 Message-Id: X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-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-20180806_094110_363468_535FBFB2 X-CRM114-Status: GOOD ( 14.24 ) 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 , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , 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__. 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 Mon Aug 6 16:40:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10557431 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 19F1A15E9 for ; Mon, 6 Aug 2018 16:41:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 085D0298B9 for ; Mon, 6 Aug 2018 16:41:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAF1F2978E; Mon, 6 Aug 2018 16: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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI 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 44E0D2978E for ; Mon, 6 Aug 2018 16:41:29 +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=7ErPk7T8JyWqifqb2ooqnGZE/WWeLkPBIOBbsUWPYNE=; b=YZQEzvE48O/EZt N3934p8+VIhn+M+s7ys5uEO+Nrnw9VwOw8hUZK7MK+8O/8K3qVKPtZgzTLqgq/WXHictmfY5tWRhe 2BSy0cSw1R+vREgxnjPNQP27eEfTveKvXnrxKztqGxO2BERUt2C8S9WZSbNr9g7M7VWeQqNM/m7j9 zy+6GuZmyW06EHQ9dLRJ+Jxa2w1Lg/ZnJD+ADLZSQFmi6dSTOXee3KfgHYcbwH+AVF0FiP3D8IKhZ 0rpj9beSeT28dn+C3HFzXbhvwH0W70oaiUoySiN72YYczqN9TIn+jfB6rjEqmed21/Td7xh3UAefe DTJ6ErPe8uP5x7egTVyg==; 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 1fmiZN-0007oo-D2; Mon, 06 Aug 2018 16:41:21 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmiZA-0007U9-8U for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2018 16:41:09 +0000 Received: by mail-wr1-x443.google.com with SMTP id v14-v6so12996912wro.5 for ; Mon, 06 Aug 2018 09:40:58 -0700 (PDT) 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=YBeH5wb0hNzlivAoVU1htfthx3SJVx7ZblkVtJGW9ZA=; b=ZfDD4//e+nKU3Jk48Adjac7R2nCCq1HmUAoIcnD0wQGnnbJdjWUlD2Aytat6evC4LS VVCRE4GradGfF7mcdUatpkfkbS3oUExjCB/oJKRWeOgr7D4ns0ZdM/ecmR+rDEiJijY5 S5Sn5a3jb2HgFLP5cDZykHlUrABGLypRXZBcf03L4NF2mJDMuWsf2I0cBuuPGn4R+s/1 lH0SekuGSZvecQg1AancsSigJdj1Yu9rEv5ENqjlxw1iJ0P7zjekaIIfk0F3yh9DLnKi TZpN0Zr9j707UzVmqzktL466xYpXyXTkduX6zmE7Ee23DujIeKOV8ZkSblww3yE0f9TH 8Z4w== 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=YBeH5wb0hNzlivAoVU1htfthx3SJVx7ZblkVtJGW9ZA=; b=uSxQQP6TFg57IIuaFkXoCUEORXRfjjg7RuaXjZZaRR/nA0bx8vtW7+YKz+1tWPjihB tLc4YjlVLnc8LR9KOKlZUe9dpYZNM5yF8Zb7TFEVXH5fIrNmBmDqPpkCjbdUpuG3r6gS lOzNTx2G2YBOz/wG/fpGDSorK10qWeglRTne2mV2FNXWmXSR6RCvQD/M9kYJMuNVp+tQ M+t2E1i6gz+PclM33aanyeNq5k15bc1TicmbdE+R0Z3ugTIXFcnl7e4seXFK0mvqr9VD akmWf4B0ndUYMDd7xrX87G4/rWfrNha/8KYasqOd8eW4ByyjEm9h+x7rmQhLrrn9rV6i bkSQ== X-Gm-Message-State: AOUpUlHsnZJuxRQKlFHUa9Sx3cncA52Oe38GAkj+jHItSSetxHo9HH6X cOWjCMT0RbMst4Ec/v7C+mMeIA== X-Google-Smtp-Source: AAOMgpcsiooZAsa7Co5DL90XZQSeO75lLqOzA0ZY/k14f/rzEmHb2gPZjF9ufPSZOUffbBSYdCeBEQ== X-Received: by 2002:adf:91e5:: with SMTP id 92-v6mr10363242wri.124.1533573656582; Mon, 06 Aug 2018 09:40:56 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 66-v6sm16385790wmw.34.2018.08.06.09.40.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 09:40:55 -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 Subject: [PATCH v5 02/10] uaccess: add untagged_addr definition for other arches Date: Mon, 6 Aug 2018 18:40:37 +0200 Message-Id: X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-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-20180806_094108_300532_ED3B498E X-CRM114-Status: GOOD ( 13.27 ) 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 , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , 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. 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 Mon Aug 6 16:40:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10557441 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 0F11513B4 for ; Mon, 6 Aug 2018 16:41:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F148729765 for ; Mon, 6 Aug 2018 16:41:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E456C29790; Mon, 6 Aug 2018 16:41:45 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI 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 8834F29765 for ; Mon, 6 Aug 2018 16:41:45 +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=swaAzDSAjXByq1rqRh7MbV+JzVau26EUygp5okalsLc=; b=bQ7xnkSZnHtRBX xECOXDsEFW4LM20g6CJ2dJz63MOLsxdY7Fg6m2bpeZlf7olcC5lX5kdoJMWEQ6RRLjjdqvtPAmUMR 0TGZVwm29w4X2fOQPNDSGAvo/LzakFMjO5sPWfSc8KZtEssTe7+6VMgvVVhciXFOoUmzWrcFd3E1h UJH3+YlTG9J45mSmd8xUuPHnVtI6kiCrQFkie92zYHWwBX7MhY/m8S8iQwWXiKCNmzKH9k4F9kLWM a3rUQM4/mkZCAXewldkh/6t1cOc4Ix1gylpdCG45WVkcY3FDbVjv7aTmiRF0+bhPuP3ZsR1nHfoLY kSj5IGvMlLT6hGsLg4mg==; 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 1fmiZd-0008Dy-FD; Mon, 06 Aug 2018 16:41:37 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmiZC-0007UH-0N for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2018 16:41:12 +0000 Received: by mail-wm0-x244.google.com with SMTP id w24-v6so14983152wmc.1 for ; Mon, 06 Aug 2018 09:40:59 -0700 (PDT) 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=WADZVauYt2+vN10op76v0l4/uhmUIRsYzVe9gnbEQFA=; b=hY19VVlNC+aT5T0+2ijd0mPFjapVd6gfqUj0erw0EDOJ7eBmW+Z2x+XRfZD5O4Ac94 3I63n27oCUcp10sI/R6BhxKri6mPzwVCDsDOb3SWT19hUTxakDBMMYxpjSdnaqFuVuLc bpml4I6XJiFT2ngv+DVV9M2GX/Dx2Z7qOxaYHLhvHwuI7CE/9/5OFZL5C0FrKLsuBTup FKle1LaLfIHzrfWzOuj2ESOMv/mfS1XGNWkuASeMkcTFIcbmIBjb+9eD3ytrtzihsmpN Eh26t1BM3+6TAUjrYud29s8Qagu0ISZ3YeQG4hAkl/UkhkQfGbdL32tE8/Q1VI+PBaAb MdHg== 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=WADZVauYt2+vN10op76v0l4/uhmUIRsYzVe9gnbEQFA=; b=QwXZx82SfSTfHx8od8Z/4WcExqkOzmwTRXO3VNL7Q2o98x+nydL3wuSKmQOtIgLgHx 9PVG4eJ0N852Xl15lV5tePq+01qBRlC/BgEWguAPVfcnRmpULqHBye8cp67fnJEr/OEZ 4SSOeDMRMbPJBVbEy7JiYX/TsTdV+jhurvf6G6KdBIzmnrIoF4+nwPwIhPycHzroiA/5 70Vtp6kjGvZLAi6PE5FsRux5pCd0MJb88IamuWCmhwatwFx8Xhx7CR52XT/Uwi0Fp9Sp sWeofW9ydGkNR0wA2E4gYb8Y0TFs4GyVB/g8Uz000oWHYV7TrizUlRWvw3A0yv6gfj4P sbDA== X-Gm-Message-State: AOUpUlFuRaF2m/A9hZL+nS3LzRcD3ykrcc2QD+TbJa6dAI7I3VgAiMoq KEpGgb3ujteiL5EOBhPAz2UKsQ== X-Google-Smtp-Source: AAOMgpckRAYy9vorc4eMVCQ1Uc5x51WbaAcr5KT0f6sPPmsBT/dX4REx1PziWt7qxPnzxNWYQXu1Yw== X-Received: by 2002:a1c:3314:: with SMTP id z20-v6mr11558447wmz.95.1533573657895; Mon, 06 Aug 2018 09:40:57 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 66-v6sm16385790wmw.34.2018.08.06.09.40.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 09:40:57 -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 Subject: [PATCH v5 03/10] arm64: untag user addresses in access_ok and __uaccess_mask_ptr Date: Mon, 6 Aug 2018 18:40:38 +0200 Message-Id: X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-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-20180806_094110_150418_D1FCE62D X-CRM114-Status: GOOD ( 13.76 ) 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 , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , 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. 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 Mon Aug 6 16:40:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10557451 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 14FCC15A6 for ; Mon, 6 Aug 2018 16:42:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02B202978E for ; Mon, 6 Aug 2018 16:42:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAA7C2981B; Mon, 6 Aug 2018 16:42:09 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI 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 A1F8D2978E for ; Mon, 6 Aug 2018 16:42:09 +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=HY4u8ZMa9PM+ihshSqqnzgjN/eMw1QtwzqicwGPYTHs=; b=EuAJyGOtDbyWkW 27K45yAmr5sDkcQUZYQ2XIoKqkfjs7GHcvLdggy7/agYSG37paFtnA8nnEm1KPeDvfIqq6Sg4DHRv QXGIsNc6MxC+RUzU+G/OVXjnDISlWINs+/ckBON4Q8mA66B62XTV5ajqD2x7Ew8tJX4KZ/QGG4Gqv Zg3xAg27KorFnv2mEN8Db1uDk7vJkIu9pgmMAsNSew/j1uJws7Jff+QzDEvVocIoEoXBCoRNPMAXQ 3VG2/Qg2RLYygXHMQA5/Ks6aD1DtrRyNd2EsblemTRO8ZByckzooEDTI0MEbiXUzKdCAeX+8gxetS hoC8O2Uxmri0S+Q5KkkA==; 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 1fmia2-0000Is-Ix; Mon, 06 Aug 2018 16:42:02 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmiZC-0007Ub-01 for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2018 16:41:14 +0000 Received: by mail-wm0-x244.google.com with SMTP id l2-v6so12057743wme.1 for ; Mon, 06 Aug 2018 09:41:00 -0700 (PDT) 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=uFRCrIeakYIo90pBPUFlidHqpT0Hqqs6ARXRy/1gDrE=; b=AX+6UEOD4pChSsOaVJW9/HUmRY/Hud5HGf4nl2GADVcqj7RWjxiy1PFox5NDqoN3dO vfpNrriAJ6/Xv52Jjqyqc9GZabpYl6HbtIODPOr9wrot2mbZmq+FrgNtfun2vMh/n8f2 0C+SdMEFuWM5HRB7mTci48rybim2ePdWLxmoLET2gDdHVHgj6mmFfrEeaa1EVkcYnlhF K8cnjvJpET1k5OuNulN1TWP84QgVEtmWHZI2SiaPQ+4Aa4nJvZkzmRDejbEC8H7Bcu/a zEh/B23/FKOADejZqHo1wu+YxSnPzMHo8lGXhQkK1Kl7/IzBtzMyTM9i0BHxg+uHp1Yg rCnQ== 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=uFRCrIeakYIo90pBPUFlidHqpT0Hqqs6ARXRy/1gDrE=; b=sEMngxCA3jZ3gkPSDYxrxH8F21ND2jTJ6oA30OV2fddRkDmQ0KXwdwutyfiBK2uy01 D2k40tbHbN83H8zcFihv3FgA6bQodpH6zyEHqbNkOyltMpJNgzdj7sbSdrqc1LtGq5R7 wuetMoicsODrtfbyxOjzdWb+2jzL4oAkjCZwaLSmOyPuiZWoqw87tKHGwfJlMbZTbPpD 2Ph7PnbVrWr1px6VJBSOoW9+/+omlVSB1+3SaT4Z2HFeO0R7S3FmUeC0Dccs9jlO4nyj xIK6MTO089QUg/rNEQlyEP7sQaYftmSDoe2Nk2tl2y1yg/5zc7WltQDG3zdv3JZOJwIl oweA== X-Gm-Message-State: AOUpUlHWLtcIoSuI5WEmDoSz50Bbck2Ry9pzppub9TDQEGQaZN/qzlOD ApQyS5TFQM6qJbjLljUiGUJPHg== X-Google-Smtp-Source: AAOMgpcfIK1v5kRJhsLZ34SjY23HZ47OTWWZVSIMkNKjxkQyM4NJfzwreb6Ygxh/ZoTjJ068qYgKyQ== X-Received: by 2002:a1c:f03:: with SMTP id 3-v6mr12283207wmp.129.1533573659155; Mon, 06 Aug 2018 09:40:59 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 66-v6sm16385790wmw.34.2018.08.06.09.40.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 09:40:58 -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 Subject: [PATCH v5 04/10] mm, arm64: untag user addresses in mm/gup.c Date: Mon, 6 Aug 2018 18:40:39 +0200 Message-Id: <64762ca688f8611c38cf6a8c8bf50a75d9f2fa3a.1533573460.git.andreyknvl@google.com> X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-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-20180806_094110_193903_15F89DD5 X-CRM114-Status: GOOD ( 13.06 ) 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 , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , 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 fc5f98069f4e..ebb87fb56709 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; int ret, major = 0; + address = untagged_addr(address); + if (unlocked) fault_flags |= FAULT_FLAG_ALLOW_RETRY; From patchwork Mon Aug 6 16:40:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10557461 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 56C8515A6 for ; Mon, 6 Aug 2018 16:42:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44E3829765 for ; Mon, 6 Aug 2018 16:42:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38EE62981B; Mon, 6 Aug 2018 16:42:34 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI 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 B6D5B29765 for ; Mon, 6 Aug 2018 16:42:33 +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=eX+m5vqgpuNeahJtMStJ3J9shakfsKXLoy6H//CkkAo=; b=kdNdiqxk7X/LPI zv6Bfm8qew7CwGPri1tbwuJRPojiCFXorfQjfVNrl939IfpMH9DqBhfRmAErNIO1BHCUGcgR7A0gy onglXS9YNBT3w3n5l5BlpanwpldjmNR0uIE6v0k83lu4eqrjeQwY3/maPJ/2pQY/BMCC6e5Evbhaw F6ZJm+fe4drHueHouezfUZ3fmlfzwc7WEtZsNKShZr8DGJTXrWqr0BuTSyplc0aDhbSAV55REJIll JfFfM915thCzz+zHjuYCYlOlsZjy8CfGSyS6SWcRtr3nAAilJkp84GWm2q1mrzYUnByED/IG0CxJT 7NzHG7OuXey4svidjk8Q==; 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 1fmiaR-0000qQ-Tr; Mon, 06 Aug 2018 16:42:27 +0000 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmiZE-0007VE-Hg for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2018 16:41:17 +0000 Received: by mail-wm0-x236.google.com with SMTP id l2-v6so12057803wme.1 for ; Mon, 06 Aug 2018 09:41:02 -0700 (PDT) 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=NHhNjwTAQ121lFvWu3hMTAeIOaL1SqLvmyhWDld+/fA=; b=nmzurxSKJcYDsYV1+eQXo1AFKsb89KkGcBuugkQwRDCSRWjpnPT5FmuaK8hAnWtRDA 8/kdbUdOeJA1T1BUmRPPsYuEcN3Kf4vSMrWGCIeeWUORWVyj7dCOJBssyjuH8JPfu5d4 oo9z4xhcuG4G4MuRRRIMSo/OxcZmT2KNXiczN+sEe4P2Pm/xXP4k9NmziQ6vBFSg4gYw KSvZQ0EjS6wIbckSFwBHy7RkDJgcDfgN1QmlhoruRTi126+u8b2e0oSpg+Spg/tf2+H7 TKeHDNyXPqvg8KF+N5zbST5JPqKK0xbhHR/FCBhGHa+94zaC7S4DCqWFdC5El1TiFThF mylA== 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=NHhNjwTAQ121lFvWu3hMTAeIOaL1SqLvmyhWDld+/fA=; b=L5yxW2fQtteFHYPI7IpC9QRE+hYoQA07b3bqqVmQgdI7jk+8LEb/dxDerzFcPy1RLS 9eRHbuT3KC8qEVfver6I/TsWH/DxdQGR3Kuc9Bk+CqWCl6fsz/W0wDfLpjvRs6qL8ABk bBnzmt/eFdLcZMMx0nRKB3EHEXTtNvudRxiaB0DRMdLJw3wEfrC8VTZ1TeWEKiMcmZsX lclMsLNpB6a/W+gFQeMSUQhz2aOQHgJqxGTIJJN2TmKBBVemYP2VAqgSjbl8Jf3s3sfN TGT6g/fZ6PRdgZa9Wv/NukS4rTJxMTC21az2+y/2DNoPcMacOTCbS0mo0YxYUGsRaRad XvNQ== X-Gm-Message-State: AOUpUlE5xafpGkqTiYDD5xX/MOHPOgmeIURfKctV1NKE6aKAAxJlkdps bCPhDaCA4SWiXyfZ/oTQvNAy5Q== X-Google-Smtp-Source: AAOMgpfcqP6DQGXwm4G0u2QWpeaFGKnbiUme9+ppvLZU345bSzHiJYtDTNzNNLOci83AySBymYgP7Q== X-Received: by 2002:a1c:7e92:: with SMTP id z140-v6mr11662280wmc.48.1533573660613; Mon, 06 Aug 2018 09:41:00 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 66-v6sm16385790wmw.34.2018.08.06.09.40.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 09:40:59 -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 Subject: [PATCH v5 05/10] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Mon, 6 Aug 2018 18:40:40 +0200 Message-Id: <6a59f7eef9a056c632a515a3a51ade3f6420b462.1533573460.git.andreyknvl@google.com> X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-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-20180806_094112_980004_E88D703C X-CRM114-Status: GOOD ( 12.99 ) 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 , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , 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 Aug 6 16:40:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10557463 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 D34F215A6 for ; Mon, 6 Aug 2018 16:42:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C130D29765 for ; Mon, 6 Aug 2018 16:42:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B409D2981B; Mon, 6 Aug 2018 16:42:47 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI 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 6F60329765 for ; Mon, 6 Aug 2018 16:42:47 +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=A3mkj0Ad9BIH7kSwL+CG85H7309k5dXsgMdypd56NkY=; b=O8OhUwMKne52nJ iJsNXwwbzOjWP4XLB0TaHo7CpHJHVws8UaDVr8ikV1CLcY/6V18/DOwCoF50XiaHiZSX0dPYwOZNO glixwoL/jYkVCIEtxBcs528Bu+f9Ir9a6G/pnm0j4bM8TKOIg2dHi98sj0nkKDAAdoUqnVBaISxho BJpTA/0VNcdtKGhB+rkxFaWreDSrPTmNnHn/jjYFS0waOUW3M7jldMxyUhYaaAAy/6BGtgYfxWFo+ Hnt/5AYPfAyBHIhAX4GIha8ufk/JHz/NDql6Ww5f3Vjmz2TKZp6U5Q4cmu+YZUPwJLQrAHR1oJyDY oanlFjznuF8ExPoAl5IA==; 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 1fmiae-000174-KB; Mon, 06 Aug 2018 16:42:40 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmiZG-0007Vq-23 for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2018 16:41:17 +0000 Received: by mail-wm0-x242.google.com with SMTP id s12-v6so14501693wmc.0 for ; Mon, 06 Aug 2018 09:41:03 -0700 (PDT) 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=5fRpq50lZXJwhRR4cll4FW2BMrTPAWBgy5AakciCwzI=; b=ZGPkGAitVZH43xaGKInnHdd7n/tyNFXUzL/qaHmZCe6+KqfeJS77EJC8jpTGmiU2SO FzBsG36dBCTrIkzWu7kBkjDSJ5fbo9HzHHpwULu2+NoF4YKnPx2mMKqPQ6pAqaU+lAht KS8yf0vS/2EMM6y6c5ON02j5qVjYR1ZgccetnnSEPi1qy0nKoCNXeGe3MBLWUTVcG4y5 ZfZSGga8z9m37aTIH9e8f0b1iTeoQe63qTqsPyBHuvsvnOwmUUef0zRMpeqgFq8qOZTE KCQcpTxFLAh5tLjD/wxtGyP600A9uQuSjuRPT2mpi2rpLX/7Y0KGnc5Icm5Qoz0w3r+s oyqw== 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=5fRpq50lZXJwhRR4cll4FW2BMrTPAWBgy5AakciCwzI=; b=We87GJrwDRsgU1d0HdddNEmwygHDPrO/3Z8vtUb9BAxENMcrk4is5wLjBJILxzOg1w kuMDw0fzPGISgNcY+K93hnHXrhSyBNEQNMKwKhc7fPWH/LxlnMucuo+qF6Ps6Wu3mGnI ANr+v4LQ5q7FZD7pA0h4o9HfzVOSbZ3kpkoc2PVyIdcxKo4hKxKwKzhn6J+yOnEiWuff zA5IcaBoUGKsxP5ZnMJ+lKaol0NuGGxySBkH9xrLb2VPKIQ6FueyE+okI9P7c1q4X0Sj Ev+ec9wpwwPhibwydcStO8lf7d9osK2MGdO/3cVZpSHqZm/NpOaB86b7NIyOVAp/MO3Q BWKA== X-Gm-Message-State: AOUpUlHWowlfd3anWhH9FSjGmhvzSXGIyZ3+fXhcO6rIf6GVRIHtlm0a /1yR7O0dQ314MLq+ZjHxgkYMTg== X-Google-Smtp-Source: AAOMgpfY8aYVRq098HPSl5HcnHIV9H6zFUoOXHqCl8eBn+piyFbVnG/gEtDm0yEYaeKPInUxDQL8Gg== X-Received: by 2002:a1c:4405:: with SMTP id r5-v6mr11514009wma.4.1533573662204; Mon, 06 Aug 2018 09:41:02 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 66-v6sm16385790wmw.34.2018.08.06.09.41.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 09:41:01 -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 Subject: [PATCH v5 06/10] arm64: untag user address in __do_user_fault Date: Mon, 6 Aug 2018 18:40:41 +0200 Message-Id: X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-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-20180806_094114_464169_0F11F218 X-CRM114-Status: GOOD ( 16.82 ) 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 , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , 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 __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 b8eecc7b9531..89033d992d28 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 Mon Aug 6 16:40:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10557479 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 76DCA13B4 for ; Mon, 6 Aug 2018 16:55:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6464129101 for ; Mon, 6 Aug 2018 16:55:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 575CD29896; Mon, 6 Aug 2018 16:55:24 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI 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 01E4329101 for ; Mon, 6 Aug 2018 16:55:23 +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=a21IGhVA7wq5LvoZl2Y7h6UL6W/5919i8Hj5B5bmzOY=; b=fJS0kjvlZtF9qh m0hQw+LmY1hIleR7N3SvLb2I6AWdrj0nwvt/Wteha408MhpTKxi3mO+oKY7aGypSsmGKhEWj3i4UU ipywYgNSF4ehGRT0U+7g0rU29HWtFYCQrAD17gEOH9oahgFHAUm6oc8v+K1MAIvll45XFmJGESsIu r+tcdKY9zBlx4ehh8InMACre7B/eygGX8xE8fzWJnB3asUYOiv3b5aKDioF0LcwxD+IX4JoISCzGS F7zCHRUBURdWx40Qo7GQdq1F9PRQ7oj9fCinD56uJD+dvVFdDQSzrVMHavrCOb8ZYq3WGRDqMdRLe OFRQ+EZMh+WNaDQfZmCA==; 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 1fmimw-0000Cj-6p; Mon, 06 Aug 2018 16:55:22 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmiZC-0007W2-5V for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2018 16:41:15 +0000 Received: by mail-wm0-x243.google.com with SMTP id y9-v6so15088772wma.5 for ; Mon, 06 Aug 2018 09:41:05 -0700 (PDT) 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=YhiwXQETzFyRuKUoiUientUUS69FHU4d1USosDKGiBg=; b=TdFiCJWQV1yY7auvDE3OMD8elRn00ZYfTJx5VBDb0vmH70JjcnkbCr00a2DIqbTxkS u7P78OkVA7gQ2mUn3ucxrt0JtyrX1cqTglzaw1x/dguRXxGb50g/t8CD+nUQK1HGE0Zp glmM2eLYnNtONsT7coR0+ZV/xEq9YDzXdaTDB163co13OWzCFpLqTdc6t/n/9mu5/ri7 jX1FY0jxM1iC2UpEDrLPzuZMntSNz0ZVEPRb3jD0WGCqCJ9fJXFePlZnlDJrBFnRiOvN tvYvAMZWoxtpd7wNSEtF6rRizE0sA+pJRhf7h3xozmr3qrKnhPbxGuFUAgAjiDuMzDpo Jisg== 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=YhiwXQETzFyRuKUoiUientUUS69FHU4d1USosDKGiBg=; b=NNbJ+56aYINplLuXDMAV6fQvzz0cD1S+XaWDLjkQsSq0O2e+4JIgCzu1CctQ1XnA+q cp0k6FVTVM42QsjCZA4EsUtpz10iLMcYOhQK3p81ljkPrE6DCLoIhdl+W3SsADEFnx8q hAoMdvBuoZqs3GsJ8drwTsisZrODYKTHAXtkMVlv6eHDPrPKs1EUHQ5B9QGQxSGl5agG HnI5Shk8TVk2foPBvtZCNBpbQYDU/04CmKnkmWUoqipscq83xeIpLGPMnBgVJ0x+iGUs zOGoJXCah618z8IUNReTQ0gZnzmPKWNn3kLCNSkVlA09xtSzzCFUercdg5Z1qMuStyo1 zKzQ== X-Gm-Message-State: AOUpUlHNq13+waEOcT4mdNxblKYYEa1oDtgi5nC0W92RguYLTIHGVHN0 etbBJy7d4doUd/2bY0/31/s7aA== X-Google-Smtp-Source: AAOMgpfgr6iQdZfaudH/1Dxp198cQUe5jRBwkr+pUFpoQTY/gYwoncrlREotSNcycesndSR3fYlmIw== X-Received: by 2002:a1c:6d9a:: with SMTP id b26-v6mr11379886wmi.74.1533573663633; Mon, 06 Aug 2018 09:41:03 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 66-v6sm16385790wmw.34.2018.08.06.09.41.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 09:41:02 -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 Subject: [PATCH v5 07/10] fs, arm64: untag user address in copy_mount_options Date: Mon, 6 Aug 2018 18:40:42 +0200 Message-Id: X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-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-20180806_094110_298268_D9C77CEC X-CRM114-Status: GOOD ( 17.14 ) 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 , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , 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 8ddd14806799..fd070e65e529 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2733,7 +2733,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 Aug 6 16:40:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10557445 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 5CA3C15A6 for ; Mon, 6 Aug 2018 16:41:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AB7929765 for ; Mon, 6 Aug 2018 16:41:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E59729853; Mon, 6 Aug 2018 16: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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI 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 B369829765 for ; Mon, 6 Aug 2018 16:41: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=Vlw+7mXIMgef296jOIcOBMxm4+F5cQisUXBN0/0RuRk=; b=JXAgFd59nW0o4o VbZYZtkjUoklERlo9MgGxgs1FGphqv+L2wu8Tjzvy0yGZXBaZwHru59hAgrGnm9eZuOodoxRbfgYa umTIC3j18VKoAiJa1j6eqyAa0Ww9NaANnJObRK7IKfA4869BNoEUpL4fndod1Y3s39LLTGg7gUJXL Rc4/Tl9Xpwixb9cf5riKybZygGb122JKHO/TWRIFIkdHNK0C5ECylU+ilmIHHHqmtGXVO8yts964n EtFnIA8wu7h56gNV4TJvit785UQEL/132hQWVJjpW5pnYzmPI0Uy094CBbnsZUBx+1eMccsWIS4ka X99esaM++J0fU73XGa4g==; 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 1fmiZp-0008Ti-GZ; Mon, 06 Aug 2018 16:41:49 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmiZC-0007Wc-0H for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2018 16:41:14 +0000 Received: by mail-wm0-x244.google.com with SMTP id w24-v6so14983526wmc.1 for ; Mon, 06 Aug 2018 09:41:06 -0700 (PDT) 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=MRLVSCH0Nl1kzAwRQQajvguDlRs+/L7hQOGZ466Yf5o=; b=imLs9/aOpxfxymi3Jm6LL6Cl+HPgYBfHrn/Rg9Cv1bIX3BAGWdVj4LT09FPkG31amJ 2CoFZRgddIiWLsCzIWVXY1G1pFFxYVV8Mfp0qYuiZKiuMWN8Z0EzTMIHLKSlNuRG8u8T xollaHvv6gm2kjD0sMtaDFY/wRtfr0zOBGh8hemHLeRmD0Zq4K/I636KJEl/+SUtHWlK uPEVc4iPimcP9RTeAqVnlD6hx+VF6k8mnbMDmCCsv5pwcAQHCBhjwC3K4bOq0jwDBs8d fWI2OUe+eqE4h6JB7APAHwjbDL+As93F2/61VDpaxx+VJF3TJmmPJ82EujRrL8QyfY81 0kXA== 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=MRLVSCH0Nl1kzAwRQQajvguDlRs+/L7hQOGZ466Yf5o=; b=lQ12OARuTPw1kiJcu/oLDc4nsQa6y9WnV6wVCkMWAKSO6+yZWWm7df3R2EQARWmnyq f9ll/RbltqXDftafVHvp5oOxLEbFgNh2WvgRu4ZdodmG++FsabxwFxC9TcdhC0//F5fQ COCQ4V3Rbq26NFLTKXiCkJPHRsBJeVNJKpqJ/axvSH8DwctRRLvkwB9/oJ/AxCpmrbp1 AcQiqoFh3QyvXMeRVFCOGW4ZoRle8pLMrngrH4eT/+W+U856fQHg6nth68MufvV6eJ3n JD13LUuBgF2S349CA5PKSbB9FgR71y+iD3pyKsMyZXCj5+82CX+Zl06zgjoeh+Zxlb7p FYkw== X-Gm-Message-State: AOUpUlEVkhjZSLcoCsxwzJ30R1LPgzQE0p81nch7TZPBEUC98d7k69eo h77JO/sd0nCyn2hAT376r2oKPg== X-Google-Smtp-Source: AAOMgpdwhViAs+BEk/dzpjpUJqfDn+Z0f2edpJCMumu9mOlf7GNNn7B6rxYD936ltUhmZIL38rBNtg== X-Received: by 2002:a1c:b756:: with SMTP id h83-v6mr13169480wmf.8.1533573665078; Mon, 06 Aug 2018 09:41:05 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 66-v6sm16385790wmw.34.2018.08.06.09.41.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 09:41:04 -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 Subject: [PATCH v5 08/10] usb, arm64: untag user addresses in devio Date: Mon, 6 Aug 2018 18:40:43 +0200 Message-Id: <39bbae2c9d880bd3c27ac3ee03d4be72e161491c.1533573460.git.andreyknvl@google.com> X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-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-20180806_094110_140759_0920DE08 X-CRM114-Status: GOOD ( 15.76 ) 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 , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , 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 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 476dcc5f2da3..357c2e7b87b8 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -1404,7 +1404,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) { @@ -1633,7 +1633,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); @@ -1712,7 +1713,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 Mon Aug 6 16:40:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10557483 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 DB750139A for ; Mon, 6 Aug 2018 16:55:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9EAB29101 for ; Mon, 6 Aug 2018 16:55:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD13729896; Mon, 6 Aug 2018 16:55: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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI 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 712DB29101 for ; Mon, 6 Aug 2018 16:55: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=68XhYcs0fwJRXBo230nU65RaZzFBHZJ6Bti31tn5vYg=; b=j4cxxS4vnFUeOk dFJ1j1Z6WS9RmRW0VPmH4uhbNtIssu0v1FqZMUyEwMDCI3wmsYH41ZSX9QiFIFtIF7/9dHsFDhxse zmg4lZ/ZznwlKsuaIAgCAXFMHgctiCi3+mZLkchyk1ueXiAGDJPnTI55JMsR71mAnRq5ow9OJ8XYP GbylvMW0BYlYq/mByCLcUNy79WnCvx6okqO+H+TFLJSFbBoOBzj5JMlk6PkCBD5+aXi4Tr7UFJFQc iAFvKVkG4IFNY2nAIKqSLgpkVBt3EoFArDeXusHOrHTIM0YfpWbh4ONIQLEVbVmFSokbKhsjKn7kt F/SbMn8ypih3sR5uFNtw==; 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 1fmimy-0000F2-UY; Mon, 06 Aug 2018 16:55:24 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmiZK-0007X8-Dt for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2018 16:41:21 +0000 Received: by mail-wr1-x442.google.com with SMTP id h9-v6so13013324wro.3 for ; Mon, 06 Aug 2018 09:41:08 -0700 (PDT) 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=qyIb1LedubX4Bm4tOfTQFFJt+XM5l2v/UMtetdGR0wA=; b=SJkaC5hITo4nP+vXjYHN2mVUXmdrwLIHbNc8CpZmyoVvw3V7GtCN1wz4N7Al1vQJcF hd2hQ2Dda2FOZFaB3fi4YONbr7FkxJE0+zV6mYo8QkXkiP+cwOm4HdDWfXUKGfXTgQlN Q8wwiuZ3k//FGLrWLP4x7doPn4M/2AOprO2n9lsdrV3GL2iuZY36GdqROtoI4m5Lg5QZ FAAmEmPnQxfd5XtkyfuMIGdZRRZ9O3+CyxV3b1xZlSjyfDnCfuNe+F9+7eELSrWmRhH9 ogwsvNzG8jsKFD9+W2+dNbTKYfDwtsP7DnjDyEzq/aPqETSO9v2jfp/3lWSRQXXa9tjz rjcw== 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=qyIb1LedubX4Bm4tOfTQFFJt+XM5l2v/UMtetdGR0wA=; b=ZVtMN4gZZU7eT4z5Z78+/+fz/FPVtVd5kM9JF+FxhacIDeRX9Wn6UqcC8zPd4RrgaA b93hNlrWbeEZDlSePsj+Vv2gpLvKc4fcpWV2c0Bzpdq0w8aJLC1Y5toXCC5XVb/nwDqN pVpnzya9B/RXp/AjQZY1NaPK/VHAeMCDnSxbqaxZ1VvN5z3MGCvNiWc6z8a0d/YxuYmO P2r6dUzO5Y/cAsmueRKqvH1WwcddV5nEEWQ/q4cMlEj6PjZ5oV3qdQ0kCtkllWi6AinP PokfcjbL209DqER+XjLQLe3xYThAfM/lgZe9TGAMNkQBut+1V8UtLDBwspPsWBo8kKGj 3c3Q== X-Gm-Message-State: AOUpUlEoO/iHRczmL4Z75DTwmrsA7fKwiJ1debpcDVscotMsqDpEdt6o UUvj+7GndLtSBf4G7ogYns9AHQ== X-Google-Smtp-Source: AAOMgpeO7k6j2TtDLWY/G7617DSwScmheLW9n+G6mjNCfjUdKJdVUj28MA6JiNxNbo41h0Nsk3UX4g== X-Received: by 2002:a5d:50cd:: with SMTP id f13-v6mr10733476wrt.73.1533573666455; Mon, 06 Aug 2018 09:41:06 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 66-v6sm16385790wmw.34.2018.08.06.09.41.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 09:41:05 -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 Subject: [PATCH v5 09/10] arm64: update Documentation/arm64/tagged-pointers.txt Date: Mon, 6 Aug 2018 18:40:44 +0200 Message-Id: <5396af31a51aaafd5d65742d1cc48854513be778.1533573460.git.andreyknvl@google.com> X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-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-20180806_094118_592023_E86469D0 X-CRM114-Status: GOOD ( 14.63 ) 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 , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , 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 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 Mon Aug 6 16:40:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10557453 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 1C4A715A6 for ; Mon, 6 Aug 2018 16:42:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09A6E29765 for ; Mon, 6 Aug 2018 16:42:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F08FD29790; Mon, 6 Aug 2018 16:42:21 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI 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 8FFB429765 for ; Mon, 6 Aug 2018 16:42:21 +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=bxdIXMw9dlOfrtm54tW8zC1+Rw6AjbSjLkzQE+26C7A=; b=Sf8IaOLqdIglIw FCT0j1o2Q/2mFkg9ORRg2A98BcNiq3povb6UeQXJn19D4UBwdg+DzJQPdJa5F7iVAEE6cIri+ZWr1 0oYfhsfteoP95NM3tSCXe5yXWduaNcLGaZjVmkZfWO1AtdF3HSNAAXMtXDBRNSveFi/cZJH5453gs VXnfFrPq6Ku2JFW1cCUqyJTUoW702qqAg/nxpAKANx8TRhQhrfnDV32PrKj8dQwssP3fqhpTIQhqv AfdIjvHbg4eBJr5yf1nSWriup7ACF5SYyQd/ktm1mVOGxUnx5ShLzQOerfIQ/iZeiuuCqTxQnOeOZ wnAz/hnEmhW2cgeA5FBw==; 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 1fmiaF-0000Zp-6X; Mon, 06 Aug 2018 16:42:15 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmiZC-0007Yl-09 for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2018 16:41:15 +0000 Received: by mail-wm0-x244.google.com with SMTP id t25-v6so14971602wmi.3 for ; Mon, 06 Aug 2018 09:41:09 -0700 (PDT) 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=ZrhxEh1LXKnM2IrXVIXbI5DKlDD8oKDUSL0rMpxw/qU=; b=Ro3MVatE7Wpum1+4Kk+2wXZyHXWGz5DhEhdhzVDpd6n/5zWbox/Ku85U5aRyxxnzQJ 1J/xWvRyFAc03TrVnYRNw8OmHId2EwNePrTxpSWu1Ofv1SyERhzredl8WNaZAOK9NUox kdSLR0PzMNwDcdf8IDNrR/K6Rn2/Oq2YV3/c4uct4BnX14eyZ8BAMtfJTUrExgVGB4/D CVBWJPc3EidgI39apO4xklbv+Fl96U1MRR2IF/FLrVGIUHoTHo8+XdeER10wgCNAs+pz Ume8Ot7SFSHyWHNqaSQSC14cH5byqzRoQ0+VYrRQwYDbd2MRQJguQiz5Xk4ALJ4R63mL Zn3w== 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=ZrhxEh1LXKnM2IrXVIXbI5DKlDD8oKDUSL0rMpxw/qU=; b=F0maCessT67eMk8Lc6rwPBH6caoxdYN2UQIVB+w4nDmZ/7/FZvudt2birnRSFmJkXg JS2fe+pZOv+f475ECTBnjcM5yf4z5kFS8ENwkcOroi4nKBDIocYYFfy+09j0YCzVBcaV nyogGsL3muri0jMST2Om7CN37zKG1YfAaFaGIy8/IV2r4+2ZprMScWKsADcGGo7cYWja ghZN6/zSSnU7XuPE1zEmwuEKeT5tj827KRiT9OOU66RJZvIEECOCGYpDV0m51Kanbe7C 86B/KZmCe96FEa9Q0j7kN4Hyi3NSlrH4jDZHn6bz0Afl5WfOXDeNQYqzVRi7tnvOq/hS pjRA== X-Gm-Message-State: AOUpUlHtZayeWpAj247wtQaBu1BbXveAvZsvZnWNPyXruvQtyFJNeueu ELeLlLsJnfZp8Qq42rD0uZHDIA== X-Google-Smtp-Source: AAOMgpcDi4MsvNpmW3WExVMPVjcfyNYV436aYUrVpmhZEgiIKgBhHcCGOm+96ozBcTKn96ws7pU/kw== X-Received: by 2002:a1c:8010:: with SMTP id b16-v6mr12985397wmd.9.1533573668058; Mon, 06 Aug 2018 09:41:08 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 66-v6sm16385790wmw.34.2018.08.06.09.41.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 09:41:07 -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 Subject: [PATCH v5 10/10] selftests, arm64: add a selftest for passing tagged pointers to kernel Date: Mon, 6 Aug 2018 18:40:45 +0200 Message-Id: <44c929e1128adfa5e84ed7db832d2b34edc55f19.1533573460.git.andreyknvl@google.com> X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-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-20180806_094110_192917_7AA34DFB X-CRM114-Status: GOOD ( 15.89 ) 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 , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , 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; +}