Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7796626imm; Thu, 28 Jun 2018 09:23:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIePMSziaMT0tB2JgIce4I5b0PipVX78bQjlLiAJ/dz4xzuzpjoGIjj+2PUs9eVXFqNoATY X-Received: by 2002:a63:7d7:: with SMTP id 206-v6mr9361695pgh.137.1530203033417; Thu, 28 Jun 2018 09:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530203033; cv=none; d=google.com; s=arc-20160816; b=ybELqR5QqToqbAqD9r/MZUgSaWGh2cgE59/yKTCyosFLEp5XVSaZReIeo0Uw4ch0sa U7/iv8wmrSSK12BTcyGpE3jGU0NLa6KUOS547lhivH86VwGhuEnA5UMthCEtojw/pFHv RG79++5po6jPauGoJvX+pQ0UPf5IAGD8uo/jo970YbpjCBKuw2WRDx9RusypZD9mNEsm 374XHGSjzcpwh7wYwqOqBmXvwADy+cK/4kiwe6nYokredpb+Y1U8YqzKSPo+DQayOf4M 3CekqtIgm4orFkfmdlVPoi8j0JDvaDUNb7zLwEP1tgmIgJDzLmyTSUX6vqm9iRrdsSty iGQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=1JS8M5+WHZ4q9lqry4nTCR0zThe+sGjPnruBV6R0+5Q=; b=NJnkktcYaJ34/a6dkRvtRayY5It9gVpMXs2RvgMx2+Tiuuv69G2bcuNG+m/PNNhoMv EONRgCcWPdWPjwVFYPbtDNhTBSHrvHsn+d3Xs5JM46Ndfh5ccg84RGAru4fIbJbGz1id IqQCQLod9sz6mcX3Js1z1puJzPA/4O6GG0qAauEqSVRPx3++Sy+jKh8GrQo2DBvX6tDu 10JSeSRGgHfSHTpBuvcY2vD1fhSKMRe2dwOm+BaLdr0Flohl9/vxsSg7UAdZy7yTcxxA j0AzaDQf4XWHM5Vhn9dZUpff4+iSIZi08z1M5lyttVRLKaSpybO8+j/CpcD1CPNv5fBF k6Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=by2hPx6r; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 62-v6si5041861pfg.224.2018.06.28.09.23.38; Thu, 28 Jun 2018 09:23:53 -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=@gmail.com header.s=20161025 header.b=by2hPx6r; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753412AbeF1KqV (ORCPT + 99 others); Thu, 28 Jun 2018 06:46:21 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:33055 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753389AbeF1KqP (ORCPT ); Thu, 28 Jun 2018 06:46:15 -0400 Received: by mail-ed1-f67.google.com with SMTP id l23-v6so4887011edq.0; Thu, 28 Jun 2018 03:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1JS8M5+WHZ4q9lqry4nTCR0zThe+sGjPnruBV6R0+5Q=; b=by2hPx6rXcfMwJ5vI3bwiCxF8qRFmLT4mXXGfAYWU3Yfr6xyHRN9C5JTTvxZhU1pAQ siW4nYflexTY08sL9F/m0sCjahiMHHs3iAgToXUiDWO65tsFT0GBd1jw59PemaUS9p8B gy/+u+LaOfSHpSHTM3H44ez7ZfAwGToqx04nb8lTLAG3imCzWZlO8Bl+dueSKsQ/nv/s 2e/QzhQfshy2rvQsrbGnJqASULLg/79axf+sh9GdJoJ3vexIgr16CUrM0NZen7eVs4Nf 0KePLpEjQOfusfynR/8Tgk3O6fG6lwN1swhJ2m/TbXCoi/6nsGhAOcwSgXqHdeHTbopY f8IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1JS8M5+WHZ4q9lqry4nTCR0zThe+sGjPnruBV6R0+5Q=; b=UhpQEigFc79uOKfaJPxuQ8dfVSXL/zgihO1IGZ5OlY9tZFRVoHUG8Nl4z4AzfzXO7V Fgy3hoLn4RPHP8T5Y6LYvqSLpyp7FTOe8hr0m9CC+x7dPQEPUiyGOWTPhkS9fU1CQEtW HAszd7i8jabnfbvBQvGWvGSyYDEuTXevXM4RYAAQkc1PL57qaRK4KrxTo0VqfVJN2SzD rv4b9f9nJ9PPflhoz0gHnwmDy6bKLBJAraouhFDYs65CXXQ2VZ6btWNC6rkl626tzIo0 fzuTh5VMS4RW2GD7b6bJIVso6S/sAqiBzS+a7QSpOr6sLFs6vopUQUE59M51Pag5Lh4r 6jrg== X-Gm-Message-State: APt69E2DVlQgnbW82kpevOy8ihE4cr08TigY95eqA0771vbkVWgXQ3sX y4F3c6pm0G0N62psALb41skmQijY X-Received: by 2002:a50:b0c2:: with SMTP id j60-v6mr9198296edd.188.1530182773883; Thu, 28 Jun 2018 03:46:13 -0700 (PDT) Received: from ltop.local ([2a02:a03f:40dc:3d00:cc54:7de1:e161:def7]) by smtp.gmail.com with ESMTPSA id p30-v6sm3703882edc.5.2018.06.28.03.46.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 03:46:13 -0700 (PDT) Date: Thu, 28 Jun 2018 12:46:11 +0200 From: Luc Van Oostenryck To: Catalin Marinas Cc: Mark Rutland , Kate Stewart , "linux-doc@vger.kernel.org" , Will Deacon , Kostya Serebryany , "linux-kselftest@vger.kernel.org" , Chintan Pandya , Shuah Khan , Ingo Molnar , "linux-arch@vger.kernel.org" , Jacob Bramley , Dmitry Vyukov , Evgeniy Stepanov , Kees Cook , Ruben Ayrapetyan , Andrey Konovalov , Lee Smith , Al Viro , nd , Linux ARM , Linux Memory Management List , Greg Kroah-Hartman , LKML , Ramana Radhakrishnan , Andrew Morton , Robin Murphy , "Kirill A . Shutemov" Subject: Re: [PATCH v4 0/7] arm64: untag user pointers passed to the kernel Message-ID: <20180628104610.czsnq4w3lfhxrn53@ltop.local> References: <20180626172900.ufclp2pfrhwkxjco@armageddon.cambridge.arm.com> <0cef1643-a523-98e7-95e2-9ec595137642@arm.com> <20180627171757.amucnh5znld45cpc@armageddon.cambridge.arm.com> <20180628061758.j6bytsaj5jk4aocg@ltop.local> <20180628102741.vk6vphfinlj3lvhv@armageddon.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180628102741.vk6vphfinlj3lvhv@armageddon.cambridge.arm.com> User-Agent: NeoMutt/20180622 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 28, 2018 at 11:27:42AM +0100, Catalin Marinas wrote: > On Thu, Jun 28, 2018 at 08:17:59AM +0200, Luc Van Oostenryck wrote: > > On Wed, Jun 27, 2018 at 06:17:58PM +0100, Catalin Marinas wrote: > > > sparse is indeed an option. The current implementation doesn't warn on > > > an explicit cast from (void __user *) to (unsigned long) since that's a > > > valid thing in the kernel. I couldn't figure out if there's any other > > > __attribute__ that could be used to warn of such conversion. > > > > sparse doesn't have such attribute but would an new option that would warn > > on such cast be a solution for your case? > > I can't tell for sure whether such sparse option would be the full > solution but detecting explicit __user pointer casts to long is a good > starting point. So far this patchset pretty much relies on detecting > a syscall failure and trying to figure out why, patching the kernel. It > doesn't really scale. OK, I'll add such an option this evening. > As a side note, we have cases in the user-kernel ABI where the user > address type is "unsigned long": mmap() and friends. My feedback on an > early version of this patchset was to always require untagged pointers > coming from user space on such syscalls, so no need for explicit > untagging. Mmmm yes. I tend to favor a sort of opposite approach. When we have an address that must not be dereferenced as-such (and sometimes when the address can be from both __user & __kernel space) I prefer to use a ulong which will force the use of the required operation before being able to do any sort of dereferencing and this won't need horrible casts with __force (it, of course, all depends on the full context). -- Luc