From patchwork Fri Mar 9 14:02:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 883648 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CQSk7agV"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="BmeAclrR"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="n28I0cW2"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zyTby509kz9scN for ; Sat, 10 Mar 2018 01:02:54 +1100 (AEDT) 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=ae8b05VuTPV6WzqtW28T2GDV4U1PYEXdUs5EgwjsqYI=; b=CQSk7agVal1UsiJeuSynjlt8xG BsRDdMRP86AypxPIoGdfYU2pBNPk2qIzc/NvUsiEivXZqI+l9D6y5K5oi8rRuICHF75poA7WGdu0A sNBXUAQHz6FA7/nF0O+XKAfyxfiiDvDI6/fuE0P8vU+VBx6rNUMqMOYHtqSt9FXAqa0ba1PO1axSk 1v4diknElDgKHmz0MpQGmkNFqxfa2xr7JMqT1i41mIOx1ryPd335jBan4zSADyGR3aNY1Pb38WmXH 7mk5xDtwgT3gPt5rll8MFv4mNAOYf7cZPPFDyYVDz18vCfFlBFypGHU4zFMbChUhD4LATa+Twtl74 SviD9vtw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euIbj-0003KO-2J; Fri, 09 Mar 2018 14:02:51 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euIbf-0003Fn-13 for linux-snps-arc@bombadil.infradead.org; Fri, 09 Mar 2018 14:02:47 +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=2cZZ6id+x0/wo2ATzm8/IeoYF4xqs5KCdHuahlIxLDo=; b=BmeAclrRUV+DVfvfq5W2HlD8B /bM27s1dG1HMikQycjrFmY7Z0m15XJKXLh03jHEonc22Sa4ml/fQScdNGrG9tS51fxkrvlRIrP3eV xH/s86vLlLJ6vWdYfePbmXPeYIUHZRLie2Pnch/X5Kt4EpYIf0ylt2zPqnE2pf9wDGYLmfqiYS+yp F5jZPGxw/02hbOgLuj67OXTGRwvbTZyr4AuC2GkunxTHK9hc+6aL9hWV5TbgWogPcuqcXnOjtS9Y9 /h3IgAIww31nYUoDOWDtn7AbnVvVo9B461IxOJ8bDyAtbgt8FiORP3r+EMJM5KJXEzpuVYWsKf2xE ssby82s8A==; Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by merlin.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euIbc-0005J9-8F for linux-snps-arc@lists.infradead.org; Fri, 09 Mar 2018 14:02:44 +0000 Received: by mail-wr0-x244.google.com with SMTP id a63so5511670wrc.10 for ; Fri, 09 Mar 2018 06:02:28 -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 :in-reply-to:references; bh=2cZZ6id+x0/wo2ATzm8/IeoYF4xqs5KCdHuahlIxLDo=; b=n28I0cW2tGIoBIYvHm1SI0XfLgASTd/j+fKufWMhstDQ4Pj7hb6Lp0fKgCIbDNz3br he5XQCd6p9rwPaNTHo4o0Uz+ZcfYVfLFeFwBCFXdC5L/tRjmIC5P7Q/4Cv/qXdIwUc3c KqhKMf/N2RQst7CjSS1svXucH30lNXhNRKyN7+lVhhj3MBjAAWTwfnwTx15mYXnezjsm WZaNzGRqzMTvuewgTuegpJiv5D3QqmaX4WuhSuanxMSU0ZCbsfuf/GgyOPG2o+waXiW7 vKQX1NqjKZfrh1VJD8E5dt0c18OFe3Po9kTmTYxPm1uq5u22ld+8CzuBdiRVepaWhudU FNiw== 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:in-reply-to:references; bh=2cZZ6id+x0/wo2ATzm8/IeoYF4xqs5KCdHuahlIxLDo=; b=lUzZAgKMJi4wIBfEnFLRY7eT9Mirf7kkS4PLsoDi+o/TZ6eTW17CO36D/RFpPlTNsU cp9j9jeXjy9X8mbUd3xYupO5x4tbZjOQnUWBCbPrkj3MpF6VmUQ1F6W3In5j4VBX63zG 4eTqcHCocmFBIJrgdqpDNZOtM+dBGarinQIojK1Cms5/NpypHRT3lfHD0YcqFkDZNpyr jFqZUbijAMgvYXK3+xEg436tjPdYdCFkLAuViriU7q6k4jDIEuCar7BbTG2HaliahkQ7 KFFBpPcyj9/HNFzxJoKaVtUzfCVDYsYRoeWJp6WNMusnWZ7kdT9G7N5cajS423PYCiyj ouBA== X-Gm-Message-State: APf1xPDQxzwE3YmAcY6+k78szjKOUIE19mKJwjYDeL0ommpaiLUBmvGn Y4DyVAPyCbn2+3RQ8uAza2tdBw== X-Google-Smtp-Source: AG47ELvbn6srqv+rO92C9ogiihmsYkHDHVrSlz9idaCoHMrpLnomGUssQTnZ+zDlRwUeFPhJ0hlfTQ== X-Received: by 10.223.191.10 with SMTP id p10mr27628264wrh.160.1520604143784; Fri, 09 Mar 2018 06:02:23 -0800 (PST) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id f3sm994484wre.72.2018.03.09.06.02.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 06:02:23 -0800 (PST) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Philippe Ombredanne , Greg Kroah-Hartman , Thomas Gleixner , Kate Stewart , Andrew Morton , "Kirill A . Shutemov" , Ingo Molnar , "Aneesh Kumar K . V" , Minchan Kim , Michal Hocko , Shaohua Li , Andrea Arcangeli , Anshuman Khandual , Mike Rapoport , Vlastimil Babka , Naoya Horiguchi , Shakeel Butt , Joonsoo Kim , Hugh Dickins , Mel Gorman , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Mike Kravetz , Zi Yan , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Russell King , Mark Salter , Aurelien Jacquiot , Mikael Starvik , Jesper Nilsson , Tony Luck , Fenghua Yu , Geert Uytterhoeven , James Hogan , Michal Simek , Ralf Baechle , David Howells , Ley Foon Tan , Jonas Bonn , Stefan Kristiansson , Stafford Horne , "James E . J . Bottomley" , Helge Deller , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Palmer Dabbelt , Albert Ou , Chen Liqin , Lennox Wu , Yoshinori Sato , Rich Felker , "David S . Miller" , Ingo Molnar , x86@kernel.org, Chris Zankel , Max Filippov , Arnd Bergmann , linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, adi-buildroot-devel@lists.sourceforge.net, linux-c6x-dev@linux-c6x.org, linux-cris-kernel@axis.com, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-metag@vger.kernel.org, linux-mips@linux-mips.org, linux-am33-list@redhat.com, nios2-dev@lists.rocketboards.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-arch@vger.kernel.org Subject: [RFC PATCH 5/6] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Fri, 9 Mar 2018 15:02:03 +0100 Message-Id: X-Mailer: git-send-email 2.16.2.395.g2e18187dfd-goog In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180309_090244_305661_71F8EA3D X-CRM114-Status: GOOD ( 14.13 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c0c:0:0:0:244 listed in] [list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jacob Bramley , Ruben Ayrapetyan , Andrey Konovalov , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Evgeniy Stepanov MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 separately handle the case of tagged user addresses as well. 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)) {