From patchwork Wed Apr 18 18:53:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10348815 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 6E6FA601D7 for ; Wed, 18 Apr 2018 18:57:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E4EB287F2 for ; Wed, 18 Apr 2018 18:57:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 527ED287F4; Wed, 18 Apr 2018 18:57:34 +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 DD506287F2 for ; Wed, 18 Apr 2018 18:57:33 +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=VWoWcg2d3qvvTmSO8ISlrIw1mYFRgPGnmEj+8F3MNu0=; b=uE6RcW4u0DphAZ8xamgEB6Kd3p 4R4RWHKLfIvAMq6qhLRFYZu21w7X80+D3bKGkBAK0sOqF8qt1TjKTDnv4PGBTL1oIVymfSNR3ly1Z f8UlI5Rc1RVLdyu9mJ49RZPGroffDHiTBgbTtPVOxTUKPRK/oDrlrkFJfyQFcUrtOx46AMP4hrIhm roKwc+lqMi2hvkASH6pgvzOfLsr3OUPjLz4wIejGBNQD5dwNYOAM795N3UCTuiqo4ZHy0jjx8Us8x NKgVW/awJ685m4eQa9NVf3KaWXiMqMjRA2uKopSBf/8IS8BnL0gOa13FhimANnwA8yx1inXdFm9PQ uVY8tlsg==; 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 1f8sGe-0005iX-KF; Wed, 18 Apr 2018 18:57:20 +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 1f8sD4-0002v5-OC for linux-arm-kernel@lists.infradead.org; Wed, 18 Apr 2018 18:53:40 +0000 Received: by mail-wr0-x242.google.com with SMTP id d1-v6so7521624wrj.13 for ; Wed, 18 Apr 2018 11:53:28 -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=toZBohlOWDiEKrPW3p9JdtOT1z0eiogSGWK/THMLOZ8=; b=wCsTPP/lgPn3EvPWa4udd8AK+U36N1PQjXKBm4wauzo1Eks0os35Ev2seoyEZxxVGI dNtXNPM0XOdQzzcykewx4zhfxEt1jzQ3yrCMon3IW+CQ5fKvCanelrSjYSJ2E18Qs7Cf txRBCJC5OO4rKPw26uy+83nrK9fJvSKak5ZEkpP5uebqAJVtTqtd4jNEITF2Ez03Ynmt ZLPnqP2NWllzuDd64ohHHuebmAk2aNpH4KnWN0CdK2C3wrZv+atI/ujv0IQgtOMa8vUq jzTak6Zo2rotICxTwkQ51CHuwzcM/onQ8TSL/KxZLr0TpW1OO2YbcxgEQ+tHj8qVjGhy J48Q== 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=toZBohlOWDiEKrPW3p9JdtOT1z0eiogSGWK/THMLOZ8=; b=kcSUKQEHYErv/G4usggLa2gIrjj62IGJli8dlkaLmnYM2Xy4K8zDDccGbcz/KQigeG 5kNGmn8X3DvoIXWmPdo6BizRq4vJ6nnsmSPTvSd6TDJjeY4qPn+RMSD7X45yjQqc01Rx 0py6ud3k8KH1G78QqwLath+KCGBBdC/8Cx/XWLz9axWr123b5n9YtXYj4pE5ihd7hJYR vvl6T43uNw9Onc9tJ79PtgKXE1hlYn9WSSylD6sm0hUTTPwS9chBjIVWFpN91s3xMWKa UaPXTFAkb4fe52Y0GXAxZ2U/65fjSocThJtPCTGkMt02tZXP/UAPaLaiVYT56asKXqsT E8BQ== X-Gm-Message-State: ALQs6tCa3kBtRBbUfg+RjkrEkOyjikcu11lZ4dxNDYr8NBuLbt7dT3gK F2hvQo6N6j/0D1zWw/GYkD17xw== X-Google-Smtp-Source: AIpwx4+S5EFC7jdGqy0sLbR9gOfqpUBQsmSEOETBpuJK0ZJ3gjbYmpNce77c+5swtw0tc6Ghd7tG3Q== X-Received: by 10.28.34.7 with SMTP id i7mr2438174wmi.97.1524077606692; Wed, 18 Apr 2018 11:53: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 k79sm2616735wmg.39.2018.04.18.11.53.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Apr 2018 11:53:25 -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 5/6] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Wed, 18 Apr 2018 20:53:14 +0200 Message-Id: <82ccccd82c350f9243fc4e1d377cdad9bf23809c.1524077494.git.andreyknvl@google.com> X-Mailer: git-send-email 2.17.0.484.g0c8726318c-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-20180418_115338_858337_1AD0285C X-CRM114-Status: GOOD ( 13.43 ) 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: 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 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)) {