From patchwork Fri May 25 17:21: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: 10428169 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E42B3602D6 for ; Fri, 25 May 2018 18:05:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0AA029751 for ; Fri, 25 May 2018 18:05:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D40962976C; Fri, 25 May 2018 18:05:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 2024F29751 for ; Fri, 25 May 2018 18:05:38 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=9XQLWhakfJvtRoDh7BuQK3hdoYGCns+f3HHF1vCHXew=; b=JcomRq35+n6obG0H93IPMjgPGH 7FuPnFt7O1sRoL3OvwUnYQcV+oeibFtcLTSILvdCUcBGKxFKXN+J9mEsdl4X33qo3bfqk7s26nY24 DBc0P0hDzuOZ5bF23M9lFcJUQjSjP69QpPh4scdjB60aAvkzC50yLk9uQTZEhyEmnQmSFSpqWojVA MWtOS+6CuMq2m9BkJ4R6D5Kyt4KhY/YZ/Cm4NhlCrrfLgnptEx3xzsgCw6E8yUG0CLlP+woX54ega Wj7eCRMBLgUAld/sOTU5rSx0661i0sO/CIgmPCBgXpCNT3+yBh1IHXDaLTCVI52BMYUpgejwDBQPW YsXkfbrw==; 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 1fMH5i-0000xp-OM; Fri, 25 May 2018 18:05:26 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fMH5g-0000WP-Ti for linux-arm-kernel@bombadil.infradead.org; Fri, 25 May 2018 18:05:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=yZP0biNYmIhGSM1a5h0e7cWrGAjsco28ACLkrXaSiyQ=; b=ibtiuVYu+SXZKsKoSvmFGewB7 IKqxl/YmsRh1yrvt3GZaozvplWkATuqoxev3TzH4w4Q7be5SP+JmlIvHCLtlD3txUbM7MuBn9p0IS Y9Yyp23+y1jj2EfRmdFMYn2MRIMJ+V/MeMbiwz+59P2x6TwigyugN09gWbmrE0e5kDS5KNBRKtREc kGkQLLCzX1Zhu2BnqdEcI77hNqHHzrAUNn352H7GI/VezNWUmRCaC8tPRLyqGm83j9Z3L45ZtUnir Ps9vrCXYEHzdwSZ2KEOL5GU5Wi2YhwyImxxU3GNXvSujLLHGoctz4loEiSM/gpqzkSfHr6DaPsH/f Ni/9N9REg==; Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fMGPI-0006LR-0G for linux-arm-kernel@lists.infradead.org; Fri, 25 May 2018 17:21:36 +0000 Received: by mail-wr0-x243.google.com with SMTP id w3-v6so10426939wrl.12 for ; Fri, 25 May 2018 10:21:28 -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; bh=yZP0biNYmIhGSM1a5h0e7cWrGAjsco28ACLkrXaSiyQ=; b=RIIFfTCzVWK7Zyh0oktok2JvdAghpLR7bMVgP0HLy5S/3rf973xF/QTZa9wQ4nx3aj B5/8Y3jnetkBcUAgzBdFNU7x8AlCBRL5YeJL6/vIOhrkUu5zU+miM0wPnwG0CTLVG34S DrbvkfdwjwE+iAOEk+pfOwiOfr4Mm7Bb//gGhAdNO3yIWPXCg5X3/q+qK3YPna2B/Q9E WmI81zGTsyiusSTsdc91LKPHkWW84UJVnPhxqK4NndtlCScLQh5dI8k9ttH2NhCU3UGa YG9XimfWqivTL31V3XR9qvQ/7wtb69FdJPXsx3bXqikWT3afPL7ohHdfusqP0jARtB7Y x8cA== 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; bh=yZP0biNYmIhGSM1a5h0e7cWrGAjsco28ACLkrXaSiyQ=; b=PgkV7+hihDA/Fti4i37TIuO/CKa1RmeBH0PXU747oMv0vXc4DDWQUwixljRLsF0eFO d4xDu4uNJNy7Js4FDq48uISl3OlO8hV30VV3KlJUjDazUJOz1MPdzrwtnXgWjbNPI9Gi G+sPGjcHPjwd1oOZIuav9F3apKqra1gdMbtnfZSeVf2n2mBZfGK6oSitz4nn4wu0Gxk9 9/HySRJ9au9lKX+o9qJLVhAKAQWq1ofl4pAHevrAci6LHfEe20b7GEP7aemKVdNnKQCE V0XLuNB4U3RyKwWqr5JRMT9KMTiRaKE0iFdxhBSam2gxQi4gt66NnncQD01uFpOLgCrW sCZg== X-Gm-Message-State: ALKqPwe7I9jOnOHe/We12O7bHM3qX3PR8PgQHpGfTJ2Sj9c+5Iv3u8Fk 1WklRIL8ZfM96r0RsmOu1HQ9Dg== X-Google-Smtp-Source: AB8JxZrWLPpHy6ArAulKgNALwWbIej1CZbxkjhsfiuGM4htKA2cPxuSLOdhOSxZxVMdS8vws4FCybA== X-Received: by 2002:adf:8756:: with SMTP id 22-v6mr2654907wrz.117.1527268886845; Fri, 25 May 2018 10:21:26 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id s5-v6sm26579964wra.48.2018.05.25.10.21.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 May 2018 10:21:26 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 5/6] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Fri, 25 May 2018 19:21:15 +0200 Message-Id: <011bbed9ae9404e2f8939e2bcda459387038089f.1527268727.git.andreyknvl@google.com> X-Mailer: git-send-email 2.17.0.921.gf22659ad46-goog In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180525_132136_091741_9E7A9C2C X-CRM114-Status: GOOD ( 14.90 ) 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 MIME-Version: 1.0 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)) {