From patchwork Thu May 3 14:15: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: 10378473 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 230BB60353 for ; Thu, 3 May 2018 14:20:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CA2628CC5 for ; Thu, 3 May 2018 14:20:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F120328EC4; Thu, 3 May 2018 14:20: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 17FF228CC5 for ; Thu, 3 May 2018 14:20: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: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=fN7XrfA/sDKuArD4SabuwbY2JX5MG91gHm90DTktwYw=; b=JmPomF8uSdY8AevLqUG9ubyFBU 09yVzczJeE/3c2ZE5S9kkaFlR2kSWX0X/0HDn28QayU5nisJSJFtYeXu0tOsd4vjDUv8GzmxzbYYg JYBlbz/Qvwd2azbjUFzLJw00y6+0PAfD4J3UXVYnvgqxkkH94F3PAQI3dYL/VkPfWL9PeB8ATqC59 yTAqrAcvWMdPa9fDPndDyefk5gN80GJL852xupL1W3GG/iKzISR338G2jls+yYAQFHGV9dRGlR3pa VozgSs6CYdJ6r0qeafWfZYVLezTv3kO97aiEsKvyRfTm6MWkZgKi7SlHQi33sXNttdXka5xEZsPTG Uhfpt3vw==; 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 1fEF5V-0005PG-Jl; Thu, 03 May 2018 14:20:01 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fEF1g-0003VB-0Z for linux-arm-kernel@lists.infradead.org; Thu, 03 May 2018 14:16:12 +0000 Received: by mail-wr0-x242.google.com with SMTP id v5-v6so17798907wrf.9 for ; Thu, 03 May 2018 07:15: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 :in-reply-to:references; bh=M5UHAvrtR5/eJhShSI1YJ0Xmi/BIFkhr39NHkoB1ybI=; b=dbEUj9y/d9revilF41htY8tL8vfwOjD+LyR/3xiYiL8nDwFb2RNFx2jhSzefyIce59 cIyLKeIWW/ckQvWDsWbeNgvU9t6S4MGX6eYo8jWEdYCAV2tfTxNF9CkCtm+4yCU+inLO 65DK88iaqemjOrBBYUBVguEp/xBraRAi1EAUxlkhRzh2SQUp6zywAB6o3Hak2NXju22a LadHnLSttfkzETN1Pn4COb9e92lFiW5MK7NXaY38UjJPHfVXK3zvmwrXH2g0kz+HvXml LNLCtKWzJ7wMhh+1qMRqKsLk/in9sKyd3gQkQWEmnuX+mPO/beUGcFeyr4tPb4/rpvPv nDVw== 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=M5UHAvrtR5/eJhShSI1YJ0Xmi/BIFkhr39NHkoB1ybI=; b=lyL1og+2DeURjc1AOtajOnval895FUcwQtvTmOXL9SZVGkmBBzRHBygfCXr54GMnOG enuZ56WMI77C7EcI7fsvUWHu5PmER8WOysi80huuwZkaGiNIYigCGd/Dwt2kSZRGcDn/ /+actNI2TbwWqDQYp4n/c0tV+HHLZgEvfj8UlEB5vsercxjiUKqD8eat1n4uFlbDh3EP G9C9My3trrBdXC2bJHZtzV/UWBuv2hr3Gr+nzbN7v8rSLgsYoHpmVXd+GXqKAZWXkJCk /0BQvPSbeOTZYYj0aoZ6PARWrx7Pcf7sAQsYHU8tYC2WKE5ZDERWZtXm9hXkIK0h8zyI PdPQ== X-Gm-Message-State: ALQs6tBUY8hscqmPB0/E7SIIePpLOOdlOTFHjBTfuzW6fnixd9e6ab1y +8nOAHlDipXij1tqcwOj2IMjyw== X-Google-Smtp-Source: AB8JxZrtgvBbu51uuNOrM930KRxctyDs8aDRqxQKJDoQnvKSatdZ45lFj+2+C4ayBT0TuQT8vva3KA== X-Received: by 2002:adf:c3cd:: with SMTP id d13-v6mr14198496wrg.282.1525356957822; Thu, 03 May 2018 07:15: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 u20-v6sm22090298wru.33.2018.05.03.07.15.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 07:15:56 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Jonathan Corbet , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , James Morse , Kees Cook , Bart Van Assche , Kate Stewart , Greg Kroah-Hartman , Thomas Gleixner , Philippe Ombredanne , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Dan Williams , "Aneesh Kumar K . V" , Zi Yan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 5/6] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Thu, 3 May 2018 16:15:43 +0200 Message-Id: <98e18e4ca8e40bb8e7ea8e622833ce9123207e1e.1525356769.git.andreyknvl@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-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-20180503_071604_082368_D7BAD9E0 X-CRM114-Status: GOOD ( 14.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 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)) {