Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1302765imm; Tue, 2 Oct 2018 06:14:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV61X67yyoc4UVsouViwHMTYlwgVbmNRxRnTU0/lrT868SzoREdBOCucs1k8xzVci+O2GP8Rs X-Received: by 2002:a17:902:2805:: with SMTP id e5-v6mr315360plb.169.1538486048213; Tue, 02 Oct 2018 06:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538486048; cv=none; d=google.com; s=arc-20160816; b=WyJE8kr1ru2QJhR+1ar3eG8MaliMhvFEa29ByXPUecdI1OohuPVLhR/G42OZKKltRL +Ca/uNLLTMkyA/rBue2xwyaAWG5K4EEAIk5cjiB+UeLdfYklNKnFCaCIGSzteO2g25S5 NmVTZtbrDH0diPfZfYYSRP3HkRNl3XTvH1TwajaZmQqNyxY/Dd81VMY2ebVaN8Db2zJu kY5sr0gjs6L4UUV2WRfxucQmH6hsYoyXaRJC101heOQoVgu0UIJZtgpK53ZOAcPYVCTO CL04oRguOAF6Dm29cTbKVCQ456DPapONN9prIRZBFgY3MYUqdpaLAXWR0Em9UHqrHnvW c09A== 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; bh=NvErLiPb7Dhi68E8otsA18THd2lbB+9b3/NhcG854Xk=; b=Dc/1yiY7n1BU4dk2Fknl1TG/fFuWjUH54qbzz4HGMflLyorPOY0wfvaAL8w/JdMAnG VmbFEUI5csKh1fp4iReIJqx8HXxOz8AdoZsSeCafptZJR34290BnJme6otlqqfdBgTw0 eE3hhhWalmxKPktmCzB83aFJe3NmLaLveN+/sqKaZAxkahnR1UFZA3Kj06Zhw4Ckkrs8 8fbUTNp8RfMV/0phVfR/shpKvAwOGrGaiv1MVXIcBxx/o9hdb8fTWHZe+b0k7UcYrCzF M/A5qi4bZVSp+sdZVrsZBhiHfFAskDzu/PTmI5RXObgGnZVK4PEQVdd+z17JOaYpM9YY 6MIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=J3rqMQ+O; 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 z10-v6si9831592pgv.487.2018.10.02.06.13.53; Tue, 02 Oct 2018 06:14:08 -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=J3rqMQ+O; 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 S1727854AbeJBT4o (ORCPT + 99 others); Tue, 2 Oct 2018 15:56:44 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43295 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727975AbeJBT4M (ORCPT ); Tue, 2 Oct 2018 15:56:12 -0400 Received: by mail-wr1-f66.google.com with SMTP id n1-v6so2160599wrt.10 for ; Tue, 02 Oct 2018 06:12:54 -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=NvErLiPb7Dhi68E8otsA18THd2lbB+9b3/NhcG854Xk=; b=J3rqMQ+OwoWESxRlNUNZvjq3C/i5394uPASFBYI9muB/L1ZiyOZBCro1+FKtx6blgw Zf3QR0zbR9aBLw8k94HJn2BihJomkAwGXZ6D3IccQan79jH4+JXMjrtrO30iOwbiwlL7 ZXwh97DJrxJryJEPEhuLlgAGLLAKtiHeczVtcczOfqs5HYQ7W2vG5CxdrOSeUx2uSvN5 GAAUamfcPXwAaP0TYFJuhfKsE1NhlhzkhRgg8V0uSoEfQtqHCiPnIouALNbppfaPkHjL VYO3WaSNSHcsFRl7xSVGvwVKBnyNE6GtDLcbcOxwj/EAXF0Z2usZxGp1Hq2AoDKtY0gx DxAA== 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=NvErLiPb7Dhi68E8otsA18THd2lbB+9b3/NhcG854Xk=; b=CaIm3DqY65P/iQMcxfkLBlWenRLXVd4MVzm2HhzqROwvumxDCcf6Q2Ms1yEQAAgc8G nUqj/MrNK4B1KRDzmSaeO2P/aB5HI1/5kEIMmcJ9hlELsV2qpnkiTl2N/rX2u3+ggbR4 +VObYVAu5M3aCptROXEHoZX+lcOHrmkl5Bgxmbu3xDoU3GPV3tnTggkfFKe3VO9bAbwc 56t03XffuJomJhn0ZJv0gY5nrw4Go9FLxDwPvG27E/kjw/HpEX4gGZ+31iHOdmJuLFn7 I5YaEd4A/yxjeRP5V1xxqr1AuabKAmnB48mMDYGGEUaXfKXtiQbN8+gRkZkj8xoGgcQ9 iXTQ== X-Gm-Message-State: ABuFfojt4kqIakYuEDd4zytXBIM+dPsqk0bgtU1D24VARCwEFjibyY8T Med/QMzTogat8QfifsatomNtMQ== X-Received: by 2002:a5d:4101:: with SMTP id l1-v6mr6433311wrp.45.1538485973338; Tue, 02 Oct 2018 06:12:53 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id v10-v6sm17458681wrp.0.2018.10.02.06.12.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 06:12:52 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , 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 , Luc Van Oostenryck , Andrey Konovalov Subject: [PATCH v7 5/8] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Tue, 2 Oct 2018 15:12:40 +0200 Message-Id: <978d6bcda7f6cc9420d77b1155d54300e73a634d.1538485901.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-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.605.g01d371f741-goog