From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: ARC-Seal: i=1; a=rsa-sha256; t=1522169875; cv=none; d=google.com; s=arc-20160816; b=ouvuTCJPYyQlqcdnmzME9pRLNFhvnLbcYaLlvxQ+RChsKGvCgXgFPCBN5kTtf0cCU5 RxrJoW40m/RdSF7WSfOU3k260ScQQ0mrMcGkl4rR9fPOCsxTDwqZVf5LzNA6rMuwi1rF tq4GaU85ihd3PE5TvlfFmJpA/mYS3g7mH8e1zfHZO1Em265pQR0kbgZgoHHPfoCFTai1 RAORcQcEiXCLueNon2fuh33n1Fg7YwhR1aFKd9ctyt25BaMhIn6iovKLpSZdiX0dtULn d9SRo6jNMSFO1UrYXk59k2DFK30rmamkO26FDUOfuaoG1U/ATHov86I8JGMfLGOy4CMG eJwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=zLiSxNYCnbZDGOudEgmHw5G2g+Qsz+FQUgsgraVMNdU=; b=Q1wXWajroQDe6mU4Mc6+nwKNQtAJl8RBDcDnnSj0ajDuR6qFfZfdFXgnvVKflwMF6j UKV5JsuCTGtQVndSWGSzW9CfsPpz5pCDwgeky0KccD8Pon4FwRKqULRGP4IdvvYztTkb aCUX/0dtJruR4h2nsklpfPmWI5pQ5wA7ewWFEx3ZGU6Ph5XFRN5I0fDwhQ9i32m3adqP oBR4R1VAW3llPtVRNTEJOKSbgYd5u9/2uTjPV9mm0/KzWD9jsTx5L2z5z5ft3Jm3Wajb A+75BdBbm4HKkiwFOOQVNQNXVave9CSEwCuQpd3LeuC+QP6Etq4SPDJ1fhC4fJo5TUAh EGDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dCo2qWPk; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dCo2qWPk; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Google-Smtp-Source: AIpwx48QI24nLLjNvxbcD2UT2yQZ6pWgReRkH9he5h6cS3juE62VyMrI+6oe5NRpvpUIOW/Duw1EiA== 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 Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan Subject: [RFC PATCH v2 5/6] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Tue, 27 Mar 2018 18:57:41 +0200 Message-Id: <1a761b77620457f3bb57d327343765068cd652eb.1522169685.git.andreyknvl@google.com> X-Mailer: git-send-email 2.17.0.rc0.231.g781580f067-goog In-Reply-To: References: In-Reply-To: References: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1596110798857108837?= X-GMAIL-MSGID: =?utf-8?q?1596110798857108837?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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)) { -- 2.17.0.rc0.231.g781580f067-goog From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on archive.lwn.net X-Spam-Level: X-Spam-Status: No, score=-4.6 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,T_DKIM_INVALID, T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by archive.lwn.net (Postfix) with ESMTP id D98297DD31 for ; Tue, 27 Mar 2018 16:58:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754274AbeC0Q57 (ORCPT ); Tue, 27 Mar 2018 12:57:59 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:46690 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755465AbeC0Q54 (ORCPT ); Tue, 27 Mar 2018 12:57:56 -0400 Received: by mail-wr0-f193.google.com with SMTP id d1so11089082wrj.13 for ; Tue, 27 Mar 2018 09:57:55 -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=zLiSxNYCnbZDGOudEgmHw5G2g+Qsz+FQUgsgraVMNdU=; b=dCo2qWPklBfMRyZnIkK9tXaJjSF8B6r1Aivq6hpI1SeUrHy+/gCVqYqRdIFK/bTpZK +SqF7iWci+OenSDS5EKNUZEMz0A2rivQrzyJgb1zW2Dmnj7VYmNrqb1O2dE5GhDKUBMY Fq+YXUE/fcKFejypRxAbkWfnphhe6NRHU429QjKTrJo8lqStvoes6Kd3F0BwAA4spq9J 4qQkh66OjsJu6XD4BXuUmEbV3yaBW9lDyBBnbaQluS2oiX8tmCKAbZS1oiNVgYw/Gjt5 GhG1Qobn+1ta44btCuOC2jtxyoLjRtFqkA9IQOdPtixLk3cT3jJBYo4HJa93kQvNo5Lg btWA== 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=zLiSxNYCnbZDGOudEgmHw5G2g+Qsz+FQUgsgraVMNdU=; b=pDfHCaQy3Oze/Tchree6muUkXt0xHa9XNSYyzzfUQjGcICnOGeRgGnMmpfSiGNbJ1M g/Es5j9fK6kIdJXZqG35Kb7iyBNnGyjmM/6QAVOXMLmIQh7vFq+3rz8AlgvG147RJ0BE Rik3zsAglOoLNUuiGX11MXWzskx7UWdKDFXd5bM7sW05AXFWxM9wgrQmehokYXJrIqoo pfAEpzDDlH6rzAgwQTRbypSij0AtqabqI2QGVmedFFAnulDYeUzDmdIg22Z2GCvQVrwr YLwg9LLddFIhpRJBjH5MEaC1JlKsypQaR9TAnIiM4laovl3cvQsT5fV3YKdJh1oQQFDs jQcw== X-Gm-Message-State: AElRT7Gkd85n4Pz3XLgZBVzMNT0iDJW1inD73pzg9ifkUQ7oeMuPPE2l CcOnMeVR7c94tWlwjkyak33+Fg== X-Google-Smtp-Source: AIpwx48QI24nLLjNvxbcD2UT2yQZ6pWgReRkH9he5h6cS3juE62VyMrI+6oe5NRpvpUIOW/Duw1EiA== X-Received: by 10.223.225.76 with SMTP id f12mr124682wri.128.1522169874753; Tue, 27 Mar 2018 09:57:54 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id 93sm1622992wrh.46.2018.03.27.09.57.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 09:57:53 -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 Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan Subject: [RFC PATCH v2 5/6] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user Date: Tue, 27 Mar 2018 18:57:41 +0200 Message-Id: <1a761b77620457f3bb57d327343765068cd652eb.1522169685.git.andreyknvl@google.com> X-Mailer: git-send-email 2.17.0.rc0.231.g781580f067-goog In-Reply-To: References: In-Reply-To: References: Sender: linux-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@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 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)) { -- 2.17.0.rc0.231.g781580f067-goog -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 From: andreyknvl@google.com (Andrey Konovalov) Date: Tue, 27 Mar 2018 18:57:41 +0200 Subject: [RFC PATCH v2 5/6] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user In-Reply-To: References: Message-ID: <1a761b77620457f3bb57d327343765068cd652eb.1522169685.git.andreyknvl@google.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.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 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)) { -- 2.17.0.rc0.231.g781580f067-goog