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: 10428101 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 3B38B602D6 for ; Fri, 25 May 2018 17:21:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2192629321 for ; Fri, 25 May 2018 17:21:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15F502972F; Fri, 25 May 2018 17:21:36 +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 9FEDB29321 for ; Fri, 25 May 2018 17:21:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 624826B026A; Fri, 25 May 2018 13:21:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 57F4F6B026B; Fri, 25 May 2018 13:21:29 -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 3FC0C6B026C; Fri, 25 May 2018 13:21:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by kanga.kvack.org (Postfix) with ESMTP id C5F676B026A for ; Fri, 25 May 2018 13:21:28 -0400 (EDT) Received: by mail-wm0-f70.google.com with SMTP id y82-v6so3957692wmb.5 for ; Fri, 25 May 2018 10:21:28 -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; bh=yZP0biNYmIhGSM1a5h0e7cWrGAjsco28ACLkrXaSiyQ=; b=J7Q6bd5Z2BD4jqk/Mh3bwR6DQAZl6oE2kuzcOBw0xfY99Xi9gf9QXJWqjn3+V0SfvB 4bLVFFps3aka7Cwf4V2mK+3tyF7umtgRRMjy8NVtJJYrpyNqfdMAXD2pccvmKMzb+fap Ae8CexNfuGgqBAwaLua1s8fJUPbOAgUseyIv2O0IJ+bS6tRI+vPOsH+lLdnhRnwK8xcn aFlC10Uz5yzqiXOyvN/09zqaB0dcHaoQYyi9hVroYTPuRsS0JzyDSsYcT91zDg93fNx/ lS8pnFIXehv5U5w1+xXMtFmHiKhqgGeKBxNf+DumBJRxs299d3ku32SoZPfn5zYHew0M rhfA== X-Gm-Message-State: ALKqPwdUWQAeak+r/DpTj5bg/+VNyw/3N/z4PjSgeaqOzx/tVWw7RfQ6 ku5TR80nwqOBtyKcky+fapjgh6WPcLcUA0H033vVn3vk6N+MkcJrYZb22LI28HKIxU7DaXBLILE PN2TunkZ2Xnvg2zXRu6xviEZGgRhHbx+qTPL7japK8OE2ejo/qstoSdj8kMsFf9fmHQiJqVx0O/ zY6oeJlQmX5j1q7jP07vy4OsSCfltUJdt2C7hjpSi9TCn9R2YONq9YH9uGJf41hSSuveaA6HEKQ c1Hm17FFoq694+HR+p63aGrwP3pP22/LCd8qDE/5QVGN2/4Dcbiv97eYfowDP26BcU90Ma4B5cs bbOE3Pfz9gbjg/x+0D4DIzlWcNLiM8+P+S8QJdJmmm3TMX7pJwQAoh1GIsoLbWUK1VK5x1N3dkO S X-Received: by 2002:a1c:97d3:: with SMTP id z202-v6mr2472732wmd.66.1527268888368; Fri, 25 May 2018 10:21:28 -0700 (PDT) X-Received: by 2002:a1c:97d3:: with SMTP id z202-v6mr2472705wmd.66.1527268887670; Fri, 25 May 2018 10:21:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527268887; cv=none; d=google.com; s=arc-20160816; b=jeWkWednRMVeRjwvS/nmFXm2MeDK9sH/vfeBwfByPc/U7Y9/EjyRxJPkTsVLkrOWzt JXkjmmnZDlKTMm6Io7g/iOMXgwB9oJ+6SFpOQTqr/F9K3IDbRgujjmpbOAnHYcdzpBtM iwqObHfQFUhpGulAwuHe1BtOStWoWsuZAdEnVAkEOi9NssqE88DzFF9w3djQr0fX0cJi 55diZUjjlmn05pRyFhvDgLUv7L1bJz1oytsiRj8IND7AvqIECaFYJcORtcvBb1BAIUl/ fhWDVnJBmDjgBfXDJI6MdS9UHiZabXS705rBGCyQmGM2g/WQXY5ZyutYVFF70QCXChS8 /Sog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=yZP0biNYmIhGSM1a5h0e7cWrGAjsco28ACLkrXaSiyQ=; b=el4g4DmAIIOyhnBb+VhMFUAVWxc6Vhcoy3NmwSfsOqYShPra9Kzjo822CG/7/kgGXy BUaXdv3JfNLQLbOr/DwmxzEQ5ROdMX21RJIh5gr/h+PEMT0yiRMTDEPWsRiGCBoYhyGk Pxpynrgu0BKE1p5GiotLkvmu1+dviicRgcRU2/ZUXJA66FXb9NybuIha988tQhVEHA1j yOnFH755tiHCAnzOaHCAB8ovBTvywVLPvV9btCLHFlyZaC3SQcAqgWWsrIi0jemlN+Ac /UDX2ada4g+9SjDx3POA7fIETKXW0IiJGt1r93IvmJRIXawdjZ6s/FozpeQ5OxqYMT3T 2ktQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RIIFfTCz; 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 16-v6sor12889893wrt.73.2018.05.25.10.21.27 for (Google Transport Security); Fri, 25 May 2018 10:21:27 -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=RIIFfTCz; 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; bh=yZP0biNYmIhGSM1a5h0e7cWrGAjsco28ACLkrXaSiyQ=; b=RIIFfTCzVWK7Zyh0oktok2JvdAghpLR7bMVgP0HLy5S/3rf973xF/QTZa9wQ4nx3aj B5/8Y3jnetkBcUAgzBdFNU7x8AlCBRL5YeJL6/vIOhrkUu5zU+miM0wPnwG0CTLVG34S DrbvkfdwjwE+iAOEk+pfOwiOfr4Mm7Bb//gGhAdNO3yIWPXCg5X3/q+qK3YPna2B/Q9E WmI81zGTsyiusSTsdc91LKPHkWW84UJVnPhxqK4NndtlCScLQh5dI8k9ttH2NhCU3UGa YG9XimfWqivTL31V3XR9qvQ/7wtb69FdJPXsx3bXqikWT3afPL7ohHdfusqP0jARtB7Y x8cA== 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 Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya 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-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)) {