Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp907023imm; Wed, 20 Jun 2018 08:28:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI05ZAKFyZrS3JZF7wCMTJLfiEi8m1J0edhI/qrcFgjpNAVAAn83wrZXFLe+F2IcrTxlGSd X-Received: by 2002:a17:902:6903:: with SMTP id j3-v6mr23916972plk.313.1529508482191; Wed, 20 Jun 2018 08:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529508482; cv=none; d=google.com; s=arc-20160816; b=wb8NaQhH7Epnbia3Vqd+xmL0vM6DeNqSQssprtZ/vXDBmmV6sHZrhKYWOwhTc0P/GE vQhH3ioMJwQV+X2DwKg6pLaFn4d2kbf+zlNO6lMcbyR+BK0JyFFthjWqUmMVnvcfryjv 6BbBAnJV4zJRjbHUrXdfoxhU9uewGzIT8C71YxwW4OkHx0yVmVm6sV6oh3t5ueIveWpM Fr5kseRtw9CPs3vkzPG+wSqabFAF975SGPch81+o73P7uycOH5dxHhiYU0TAA3QSr+Al PbR75e3wbV0hc15PnpO/4168UvHCE1glK0eDEgjnmITWvyLDb9WQbeT3vPbvsyAP9ZZE wpug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=bcED8CkiPVSBRc7qI0iNRMFkXBn8RO25/zBGmIuPiVM=; b=bLo3BjVQwF2cCZuQ1k5f2du2pVbkA/NBSZIx/L4ZDmZxmCi87v0ft0dcU2HkF5KbRs QT6mDL1ZBSg/ZPCGx3zlG2fH1pw2q/wtMR5fcfaB6qEOsmaOK+8NoSGekF5xYwPIFgov 8B2cQvZ3yNxlCCU0aOdF73ZpuTd5kjUUfjoVZiAuJbM/qaOEl68KK8N1edvrtyCsy+r/ a66vpXt3t3ZxuH4OON2c8ChRV60CsYF6PNAMYhCwPK5C9jEhqxRcrdj3fl5kIL6XLFhv ny5/yp4MqwFqh2hFK9Oujm6pD3DPwefpHmqL1CB0oHN5ePm4ksqB/Ni8nuNGAZ08io7N W75g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=u0WfB6NH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w78-v6si2667832pfa.359.2018.06.20.08.27.48; Wed, 20 Jun 2018 08:28:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=u0WfB6NH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932547AbeFTPZ2 (ORCPT + 99 others); Wed, 20 Jun 2018 11:25:28 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:37256 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932232AbeFTPYj (ORCPT ); Wed, 20 Jun 2018 11:24:39 -0400 Received: by mail-wm0-f65.google.com with SMTP id r125-v6so228442wmg.2 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=eCTG7b+M5Iy+6Mj0t+bXMoxR24LTZY7DnqmrAxB72HTd7zzs7gff+NvpmP188KyxYT UE2cU0rONdK1aey5kQVAQKD4TqZRBhSJwQ6Ebps4+Ik6IrerXZqU/mGgRs0oRC3RWgQA 2FQ8qn28o47PQHYenuaBIM/er3+6uLV5O8OiEA54ed1sO/BCA4Nita74r76A+mrFxemM qSi9+XWqdDq4+ap22j94SUESfaqMB1KLdGUwj8w38god79/l7fxmSC9iRi23FQepFNWo AqAxqAE8qZfopZc5ekbcPxt0iXZSAqmkVRMe1SkXqOeT3elBTz8EAaiuRZyATaDKpRTJ n4hw== X-Gm-Message-State: APt69E1uvBjgEM2h1P5gdHL5j7wgSmaWTUhY9f3sqb1UHBP1frlKQ3Mr Lq3nuPwTQmp/8zYF/X39m/k8sg== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)) { -- 2.18.0.rc1.244.gcf134e6275-goog