From patchwork Mon Aug 6 16:40:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10557461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 56C8515A6 for ; Mon, 6 Aug 2018 16:42:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44E3829765 for ; Mon, 6 Aug 2018 16:42:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38EE62981B; Mon, 6 Aug 2018 16:42: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 B6D5B29765 for ; Mon, 6 Aug 2018 16:42: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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=eX+m5vqgpuNeahJtMStJ3J9shakfsKXLoy6H//CkkAo=; b=kdNdiqxk7X/LPI zv6Bfm8qew7CwGPri1tbwuJRPojiCFXorfQjfVNrl939IfpMH9DqBhfRmAErNIO1BHCUGcgR7A0gy onglXS9YNBT3w3n5l5BlpanwpldjmNR0uIE6v0k83lu4eqrjeQwY3/maPJ/2pQY/BMCC6e5Evbhaw F6ZJm+fe4drHueHouezfUZ3fmlfzwc7WEtZsNKShZr8DGJTXrWqr0BuTSyplc0aDhbSAV55REJIll JfFfM915thCzz+zHjuYCYlOlsZjy8CfGSyS6SWcRtr3nAAilJkp84GWm2q1mrzYUnByED/IG0CxJT 7NzHG7OuXey4svidjk8Q==; 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 1fmiaR-0000qQ-Tr; Mon, 06 Aug 2018 16:42:27 +0000 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmiZE-0007VE-Hg for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2018 16:41:17 +0000 Received: by mail-wm0-x236.google.com with SMTP id l2-v6so12057803wme.1 for ; Mon, 06 Aug 2018 09:41:02 -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 :mime-version:content-transfer-encoding; bh=NHhNjwTAQ121lFvWu3hMTAeIOaL1SqLvmyhWDld+/fA=; b=nmzurxSKJcYDsYV1+eQXo1AFKsb89KkGcBuugkQwRDCSRWjpnPT5FmuaK8hAnWtRDA 8/kdbUdOeJA1T1BUmRPPsYuEcN3Kf4vSMrWGCIeeWUORWVyj7dCOJBssyjuH8JPfu5d4 oo9z4xhcuG4G4MuRRRIMSo/OxcZmT2KNXiczN+sEe4P2Pm/xXP4k9NmziQ6vBFSg4gYw KSvZQ0EjS6wIbckSFwBHy7RkDJgcDfgN1QmlhoruRTi126+u8b2e0oSpg+Spg/tf2+H7 TKeHDNyXPqvg8KF+N5zbST5JPqKK0xbhHR/FCBhGHa+94zaC7S4DCqWFdC5El1TiFThF mylA== 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:mime-version:content-transfer-encoding; bh=NHhNjwTAQ121lFvWu3hMTAeIOaL1SqLvmyhWDld+/fA=; b=L5yxW2fQtteFHYPI7IpC9QRE+hYoQA07b3bqqVmQgdI7jk+8LEb/dxDerzFcPy1RLS 9eRHbuT3KC8qEVfver6I/TsWH/DxdQGR3Kuc9Bk+CqWCl6fsz/W0wDfLpjvRs6qL8ABk bBnzmt/eFdLcZMMx0nRKB3EHEXTtNvudRxiaB0DRMdLJw3wEfrC8VTZ1TeWEKiMcmZsX lclMsLNpB6a/W+gFQeMSUQhz2aOQHgJqxGTIJJN2TmKBBVemYP2VAqgSjbl8Jf3s3sfN TGT6g/fZ6PRdgZa9Wv/NukS4rTJxMTC21az2+y/2DNoPcMacOTCbS0mo0YxYUGsRaRad XvNQ== X-Gm-Message-State: AOUpUlE5xafpGkqTiYDD5xX/MOHPOgmeIURfKctV1NKE6aKAAxJlkdps bCPhDaCA4SWiXyfZ/oTQvNAy5Q== X-Google-Smtp-Source: AAOMgpfcqP6DQGXwm4G0u2QWpeaFGKnbiUme9+ppvLZU345bSzHiJYtDTNzNNLOci83AySBymYgP7Q== X-Received: by 2002:a1c:7e92:: with SMTP id z140-v6mr11662280wmc.48.1533573660613; Mon, 06 Aug 2018 09:41:00 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 66-v6sm16385790wmw.34.2018.08.06.09.40.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 09:40:59 -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 Subject: [PATCH v5 05/10] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Mon, 6 Aug 2018 18:40:40 +0200 Message-Id: <6a59f7eef9a056c632a515a3a51ade3f6420b462.1533573460.git.andreyknvl@google.com> X-Mailer: git-send-email 2.18.0.597.ga71716f1ad-goog In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_094112_980004_E88D703C X-CRM114-Status: GOOD ( 12.99 ) 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 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)) {