Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp511349imm; Thu, 30 Aug 2018 04:43:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYBmYewmDlaeqUZwhwSPYlJmF1nJuGKGouea46Qu5MwCvLyF9REhopNtnf4AbFXSPCxsVjr X-Received: by 2002:a62:778c:: with SMTP id s134-v6mr10139933pfc.189.1535629424574; Thu, 30 Aug 2018 04:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629424; cv=none; d=google.com; s=arc-20160816; b=0X0NyUOrcgQZxc7N+fopC/OCfz0jtV7aVV1RIC/X/85nDviwPEHmAyFhVLKJ8aRGLi ElKyONAKTZD03Ct9ANzs5e9q7txaUq2uGeqKXGAAQyLFzmf2NS+NARFDhZhXH8xLH+SI BHqbR0P6s83jFm6YrExJ0Ty++2RTYroeOOsGcMM5ZxBcc8ZPrlQto/CYc/rCLUHDwClN D42AjBDXzmZ0NN+o7m4m9uMLNrwglchZWUmyUbRJB3JVRwXEIkyKju2+/dkKk/8O+i4X bIFPaHhQeIxJRBts2fsyZzT0BQr9aF9CD+OohWkk+ztkVQ/I4IWfVuetM2AvU7S8OPrC lAVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=5dvluYXXhbs3bkFHe7bYXbDtGM4AV4lqI04lFKRyGa0=; b=Eea5ZO5+6zaj6PA5PH9fFwssi7uLuSR6kmBfjWXSfitAmxV2+yhyBJtMfrKP5ABkAm Wfvv9l5W1fy5jX+KDQP304dHbDahsdo5MZTrOpk8SXIH+f9XZg6+xrEYXauTpe1eKq32 +5GCZY/q00k+ZRhi5AyWVK11k2zRiLSvWGqn5i7daqtFrnELaVjrMaoTQGe4Zk+Hvqg6 ZEhXK8BkHQmafGqs/vSqgdsVrBk9W29hPunlUF9z+kvcj+KkaS8grwpy4fQxnsgF41c+ vdPxUWFdF1EhEa0NQuNMgezY1Xla0GGmB40zq1v3LsNQmwt4BAi114AImxlX8OWHsKbg PyVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FrgdPh5T; 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 d9-v6si6498797pgg.423.2018.08.30.04.43.30; Thu, 30 Aug 2018 04:43:44 -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=FrgdPh5T; 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 S1728524AbeH3PnN (ORCPT + 99 others); Thu, 30 Aug 2018 11:43:13 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:35626 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728334AbeH3PnM (ORCPT ); Thu, 30 Aug 2018 11:43:12 -0400 Received: by mail-wm0-f49.google.com with SMTP id o18-v6so1696441wmc.0 for ; Thu, 30 Aug 2018 04:41:29 -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=5dvluYXXhbs3bkFHe7bYXbDtGM4AV4lqI04lFKRyGa0=; b=FrgdPh5TBPIr4rtMd7tklQtyRgar4ZAsFHKz1PwEj3+VC5jau9Dry3d3VxRWxcx9DN aM7aeZudTWm7p/kNyIHKV/3zc+Y5VxHMcMOGT00Raehj8yCHK4qQRjbgPVV2KLJMxAqa 3Rgdu4UCrXM9AqoS+dFhMRoW3rJ0nq+cpf74SiEB/jzedt9fBg4Hfm/m/pENAIQSu++0 oMrCJovZb3IkPM50eWmd/9DzfAZugaZLcIZhmav9Cf0kn8UP4YxUMn9mjnercwABxtdG oWWF4BHN5MPrFvo1HQRM1riSm10AId1VXqNCaVpDU0IN56koQpJ+E8OSG+nLyWo4zchm X6TQ== 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=5dvluYXXhbs3bkFHe7bYXbDtGM4AV4lqI04lFKRyGa0=; b=J21MHMlpmKKtpCFTgDG1ZsdnP7KCabRMrpb+9hMq7n1suWSounDt4PxGysuDdPWCEz 6enJ5lGRLo+cDYuGc3OXGekBsukLNH1PIhdEd9WrPAeyDVrAw3YDpWHQn7/OtFW2Va+C Npu33J+UD/dk6aFAgXOg+SMWkNMcyjJIv9XU1FnYDG7U3VJeHf9XO6bsMwWxFQQzYY+Q TVdm6cKFt5You9TDuetKUecQ5F2l4wA97Qkm7T7uQenNFE2CATbnjVTp1JUa3qWCreNr DzT1sMdANsibKPdoM6eZCKxWuok8xVlT2Ch+Mg+bUmnWHeFKFQZ3kC6tx6llx7rZDuyY eE8w== X-Gm-Message-State: APzg51C2Z2DMb3AoNpZeE2Rj2+sHmehEL22H5tpd+eMKMeStveSnzq2o 3nBLRZzPn4bQ2UYYAU6SdHhg4w== X-Received: by 2002:a1c:b143:: with SMTP id a64-v6mr1645342wmf.114.1535629288159; Thu, 30 Aug 2018 04:41:28 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:27 -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 v6 05/11] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Thu, 30 Aug 2018 13:41:10 +0200 Message-Id: X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.19.0.rc0.228.g281dcd1b4d0-goog