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: 10378449 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 0ADEF60353 for ; Thu, 3 May 2018 14:16:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBEEB29032 for ; Thu, 3 May 2018 14:16:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E01D929171; Thu, 3 May 2018 14:16:07 +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=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F59729032 for ; Thu, 3 May 2018 14:16:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15E8E6B0012; Thu, 3 May 2018 10:16:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0A1F46B0022; Thu, 3 May 2018 10:15:59 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB8D16B0023; Thu, 3 May 2018 10:15:59 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr0-f199.google.com (mail-wr0-f199.google.com [209.85.128.199]) by kanga.kvack.org (Postfix) with ESMTP id 7D79D6B0012 for ; Thu, 3 May 2018 10:15:59 -0400 (EDT) Received: by mail-wr0-f199.google.com with SMTP id 54-v6so6803571wrw.1 for ; Thu, 03 May 2018 07:15:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:in-reply-to:references; bh=M5UHAvrtR5/eJhShSI1YJ0Xmi/BIFkhr39NHkoB1ybI=; b=ddOOfNfC3bWyBiZ/ibNDkFxfNLnMZNVGVaS+iCM11/bVt+8CvhGHgVcjMfdQlXonWn CvJ2jNk3TJTcbRACl0JYu89OIsDaROJntLB1Hv5ec99mV+uSuR/Y1jbse3KQId4sEWCk ZvaPnf+PPXA2qkU/EzT5B46eW71xt1b/2yIEL6+MKYS/oisCqfqwZEYYFPxVsHpeEwpL cR0QcTy7zVY8jzN5i265282RrZRJI5Rh8knDgLSX8KjJebP/SgHU+JwbBdy2HFdvULBe 5YZbtqAaOsA2zltIumTyfumjw1MaJK+hN8TTf0rprE2XB+FyJqXfdxfia5axsFNzfU0y ZkUQ== X-Gm-Message-State: ALQs6tBqV7/qsfSmZmsElwtu027hu7cCDd+4Q5JqK2yUB9GBETudLilK WtwG7T0JbEdKgOPMeNX8HjYi6X7Q5AAJ3zjt/xu1oOmnOGx+0v4McUDhG+ag8J+HalhjzTuMN+2 0SUu+oFopyChIhvoclU/1a6YN9Ec8ZHbLMpKl8vSLqmAXfIGRw+SmydGx/ZZWHDvTAib9Jn4zjS 8m5S6CcCvigTw/R2unpVThGpOTTrzw7OmMk+ZeHJJ3VZt8skor97/GndjuphQ+7Ls9WDZ+WJt3V 7G0htP4G+AVh8MQ4rHrdosqhCP3YXh44s/RoR77sQ2UxGQBy3cxKfPIttI5/kO4daUKBtDpLynx ZT0VfXRTtsMwb5I3ifLclw8lB2ZoJeswuJgSEs5Hka2pdCtF/FrqB4f/0nqmr9O6iHVGR7yJfPc p X-Received: by 10.28.95.131 with SMTP id t125mr15458951wmb.124.1525356959032; Thu, 03 May 2018 07:15:59 -0700 (PDT) X-Received: by 10.28.95.131 with SMTP id t125mr15458932wmb.124.1525356958371; Thu, 03 May 2018 07:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525356958; cv=none; d=google.com; s=arc-20160816; b=UhSVS9La3U4qpPNJ/VRkNgjd7R6LMXeinZQvorsKJlQz7/pqdrz7DzboqrSbfYApP0 29B/w5rs7efFST+UbGlgt2aKmIOjops4kqKvka4EnILVHq7lraVusQj+f12BUdx+mP0e VfZ3W8VuVgxk596Ne11RXitbWVl3l1OD0DxDBNSdnN+6VlhW83KdNDrhFPQmosJtK4ty 1h98oN6kIK5YobxTRVheQQWh9Uj2ob+qjK/sJ0TxSt7PFkwGqPiP+zbrnWTGNKv45aM6 JcCZYh+eAAkMpQ+8NYbgd9WmFLzKVyLF6wI9cSclsZ2/k5xnvfZfUZPk7Pn8wFpJvXAi gJkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=M5UHAvrtR5/eJhShSI1YJ0Xmi/BIFkhr39NHkoB1ybI=; b=auQLNnj2u6DzcusxPN9p7MuRXuXL/sJzyK5J9rWBSWArUs2f29HRaQG78m0q6nNfmb mW1T5m+xjtq5yAWvzui/CdOIu8P57xeAgAGCVK9UwcuBjKDKxxGkKA6PD4X2iAjnmLZA 5hvY8oQtOArPQqzvemjdkzhkpVzr1C0FgCFLANAq83QtlEKaRPguB06e5faQHlCFIwN/ EaJ+DHWYt9y6KATXKM6Y/+pM9i4K3SoQsDMmw+DnD/ee+Ef8vdnDngj+2htb8wZvlpRl DsmCZAxXhqjt9LTxeUZ29vWxyGZAFo266aQizboF4xHBkFyS2Ly2oODMP6TuX+wLzxZe INbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dbEUj9y/; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m3-v6sor6506526wri.32.2018.05.03.07.15.58 for (Google Transport Security); Thu, 03 May 2018 07:15:58 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dbEUj9y/; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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-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 Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya 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-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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)) {