From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F6F9C4646D for ; Tue, 11 Jun 2019 20:07:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 147CB21721 for ; Tue, 11 Jun 2019 20:07:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="i+ihcJfD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405944AbfFKUHS (ORCPT ); Tue, 11 Jun 2019 16:07:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:52182 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405476AbfFKUHS (ORCPT ); Tue, 11 Jun 2019 16:07:18 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5BK5X7D176393; Tue, 11 Jun 2019 20:06:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=chD9BHu2Q8n/vFf6CCiBN6lp1HXxmyrKtdEjtx98SfY=; b=i+ihcJfD+r++tCN09DcxE+9SdhIRXslpbsen1Ly2b/r82XpfipS+cg5oxIFDHr5z/GAU VrRdu7NdT1KOdFyjMhexY6IfvMPY77FUH+FKxtIUXO8d1C0e0tDTPRmvp1FdzV8V7pYX U4IzADiDszYzTuo1y6F4qZFiT2b9u6Cz8QDPrN+6Sqlg39FglRjDj2+y+RKoGD/iKR6m uDqlrJDwwIbHmVtlRXKy/zbwpgKr8Ch3G7MbdDDHDEU1fdVCH38z0MVPNm3oNSiK0LeC adAcFZjzJlLyTbihfu+4rXpoW5PNw7BgFZdrw7mehFHTf2SW6/39ZzEaisuCtPm7xaov 9A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2t04etqfpk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jun 2019 20:06:20 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5BK52LA147470; Tue, 11 Jun 2019 20:06:20 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2t04hyj0wv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jun 2019 20:06:19 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5BK6Df4017807; Tue, 11 Jun 2019 20:06:13 GMT Received: from [10.154.187.61] (/10.154.187.61) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 11 Jun 2019 13:06:13 -0700 Subject: Re: [PATCH v16 03/16] lib, arm64: untag user pointers in strn*_user To: Andrey Konovalov , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: Catalin Marinas , Vincenzo Frascino , Will Deacon , Mark Rutland , Andrew Morton , Greg Kroah-Hartman , Kees Cook , Yishai Hadas , Felix Kuehling , Alexander Deucher , Christian Koenig , Mauro Carvalho Chehab , Jens Wiklander , Alex Williamson , Leon Romanovsky , Luc Van Oostenryck , Dave Martin , enh , Jason Gunthorpe , Christoph Hellwig , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Robin Murphy , Kevin Brodsky , Szabolcs Nagy References: <14f17ef1902aa4f07a39f96879394e718a1f5dc1.1559580831.git.andreyknvl@google.com> From: Khalid Aziz Organization: Oracle Corp Message-ID: Date: Tue, 11 Jun 2019 14:06:09 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <14f17ef1902aa4f07a39f96879394e718a1f5dc1.1559580831.git.andreyknvl@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9284 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906110129 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9284 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906110129 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On 6/3/19 10:55 AM, Andrey Konovalov wrote: > This patch is a part of a series that extends arm64 kernel ABI to allow= to > pass tagged user pointers (with the top byte set to something else othe= r > than 0x00) as syscall arguments. >=20 > 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 w= e > need to handle the case of tagged user addresses separately. >=20 > Untag user pointers passed to these functions. >=20 > Note, that this patch only temporarily untags the pointers to perform > validity checks, but then uses them as is to perform user memory access= es. >=20 > Reviewed-by: Catalin Marinas > Signed-off-by: Andrey Konovalov > --- > lib/strncpy_from_user.c | 3 ++- > lib/strnlen_user.c | 3 ++- > 2 files changed, 4 insertions(+), 2 deletions(-) Looks good. Reviewed-by: Khalid Aziz >=20 > diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c > index 023ba9f3b99f..dccb95af6003 100644 > --- a/lib/strncpy_from_user.c > +++ b/lib/strncpy_from_user.c > @@ -6,6 +6,7 @@ > #include > #include > #include > +#include > =20 > #include > #include > @@ -108,7 +109,7 @@ long strncpy_from_user(char *dst, const char __user= *src, long count) > return 0; > =20 > max_addr =3D user_addr_max(); > - src_addr =3D (unsigned long)src; > + src_addr =3D (unsigned long)untagged_addr(src); > if (likely(src_addr < max_addr)) { > unsigned long max =3D max_addr - src_addr; > long retval; > diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c > index 7f2db3fe311f..28ff554a1be8 100644 > --- a/lib/strnlen_user.c > +++ b/lib/strnlen_user.c > @@ -2,6 +2,7 @@ > #include > #include > #include > +#include > =20 > #include > =20 > @@ -109,7 +110,7 @@ long strnlen_user(const char __user *str, long coun= t) > return 0; > =20 > max_addr =3D user_addr_max(); > - src_addr =3D (unsigned long)str; > + src_addr =3D (unsigned long)untagged_addr(str); > if (likely(src_addr < max_addr)) { > unsigned long max =3D max_addr - src_addr; > long retval; >=20