From patchwork Wed Jun 20 15:24:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10477743 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 522F760230 for ; Wed, 20 Jun 2018 15:25:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4433D28CF7 for ; Wed, 20 Jun 2018 15:25:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38A4428F3A; Wed, 20 Jun 2018 15:25:28 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD38528DDD for ; Wed, 20 Jun 2018 15:25:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932299AbeFTPZ0 (ORCPT ); Wed, 20 Jun 2018 11:25:26 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35501 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932241AbeFTPYj (ORCPT ); Wed, 20 Jun 2018 11:24:39 -0400 Received: by mail-wm0-f66.google.com with SMTP id j15-v6so256693wme.0 for ; Wed, 20 Jun 2018 08:24:38 -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=bcED8CkiPVSBRc7qI0iNRMFkXBn8RO25/zBGmIuPiVM=; b=u0WfB6NHI0Vfw7EUk1hYoNDh4hKDvHY5AQ1L20Ifpw+DC9bnAndbsAlNeEdQnwoNmh 6DBLsQtVWl4D2QlrBsjOWU+CQ88q0QBpIFSovLwoUVVj2Oo+TRuWS+jep3kcbjoHF18h g1SSSxxpROYeNG4T89d/1j8RGHCjcwzUHxHDamDEa6mJ0bcDEsQai35SxKS2qNkwqWNV VlnjcjgB5lWq9Qtaa/Agqo0s93y929vNRTENIu+a1EFHO94YDA39tUYN8IfaZvaEcGNh jHTFif6pvTIQDoJwTGXZLDTxD8rXt6+ccCKoI1BsYITIWQPkDqYzpFDVCxXEEwcLjWEC khvQ== 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=bcED8CkiPVSBRc7qI0iNRMFkXBn8RO25/zBGmIuPiVM=; b=OUVYw++SSrTDDhyOwlimgm07vm7/eolAQtD1b06KpO3B4Sal9VtiytyBpP2YlaNW+V XLjzKM2rkLYua7cajrSP5hg2hRmudpbgpzJ8YvxYJB8TzrCeyZbSQmqSRolLNDakJbbm U4rMUEF7WhDT60Jg8bxGyCZRCFgBPeG/HMatWYF3ilFgtrnn16gvflLwdzLZR4j8vpVQ 7smY7JcY2l3Ofc6enUCuWYyP1l3Ti5NR6PU8lW+GhPRsATbYuqyhsiyUwzDCMHuTjRYs 0DY8EY0tC1Ch+tpNldVu1NPi8n6Zi+RVVU6naVFJPlR/gmeHWcvdWvhcsPam2t0fro6d o+qw== X-Gm-Message-State: APt69E2aS5NZ88z0FxojvZrsX3+ut4GAYwYvBenHJkarQArGETpVESPV l4KoE1D9kVHymX8R8dpXPwAm/A== X-Google-Smtp-Source: ADUXVKJIWiVncHhLaq0gFfeTZGXtQPrH564Sy27fJti3VUKRpFj/LKkRGrTK/X22BIXNVbMclEsO2Q== X-Received: by 2002:a1c:ae8b:: with SMTP id x133-v6mr2238049wme.125.1529508277688; Wed, 20 Jun 2018 08:24:37 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id c11-v6sm3959244wrm.65.2018.06.20.08.24.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 08:24:36 -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" , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@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 v4 5/7] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Wed, 20 Jun 2018 17:24:24 +0200 Message-Id: <8ccd13e2d13dea7143bd8b5be44b733c03aa3c02.1529507994.git.andreyknvl@google.com> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: References: Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.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)) {