From patchwork Thu Nov 8 14:36:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10674395 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 C42E714E2 for ; Thu, 8 Nov 2018 14:37:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B10EC2A548 for ; Thu, 8 Nov 2018 14:37:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A437C2ABD8; Thu, 8 Nov 2018 14:37:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 4D2602A548 for ; Thu, 8 Nov 2018 14:37:28 +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=9HZUUFrVCFAGxkzQWIDxgd8vtgQlJjMKYXgCy1EaGx8=; b=JrojuWeIro9Mp3 xlaETP6gpSnhmvjUkWUz4BoAN7yDe1M4fwDnoEnKDZL5fp+M5rAon95LSUDDMiSI1CXVyeZ+8UhMN CnoCxxwusDqiioKUvnfW2QqwbaVT/SALhylSRXqv8vPC9i//X+Th5aD84RjZF0HNjiy3BjzWv2rr0 qfMjCMocg834Z53bfTPVuBJ17KS3B5PQIcRCNX1Y55dlJ1OERoJUlFzygEP9Z97IKP+QNbN+ypISb VEOI9S+P5TrDNku7hFihfLZwzpGtL8OmHMOYXFDMteGi24RGJ5Y8+CrUDAXrIkG37d+99g9oLFwIv BFmznx+8ZDuKCHRoSF/Q==; 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 1gKlQs-0007nk-KH; Thu, 08 Nov 2018 14:37:18 +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 1gKlQB-0006uT-Ic for linux-arm-kernel@lists.infradead.org; Thu, 08 Nov 2018 14:36:37 +0000 Received: by mail-wr1-x443.google.com with SMTP id y15-v6so21485322wru.9 for ; Thu, 08 Nov 2018 06:36:23 -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=CyHAJ7bm8yqliTwjL59/PERrC1/EJlU4Hst47qO5nm4=; b=hTQIa3cT8mQ6PRrw+ArPxNwUIt8G3xNjt0LPrCZ2+3MjH5B+tB03HhLfo9JtaDflG7 1WS5ukgZJKhb3Ft+7oWDzcuhvWXYYqx0oGvId1rHas5NYbuZlzgh+jsCM0J8W0xqrJa0 OhmkLb2QT3xrgFMUjfPkpf38HSHLQ5o2uSKcXbsGzJDAc1p3wW4syg78MncnKzkxdlQ2 jTset9xpCPu5advaWYtuw31DIxNZhkWjXoUPz18Ntq6yzfcR8/4GKmf2sUarr6Qq88IJ IhHrM2tjOxLBZ3p5PAc6ad18rgsGMiuDoHvHKgFHyyMONd2xM9xj5Hbiv/hkt+t/CGAx Vh+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CyHAJ7bm8yqliTwjL59/PERrC1/EJlU4Hst47qO5nm4=; b=EocF8620VuSzNXT1cjJUC4E0cpz+lEGqPO38qEcRdN6OGRzkcz9aVSyDo2gzvV/BtS +WybeRqsR2bVu+URqmo/+DxpeMDGEtgkAurTlBaUXMm+Tzqgl/D2cMtdxV53hdd8W6Kz Dcqj6E4KzhDEZcJ+DJU10KihV7Jz5676iL10MVCVzZRKK7nay9xg4/tLSox3ic9yri8W EGxCZWnjQQfMBVZBHUYK79llbvabF6AowvjRM12rgeuj3b+EMuA+Bw1EMmvAKuRL6XUY PrNPI0Xpwu6AgzSGRlip7qybTO3vHYKO7K99OjB0a8diE/9fQbIYQCq2SLbpAUG6AflD hKeA== X-Gm-Message-State: AGRZ1gLJ844cyZAv1RUHFbcPNqX4kL29gO8dgsjt7f46g0lBg/CsVK7a +CL1SFXsFa+w97Rg7k1L8n1e+Q== X-Google-Smtp-Source: AJdET5d0FY6pZsoxQnT5NEn9m/O0HpttSzArfI8Y3zJIn/M/EFbpljwG8ooaFhLFbogzGGQcdQFN0w== X-Received: by 2002:adf:c752:: with SMTP id b18-v6mr4088793wrh.197.1541687781406; Thu, 08 Nov 2018 06:36:21 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id k5-v6sm5421068wre.82.2018.11.08.06.36.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 06:36: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 v8 1/8] arm64: add type casts to untagged_addr macro Date: Thu, 8 Nov 2018 15:36:08 +0100 Message-Id: <4a4063a3e074608b99cf22ab447fecc36d056251.1541687720.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-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-20181108_063635_609450_D8EC3E2D X-CRM114-Status: GOOD ( 14.39 ) 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__. Signed-off-by: Andrey Konovalov Acked-by: Catalin Marinas --- 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..c1325271e368 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 Thu Nov 8 14:36:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10674391 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 90B4D14E2 for ; Thu, 8 Nov 2018 14:37:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EBF226C9B for ; Thu, 8 Nov 2018 14:37:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7195628B1F; Thu, 8 Nov 2018 14:37:03 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 1B8302879C for ; Thu, 8 Nov 2018 14:37:03 +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=uAelzGcUxaUwqzOo5+DaRJC2leyroJiQ+qBiqkC9x7U=; b=cgHIU75RKE2iBT oq9VcSpV9YcYG2a6qKG13/wIuGsOArBr16XrDXK79zTqWBz3NWmvMBJ1DTrufGGsxKsXGmRWzcZJj L0cDLbrVAxpio3ql+2y2Uzhq7201hfn55AIzqX7N3JcTR6gFTapC4dKNfERnxJc6nADr8tzuVe+h5 6sF/RxGU78LvJMXTRy0myKHNAW2mO58ft4mNUkriuweXSjmTWnGiIRIem/mDhgrBnwDnezU5KiDNQ ig8PP/cxmNG1L+9zxXgb54RM9aLjs7K3BJf2ukXYLnh1ecVGLCpFP+I0xa19aMZvY9alDFdALU4a1 AsuBxGuWC5pEAXt7RGow==; 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 1gKlQR-0007FJ-Lp; Thu, 08 Nov 2018 14:36:51 +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 1gKlQB-0006uV-4c for linux-arm-kernel@lists.infradead.org; Thu, 08 Nov 2018 14:36:36 +0000 Received: by mail-wm1-x341.google.com with SMTP id u13-v6so1416837wmc.4 for ; Thu, 08 Nov 2018 06:36:24 -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=/pjzuvui9d85lC6ebp/JjM8l8T1XFTIxfHxdlRMSnSU=; b=g1wof77b/ahW159tl/OaMLW0P96a0/zVeZFYRh5g6v6wbToBXd28iFvOASCK8yKV5Y xHNqterZqD2KmkFcVcFGm+gkEQeG54Jf/H+takvz8wjdH3wdoMPjV1aR/aoFl8xbW+mR 3CDZOO7tD7iSEUdTMb+jOu+oyFpmUCbQR6pdxco9Vh1tL70iQ5jUycXJ0G3WmOgyULXv HP7R7bmaLmZ4EHXVI9J9sCIzpUalSy8bFlzRzUf2kwtLgyxlzPRWUrnL1K4XN9LUvolW Y96dsy0e/tD1Mz+ow6abkTbXTuAvzZ6CsMX4iIrftNJRgkfaRW/cIVRWqwbUc26iosdQ 6XAA== 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=/pjzuvui9d85lC6ebp/JjM8l8T1XFTIxfHxdlRMSnSU=; b=rAduS1HVVKiJEBq5m+1TZKsdOgE+nSOsQT2r+4dfcbSP5toou/9mIUgUlFFAkLB4/f WMOlHY+FwdrUJnzn6z+IWfbAWU7uoXpH+u79InNqvl1SeR9aoy6l4agK4ZOYJA6FMdeZ j26mhtsQGoW3vtPkGS6HNiHm/tlBrFEmQrhLEMMR3neLvqegdzwf5u9l4mlxYWWEju9H kVRj/8F55kTjMdPJJpGqpb4AvmW2HahDNw1XdFoDgPmTRhw2cUg0OWlpLdcTeqMPKlxk ProUOB5twEGI2GWwM9zIrx+2xo5dBZEDnA04k7RL/h/VwL442DRw4K3ChSdOHjGCfyGk 5cKA== X-Gm-Message-State: AGRZ1gJ/FM7yOT1cjRS9lSOEeAF/FViGhHW5pD0UHUJyeNaX52q8kHqQ 5itcLBAT1TIvjhKEex8/8v0xHw== X-Google-Smtp-Source: AJdET5fJjnrcqJrwZDIF+kL6S1eyNF+VEauTvj/4nlfwZhoIa13mwXNXonwu4vWqr6lN/+fSYDs+KQ== X-Received: by 2002:a1c:13d2:: with SMTP id 201-v6mr1411054wmt.58.1541687782962; Thu, 08 Nov 2018 06:36:22 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id k5-v6sm5421068wre.82.2018.11.08.06.36.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 06:36:22 -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 v8 2/8] uaccess: add untagged_addr definition for other arches Date: Thu, 8 Nov 2018 15:36:09 +0100 Message-Id: X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-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-20181108_063635_177143_3F527C8E 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 , 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. Signed-off-by: Andrey Konovalov Acked-by: Catalin Marinas --- include/linux/uaccess.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index efe79c1cdd47..c045b4eff95e 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -13,6 +13,10 @@ #include +#ifndef untagged_addr +#define untagged_addr(addr) addr +#endif + /* * Architectures should provide two primitives (raw_copy_{to,from}_user()) * and get rid of their private instances of copy_{to,from}_user() and From patchwork Thu Nov 8 14:36:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10674397 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 578D414E2 for ; Thu, 8 Nov 2018 14:37:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 464082A9FF for ; Thu, 8 Nov 2018 14:37:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AA452B0BB; Thu, 8 Nov 2018 14:37:43 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 D7CA52A9FF for ; Thu, 8 Nov 2018 14:37:42 +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=dFGhc5KxbFL9s0HoFSNtHWoyz+F05AmM7IGcPHieXqM=; b=thimKjn8MvfR+I ww5RtLNeofXuWbzPx5lVZwKEwaLsOenJTKtyENpHwThcsm33xF3b3awR3tMbMKQGBVdzwWmfgil6P cDSHjCEq28oLWSi7j8Wev0t0DFJDmKAx7H/aQL18xrhUkjk5269G+ejtBq/DGAk8nhQs748Tfonto ld0gvrS5i38WQl4qseOxPDiGWQdUvy89mFAghpsphkdemXg4APlEWr3Nor+i8PrWIqALMlQhzs5GZ VT/oAVducjAwC3wxOUgbmBEoQNsS0OYfW8rSLNBlodPrreBRH6oBI1RwEfbysjfSV73Yre9uVd4cA rskX63sLjQ5P4uHZIxfA==; 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 1gKlRC-00086l-AL; Thu, 08 Nov 2018 14:37:38 +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 1gKlQD-0006uZ-S8 for linux-arm-kernel@lists.infradead.org; Thu, 08 Nov 2018 14:36:39 +0000 Received: by mail-wr1-x444.google.com with SMTP id y15-v6so21485489wru.9 for ; Thu, 08 Nov 2018 06:36:27 -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=ZukT/dUNa0Ny3ny2vQGy46SLKrS4BO5zDkycm6cPI6U=; b=Gb16Vd2d0GXy5xJf7uLbCjmyiyGw/kcSiV09tZGqiQS4c5FjYJ3DtSN2p78sD5NL8J Yu3Tm1nBUr0JKb06DFlm/sg9OAiHkeadtA96DatQGcvTFe0X3Yz+4u38QKXuYLFWQO7r ZdZsPI9cYA8WnpK58iVCPR7x7p4ad7K+2zNIHukMlIO53UKw88ProRAPC5E38UFgnPMs 8hnZ2mwMMoRYlZguF9kBwPkQlLU++3vd4fcGsGzi7ZHuhrMejEt3cElmosvTCXG3RQvw z0RTxmozNtOBom8mwr04OoYOPb09mO9j0TiB1QnplSc3B0LSA5GOBmg8attUfsmiPLR9 tp+w== 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=ZukT/dUNa0Ny3ny2vQGy46SLKrS4BO5zDkycm6cPI6U=; b=c6Ur3wJGmeqWiLfboYdJazcZ37CrxJNLC85X4iz1OrxYFtnMquyoQQxCV4xpFpuME+ 2ou3AL1fjEixt4VqOIVryIwoe2QYrfg5nKV9UixVtEG5UdM6/LtzIL4YbbGDLtOFES0V KUpr+yBLKc4onqw0T0Y58DWoCgDwG2fEooW4lrmzmpjB3F0oN1v3uUUaScLE+Sp78YKN WXVnNtFmZkI9GFz7SDyId7eZCC4Q5Zqo8ZpGy3JIxvvSPlCucz0c5POssRIEjeWf1e8l dSJ9GkKVKq1ocUV2L5fZETgHrv3OgBan+MryHqzL/EcfyAAcDNv+xB918hcFPU3tWkVL rQ8g== X-Gm-Message-State: AGRZ1gJs5ucX2Afw1+oeOK4UJL5wGx97d3eKSZWZn7ZNyu/d6YoI+cpR 34Y+refOSZWXkqj00Fv5z/1ERA== X-Google-Smtp-Source: AJdET5fkqa1ke/P7dlhhjrTblVnNyY5imtamk9/f/3V2XeRRGv6evK6z/uB52BsyTEJj+iulX88T8Q== X-Received: by 2002:a5d:4b05:: with SMTP id v5-v6mr4238564wrq.5.1541687784492; Thu, 08 Nov 2018 06:36:24 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id k5-v6sm5421068wre.82.2018.11.08.06.36.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 06:36:23 -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 v8 3/8] arm64: untag user addresses in access_ok and __uaccess_mask_ptr Date: Thu, 8 Nov 2018 15:36:10 +0100 Message-Id: X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-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-20181108_063637_938172_D16447AC X-CRM114-Status: GOOD ( 14.34 ) 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. Signed-off-by: Andrey Konovalov Reviewed-by: Catalin Marinas --- 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 c1325271e368..abc35cba134b 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 Thu Nov 8 14:36:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10674401 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 97A3814E2 for ; Thu, 8 Nov 2018 14:38:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 840E32A505 for ; Thu, 8 Nov 2018 14:38:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 742D02A9FF; Thu, 8 Nov 2018 14:38: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=-3.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 2769A2A505 for ; Thu, 8 Nov 2018 14:38: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=hkck9rRWsAa1W/bz3c7AWX1SAeIOzMXNOyBqyv9eoaA=; b=qJ+XlD+SByq2z2 zw90QUh+fU2v29lJuqg5HhFyAAhQA33AyXZs74NF6+7JkrZ+XEXISkMxAkImiMZvpT5HCC3UJhq+n lMC3oc6zeoBEPacnUctY73Pj4tvEvDGoTeH9yzsrOB55qjSwHOMfbo0kU9W6SNkxtpWqzW8LTKqG/ leFcFLfPnPjZt7HBOhlAGgT4jsQZkRJS+5c0Lyu2cBniXMcF9Rw827p2BRzfPL1i665UIXIizDd1b c0/XnsAD8RzaGCSTivucYfg/3dtKjBd4h3MAf8rSvCicRGNPSQtDjVExUuiAQT8EezdG2GYFU1Phu DhIQ7mhd0JMwJk4wRbZg==; 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 1gKlRo-0000Da-Vw; Thu, 08 Nov 2018 14:38:17 +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 1gKlQE-0006ul-Bn for linux-arm-kernel@lists.infradead.org; Thu, 08 Nov 2018 14:36:40 +0000 Received: by mail-wm1-x344.google.com with SMTP id r11-v6so1495091wmb.2 for ; Thu, 08 Nov 2018 06:36:27 -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=XFiY84rm4WtGUkeGnRX1ezxk6XhL8yE5HslON+43E5A=; b=oI+aXnMV67bGaMcJR9iVpv8//10td45km8L6aUAt2U7BKqk1YcqEFnL2kiwXI60GJo SZ/CWqH8TK1BouvBvRRzyXbwgS+WPi1NX50zFJ4aZOaLhWwHownP5SyGqmZyTvxteJal x0mda4AQkeS6YISyxX7xYqbJJdlvjtQRCohgvGk8JBce2yGqrCNVYfUUXDV/xs8CBuM0 1kAPsLjjZHDD9GoxuZyOgQVVPU9Vq8pVh34mVeWeNrhpoiskyIgvnUHpn6CnYXhNB8Gf fc13RpNIM2IDnaeH5D7Twtt/fOx+AjFtdmrj8a5LSxCAkD4uliwAac75+fL+PZR7qTT3 3SOA== 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=XFiY84rm4WtGUkeGnRX1ezxk6XhL8yE5HslON+43E5A=; b=fgbrZUVNcShAZlT0lh0GyXp5B/sJAnRAyf1jG1JAhMUOg7DtcLwyPQSFfpM9zz0N+9 9xhOzv0R+o90nS1TKd3vWxSQs163aJbStUe6dTsf6DW2JB6RDW/y8E7HyQx/AR32mP/d hiCE9ayomLu2I1qdaE07u6XbGcWI9YSS2E4esuMln/OsZHqeuiRRsnQoFemw4pX5nyu3 WK/cJZxHqQ+PXdh7YHPJ47MmXytvK2G0SIdcREJPhh6406TgG65dkgOxBUpgisgPPoWK Qc7SOdahf6gfZNBWNjouIG3mzYi8YGzKOz2NUkx7qRn9guWqz6VfTdXP7umFDzMm/JNX QG6A== X-Gm-Message-State: AGRZ1gIPF+cUOVwy+kAFqeBJSiXD2CqoCEr7yC5EjsMWW4dArQxu0Jcv OeVAdpoZ0FFv9/us06ha4eZH9g== X-Google-Smtp-Source: AJdET5fLJZXRAYzbTbJsD9GsxFNMuZQD5qXtXF3tsrt1pqTH3zYu3HOOugbRpVAPkx1jngHW7yqCPg== X-Received: by 2002:a1c:e40b:: with SMTP id b11-v6mr1500427wmh.100.1541687786099; Thu, 08 Nov 2018 06:36:26 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id k5-v6sm5421068wre.82.2018.11.08.06.36.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 06:36:25 -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 v8 4/8] mm, arm64: untag user addresses in mm/gup.c Date: Thu, 8 Nov 2018 15:36:11 +0100 Message-Id: X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-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-20181108_063638_429172_59C4496F X-CRM114-Status: GOOD ( 13.30 ) 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 f76e77a2d34b..6ff310818616 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -677,6 +677,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)); /* @@ -840,6 +842,8 @@ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm, struct vm_area_struct *vma; vm_fault_t ret, major = 0; + address = untagged_addr(address); + if (unlocked) fault_flags |= FAULT_FLAG_ALLOW_RETRY; From patchwork Thu Nov 8 14:36:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10674393 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 A31DC109C for ; Thu, 8 Nov 2018 14:37:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91C4B26C9B for ; Thu, 8 Nov 2018 14:37:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84B352A927; Thu, 8 Nov 2018 14:37:08 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 340EE26C9B for ; Thu, 8 Nov 2018 14:37:08 +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=kbE257OvODvJJMb9G/O0KRVB+IMQcfe0f6ZcHQG5D1Y=; b=MBs+rTyeo4p3jw oV7lngawO3q2Uf9aV5iSpvkj4TxqcCkFfpDF96K6lkqr9Wbobh7kGW9YzLxzmU/ATmvdySD702x6N yl80RjjX7qkWnODjksMAM2XblXXB5d+gfmpPeg8wO5ttwSOh1aFlyI5TNeH9COuhcEAVWiD3bjPz8 I7f9wBkolScOT8SC7FzR4jRwlfbWofIEgOZskUFwbhIVCrjrkz6yeFOMv9lMcqKDDvIf3PXUxCH03 EmICMox1zM5lVYlnH0cUGw6rdwe7waWsX8Z0+Sth8MYx5oLVic8Ctwf8dyNy3LBQOZ7mGxdVpf6Rw DXQr3sFuf4t+UfUQ7KQw==; 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 1gKlQg-0007Xr-HA; Thu, 08 Nov 2018 14:37:06 +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 1gKlQB-0006vP-4a for linux-arm-kernel@lists.infradead.org; Thu, 08 Nov 2018 14:36:37 +0000 Received: by mail-wm1-x341.google.com with SMTP id f10-v6so1489042wme.3 for ; Thu, 08 Nov 2018 06:36:29 -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=pCI3XzgNVAltAQe0ygEc6WjcTSNZu+vDSueRg2rkboA=; b=UP+XhJbt7rG/bdEpw8fc31VRF5aLTB6BTp86/sKBPDdvzf+3rKxrZx+R4xkXmuYNk4 Z2kSoGRZtY2xgb0cZLZ8nqWLECPTlNaPdP21J5ZftO9/AJWV27UNRA3MqMVTh/5VBt86 OR25TGd6GfMgbPUcVLtTp1LdrRAy+ildKK5CGWBA4J0gfpCpY2qo+ocTQb4EWphPlU6Q auFXwXntmIyQWzfLokABGdc0KwvDYW58Q+kRcY3/53A5RFB2TyvvkOfcZPB/L/44UZEC 8kDE/Ckdr3nMddglr5ecwDqcjOXtIhIheYGjYA9pJ/KdMyecy+Hsgg9Tkw2BDFQ1m7aq kRKA== 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=pCI3XzgNVAltAQe0ygEc6WjcTSNZu+vDSueRg2rkboA=; b=ov5yCR8ugbsPjURQJ5l2G3v29P7rw3UNIfrkmIbFKZIRCNabKuPMnqapXYzGywSA1I etwANEsk+R7aIjCzy+qfUdiLDr1/awFo7wtENAw1sEE8nNliu0QDTzz5yF8PhGKIB8v2 5LtvqJHWvLsWMcNu8ZN5zB7fprPltHOWOPfnGnkkWEQ2ImBlaQQpLBYjxDVcL8+3ES6s r60qEP7lBgIDKqmmeMBAR/AokujmpxADLkdgVPJcloqUB86Jd/Wiis9QBhRFhJdr9W0e sIaeLqj/GjQqedxCF9NkVod4zWSCrEOcJtEB6CIesisDfebRjkRs0K2c7yUgjdEiIA/J /aoA== X-Gm-Message-State: AGRZ1gIgFi28ZlbglNHyOWuts5ffH6wJV1k75SqjIuTCKEg9Ng9zzEy/ lhiJsDEXXhmfzDrzHfQqVnMStw== X-Google-Smtp-Source: AJdET5c+OpdgjUiZO9kVFnzi+iLq8I4Ia27Tsi9lTwsCI5F43MyC9kiQR9b4hA1qM6mueQyUfoxirQ== X-Received: by 2002:a1c:154a:: with SMTP id 71-v6mr1368940wmv.83.1541687787548; Thu, 08 Nov 2018 06:36:27 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id k5-v6sm5421068wre.82.2018.11.08.06.36.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 06:36:26 -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 v8 5/8] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Thu, 8 Nov 2018 15:36:12 +0100 Message-Id: <4969eac81732e555ca1ec102c12eb1e29c82ed29.1541687720.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-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-20181108_063635_178031_C90ECC92 X-CRM114-Status: GOOD ( 12.94 ) 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 Thu Nov 8 14:36:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10674403 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 0F136109C for ; Thu, 8 Nov 2018 14:38:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F17C72893B for ; Thu, 8 Nov 2018 14:38:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E48D62D8A1; Thu, 8 Nov 2018 14:38:44 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 95BAB2893B for ; Thu, 8 Nov 2018 14:38:44 +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=282bZm2xx6snUMlFrR+E+cZetEkt8KMWbHZyUzdZnEI=; b=VRdcK3iXSPtNoz x4y5HKoDb03RC9kQSOT61kqp+ymiRxOI/UQBT/Wwkt6kmIGeTPkpOcXo5j3ULkzi6x/lbSJJUhDY/ a1bgZS9BCXPvNOvwzCzwB8tcTnDlEF8NekzPGfyRfihmqL2j3sOJKaAxjic6yt11wLVZYL53uDlQ7 cEJQCcKYUNBrhKFT6a3/7WhkuQ3ITHMuVK0pPSyv2OBDS1awrK/XlHIJqI309AMFQ8XUyQsP3iC9U N8TLv2KyhttrqxssRekpYvEXnq6+toEhK8jcCdKtk+WinZH2q6/uVSanHXYkTH+yDf5Bw916yUtJU tToHYF1diryXkF/arZbA==; 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 1gKlSD-0000fk-OK; Thu, 08 Nov 2018 14:38:41 +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 1gKlQH-0006vX-Oq for linux-arm-kernel@lists.infradead.org; Thu, 08 Nov 2018 14:36:43 +0000 Received: by mail-wr1-x441.google.com with SMTP id i17-v6so21504597wre.7 for ; Thu, 08 Nov 2018 06:36:31 -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=yMfnGtGqvRCyrqlswY+Q1yEYdnjSJs7L5yVY6s2C8lo=; b=OSTpJoAOkRI0ha5rclaP8H3RmP+9ftj4eIBMetkNB1rSZYKkx6QyMUtvsfT1I3Kbsi nqq49Yy9O0XIeGCBlu0DPUC39BhChXKHgATeWUk2Fi3gh0t1QL8BYV6K4jiy3T2i6GNH VRkY3HLu0OXnhKnVS6lf3PrTZZrby7lQuqhxR85J0t5SJLDHDokRqms7hvRLEo0fiOk5 qXqzsjE//9TlVAWpqziY4CaFF5r83iPytuR7OvbTtP/y28wAZdWtDZB4Xu6aS0GvYmpk /IynZxRnIUJET/vhUgCb7aqU51FOWJpPnAr9pJIHVMZ/tONQTR1EhR7OVdPJRK9CIslK 04FQ== 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=yMfnGtGqvRCyrqlswY+Q1yEYdnjSJs7L5yVY6s2C8lo=; b=KyktTNooHuEQ0j+bS1fFPTt1YYLf3BT6d68vQvfzVS+cK7VE61NDb2wRwn7VgKruE/ 8eB+Bfmk+Fs+UKg5b60Ytja0JHfAM92qngNLiaDxLnj73GhzgLwzi34L7uBU4CUr5VXM wbqn8b9CcXH8gchGQCYgNjc+lNj5BC3/UpUIDp7jArM0dXLMCUugeHN5YYKEnJxrtOz6 sFtEesrH5/Rcp88XBuGe+bmQyMMUtZJ8xPylsopG97Mnj7myCcdzbb9bOLOfKbX3/2FD Yu12UgWKWLlGR2u8tLPuPvMYZlmzAWBA+BJL7il2RZQZj2OFKjqHK3wl4iUqAQWjeFXM Sj3Q== X-Gm-Message-State: AGRZ1gKVIgOnIUPMT7Smti6CKuKBNCuBLth3bZobjYsVyEgOtjiuzsff XTiuHGJviHv8/a9z/v5fygZckg== X-Google-Smtp-Source: AJdET5eI6mep1KozRP67zq2F57bYi00Ufy/TNGQH9gCb351dH5ClKuaGSs0MjfRiBrsX95XmOTVJkQ== X-Received: by 2002:adf:f382:: with SMTP id m2-v6mr4327147wro.111.1541687789216; Thu, 08 Nov 2018 06:36:29 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id k5-v6sm5421068wre.82.2018.11.08.06.36.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 06:36:28 -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 v8 6/8] fs, arm64: untag user address in copy_mount_options Date: Thu, 8 Nov 2018 15:36:13 +0100 Message-Id: <12fc6c9e4896b394800776c54b16b26e2003a9df.1541687720.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-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-20181108_063641_928644_B0AB5433 X-CRM114-Status: GOOD ( 17.10 ) 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 98d27da43304..1f1f998d15ed 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2674,7 +2674,7 @@ void *copy_mount_options(const void __user * data) * the remainder of the page. */ /* copy_from_user cannot cross TASK_SIZE ! */ - size = TASK_SIZE - (unsigned long)data; + size = TASK_SIZE - (unsigned long)untagged_addr(data); if (size > PAGE_SIZE) size = PAGE_SIZE; From patchwork Thu Nov 8 14:36:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10674399 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 EEC7E14E2 for ; Thu, 8 Nov 2018 14:38:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB3C12A927 for ; Thu, 8 Nov 2018 14:38:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF0342ABD8; Thu, 8 Nov 2018 14:38: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=-3.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 4F30B2A927 for ; Thu, 8 Nov 2018 14:38:00 +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=qWlgNvejnLU0PIbD2ptE4m3MSDHp2R7myan+fw0Hth8=; b=DkWlmp/SzTOQdc EGeYcT2HJ4AzUtVjdeE3XJYHWiMHVYtB6bUTWDLKi2VNAB5sK5T6OPOY9jDaEIcFy1DbMAa+rYZj7 yCiCXsuMaCrGw+DwF8+T2aRQbf1U8xvLNIsW8YFbfzKad4rFjM39WfOtff8/qtg0leuJLCYvMfaxd vRT3EOfvoeIQeZqX8P+rx9hYCPoD1ww7rNrK7JC/4PQnX+hJCH9JviRrnJXtiJvfOmTMnIxX1Dk86 GwTsp2Rtb7jom2E4EggGgmhYDra6Kx61lKlQpVcdWn/nIAbJedxO+L573Yc36IIWwIZh6SmZxCzon Yr8eMhBGPW4bRGBZW6CA==; 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 1gKlRW-0008Og-5c; Thu, 08 Nov 2018 14:37:58 +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 1gKlQD-0006w3-RZ for linux-arm-kernel@lists.infradead.org; Thu, 08 Nov 2018 14:36:39 +0000 Received: by mail-wr1-x444.google.com with SMTP id k15-v6so18518327wre.12 for ; Thu, 08 Nov 2018 06:36:32 -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=AfT6+8vP45oXrV17rGSZ9pzYS0my+RLSPjgVa2gqAd4=; b=UXht8r8Y+LVp07kCtfXSBeRBhpCaVOvYm1P+l9gMKK/QSvkAY4eFI/F/7dNdhFa+6s 03WsHwOPySnNl0C8RLlGZrgGNvf5upI9wpT2QD8fZu8QPcUo14dOOKGhsT3Vt3N2Xsfz jNCbI1daeAMYzEOF5k+/52Kcgvpjbbd1ZJorRlAFSppDB08ydUZoSHLoh0bXliV119yC tyWxnr6yN/1x8ngIwCnTTq6z3enqkxHT7u0Gob0KyEf1crq1MQb3JzblYwR/nihHzcHC ZK14++eId0uzOYOuwdG4frYt1cxu7q2wA7WvAPLwPwotre1YMk4rWNPG7CM0tgU1zuH6 v3bg== 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=AfT6+8vP45oXrV17rGSZ9pzYS0my+RLSPjgVa2gqAd4=; b=jy5bDMTv7/O+JEeadFZggnWyuKy7X4HylYaC60BPs5yWXQBCxIgt60fpeaza20UPwK O40zqFP2vBjacSF61I8zzr3riVKtuVmc8i6m914j7lpDSZrgjIHAOFeA+MuB8fCgxoxr vP1mVAUCE06OH+sTjIgXubNCgP4EoojBygf10NOxMgA8OJK+qinWomqNKmLN1Z3ro+Ed pEQ+8YKSvR3s9kwqevYI8CqBd+CkwtVMxcVEmesMpmH1ajSphdAk1xlBBCiRGAS1z3Lm UagfQ6OxOfXKWYqMCPSXUaENvQ0c6O4RrM3YIaFQIFQyxUCoB3J/UvlZDBowJ1REIbeN /u+g== X-Gm-Message-State: AGRZ1gKKWcUuiUcjdimwO+dkBQQK7iP6N+U5fRey61WWNQya+O7KHUuC aDL+Rkq7Q9vQw0vqeLKv7mqaYw== X-Google-Smtp-Source: AJdET5cd+Vxy+CiHtQ9mm6FtFF35wdB6lNLfr2BV8z1ME65fDt3kZ6JEKazzaGEHLM0pA02L2pbaZA== X-Received: by 2002:a05:6000:1182:: with SMTP id g2mr4510493wrx.310.1541687790933; Thu, 08 Nov 2018 06:36:30 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id k5-v6sm5421068wre.82.2018.11.08.06.36.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 06:36:30 -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 v8 7/8] arm64: update Documentation/arm64/tagged-pointers.txt Date: Thu, 8 Nov 2018 15:36:14 +0100 Message-Id: <8526edb07fd5a762847306bba89fbadbb19210b7.1541687720.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-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-20181108_063637_966984_62FC3E17 X-CRM114-Status: GOOD ( 14.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 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 Thu Nov 8 14:36:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10674405 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 2896E14E2 for ; Thu, 8 Nov 2018 14:39:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15FC82DCE0 for ; Thu, 8 Nov 2018 14:39:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08B6A2DCED; Thu, 8 Nov 2018 14:39:12 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 ABC522DCE0 for ; Thu, 8 Nov 2018 14:39:11 +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=xwDXTROGBwgkBsP8wWWbaL4wDePqwS3Al8GK6w1S13M=; b=ZQQD5FpAfqGOTO E2QLJjBqwW1oNPdhIbjDcIE1O4yd7Ahze4rm7wvEJz5/kPmIFvN/r6Pzwh1jnx9eQiNmQuF5pYz+f youjvtGBjyZEPWKSiSy0yvXThSZNLOyaBgvJxuHHyxkflfkCCODZ0CJktouV4tRVB4CKRIM4JEoEr rbvrkrJ1bYBzQsxsZjuIqs/SZb/qGccDn1p5pAnr1pZy8+IJWXm6aFObf5l1FRJDAcb7Cu58lXNt4 3stc33i08fLEZRxdAyjyqd+brEw5ru49HT4p/4rsMhju4acq7mU3mDPPozF/apKzu6G3Dyb6f9Lz2 B7POL+RLJNyqaTOiNVpA==; 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 1gKlSX-0000w6-4u; Thu, 08 Nov 2018 14:39:01 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKlQK-0006wJ-9W for linux-arm-kernel@lists.infradead.org; Thu, 08 Nov 2018 14:36:46 +0000 Received: by mail-wm1-x343.google.com with SMTP id w7-v6so1496471wmc.1 for ; Thu, 08 Nov 2018 06:36:33 -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=rTcNvHgzBcnv8yHP5cVBE2DYrsiz3ttqK4qPmsK+xBo=; b=mP7BwUREcnEcGSgnJc1TDgXr13K42B6BP4F15hPXDeIHuQX2uOp8Snkbsq/rDAlE8d GSxzbR40FboXXdUWHFzDhkyUPKNmYpTbYubEcgFD0CeD80LjOR+XkyuSoGS0VJJv/LH/ U6bwKzwuc24ye0v6iPDL7C1rJ5l8CkubR7mup/yvtsiMkdMISH/cH5hOvczkzzBlrJ0p 6t1bLiFLEwT4ih2n9wtnExO7TRHpeETynQbzZK9MPILt2vlGyetQLGs6FdHqDdSjfj09 3QppCswB2VwG1hTqjfpGg82D4sfV1zFc5WOav3Zmp21ggvvVuSxtI+UVd6rkaY7vKPH0 +Gog== 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=rTcNvHgzBcnv8yHP5cVBE2DYrsiz3ttqK4qPmsK+xBo=; b=uXcwbZfWZPukm+60LsHbujKnVqPENlwXxrBY0D/2hXd4CrtDbPcw3i5A8QlyfrMbk3 tEsnynQlCg5BP9e5usqnnJbIWk4YXbJONhJwnWShh2whLDpk13COXEn0QKdolPzDylvW lHEL1pnmdfAVwOn5Bp46N7pecLXD4+0IpG2melElhFve+xZ4lvhDagFAaI9tBk0jESR0 LwKVtEZQbwxDH3tebHwUWOjy269uMPP3XMftDK9Zha2qDzCT8q7aczjBcrvxIHOCI1GA E4F4ZJAHKXq1prCdP1xez85ZnYX9FrWgJp2k1845UCEFfketpBqA1ie8LoSGzwSU7dII MCGw== X-Gm-Message-State: AGRZ1gJE7WqMZlSRqZ13+4bvxN8XeIYL2mrf55nUS2g6INxeQ+BtDqnx 8H2LQM65dnCS0w4XcMZl4iovVw== X-Google-Smtp-Source: AJdET5etM7uj3EUTtVycpWGYsbTyj7fUXc6thqPRDiCt2FdD9fuqZ1p8f/aw/QlkU3PTYPTHJhfbWQ== X-Received: by 2002:a7b:c0cc:: with SMTP id s12-v6mr1514540wmh.39.1541687792444; Thu, 08 Nov 2018 06:36:32 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id k5-v6sm5421068wre.82.2018.11.08.06.36.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 06:36:31 -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 v8 8/8] selftests, arm64: add a selftest for passing tagged pointers to kernel Date: Thu, 8 Nov 2018 15:36:15 +0100 Message-Id: <08e86fb73c3f0aeb60888939e34b0c0fa69063b5.1541687720.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-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-20181108_063644_456448_BDC9C60C X-CRM114-Status: GOOD ( 16.60 ) 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; +}