Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3716427yba; Mon, 29 Apr 2019 07:24:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7Ri5p/AfD/kmMUJlBgoNsW9VQ5P0S6qbk6AJvHqpPwr5bGgOux6WvhWl4QWWRhPeoTtxP X-Received: by 2002:a65:4342:: with SMTP id k2mr23008736pgq.178.1556547852568; Mon, 29 Apr 2019 07:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556547852; cv=none; d=google.com; s=arc-20160816; b=V4ZRcBagMVxw1ka3bzbN4N66DF7VH68xpsD0Pb+uBasGE6WhTNJtcM7hok76gwSRZ+ gT+XxXAbzS3BRFVBc3wDsOCUYuWST/cRm2z+Wbvt9PKtPP3YNJoBW1msuytpJu8TAcdD axCC32Cbiuv1n57rpicw0F05qmU4qVc+MndaOOrNfcEJAJZE196hZIWoVNkVB5YekMrG Kbzej4Z7Qc8BcbYD8yO9i5mtmC/nz6QLAs4fNf7MiG1YD60YF8bFvMrC/AP3RBa8P3QH lyaRr8UCGEavTlvXAIPhjR5OTiNytQ/bscm9COPumqyqXXWfQ25zFwhPCiHYuM+sokMP 8tXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Q2RFfAyrf9RFoM43ktNZPcHmGWgFL8fnuov2nkBPWS8=; b=MMlPzHrRi9Eu8vq0mJRfe7mssRaKQxvGK2xPkrm0tKRww8OVPM7apkKxbGXyiakpIy 8aQWgkKFgYcvK4KJQdGwTLIappggNdjY3kHCO39jNN5q5RshLXBzaC08RYNZSIngkG88 Zg6aSEPTkaSYAQVWUkBcX5QcuNlrVo7beP6wfxH3GkjFoATYKp6blVQMKy8bTxnC/qEC kosX2p/hfei6x2DJ5P71PEew/RL/72wKoAGyUY8VPaFj+KSnyWdlu1H7kITxrAdscBJX Y9VX/zSYElBra7dHrlkDthOFqkRV8QiwmVw33YZiPPdYJAaY3kYoAXoILGh/HrYVXpE0 FpIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nSUn3qna; 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 34si33789057plf.288.2019.04.29.07.23.56; Mon, 29 Apr 2019 07:24:12 -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=nSUn3qna; 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 S1728359AbfD2OWW (ORCPT + 99 others); Mon, 29 Apr 2019 10:22:22 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34167 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728307AbfD2OWV (ORCPT ); Mon, 29 Apr 2019 10:22:21 -0400 Received: by mail-pg1-f194.google.com with SMTP id c13so4261473pgt.1 for ; Mon, 29 Apr 2019 07:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q2RFfAyrf9RFoM43ktNZPcHmGWgFL8fnuov2nkBPWS8=; b=nSUn3qnawAssSs6MaxKqsGt7m2rQuwz8iuV7UDRO4XwagTQcUwQLKJChDfpo2Y42Xk dLm04wkPLwmDDcGlfi33gt+mgTjEgazJ0pWoNgMCBCgvVwv5SPNGO+R0wOTcgS/YyTDI MMCTRBCf6Y5X7Op946XZIErDxOVRLAN1uJUSs6b8aMjiipEdz924r1uFPAVVEONFnBC1 eRjcEW3uL1UMy4VUvg8gNA4Pg7nsW7DCRDuZC0iLpBAnBGkKHCDzwyf3Uq04LayvwlmL Hgpedt4edzE9KmfV/TNfyjqaPwOmLbR2KI1O6u2H+6Cx6SK8d3Pu0MrHeMD38gdpjP27 JeSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q2RFfAyrf9RFoM43ktNZPcHmGWgFL8fnuov2nkBPWS8=; b=kLUVKoJrHTJwqsnlYhR0dLjjsHX0KnYHC2fqZDuy1JvKPx8gytQqM+hJ7L4qKwio0/ KmlOWtujW/Oq4CMYfJwbqglxuoNHK0EFUDVMJKJFgOW0Cq0Oq1TaLzrWZlf1TGPwvrjJ GN0foJ9lXoV6p5HGav3DfIjIUg1TD9l1GjGtvvlW3VdsOVQCkC/3Dlps+7ImTVUtBDdh Na50TUWVQDSjrhD/1IR6bxD/Ohv/BTzDeX8h7FWbDYYt7fSxxBEC8Wg4zVnzFm4MekgK lh+QESMcQDjqnBPYbujBPj+nK1LMvx54UXIaArnwdi18to7jIHrQMiXzxdz2m+cvSVOq HtGw== X-Gm-Message-State: APjAAAVw+ez25I7Zoo5OEjMyiB+NfM1MfCBgF3YZQWgjn9ul4mLk71Hp +OtSCVsB3tUk8NHmYmP2uqajWYqOpmG4x/sKp24ktw== X-Received: by 2002:a62:51c5:: with SMTP id f188mr24041707pfb.239.1556547740003; Mon, 29 Apr 2019 07:22:20 -0700 (PDT) MIME-Version: 1.0 References: <44ad2d0c55dbad449edac23ae46d151a04102a1d.1553093421.git.andreyknvl@google.com> <20190322114357.GC13384@arrakis.emea.arm.com> <20190328141934.38960af0@gandalf.local.home> <20190329103039.GA44339@arrakis.emea.arm.com> <20190426141742.GB54863@arrakis.emea.arm.com> In-Reply-To: <20190426141742.GB54863@arrakis.emea.arm.com> From: Andrey Konovalov Date: Mon, 29 Apr 2019 16:22:08 +0200 Message-ID: Subject: Re: [PATCH v13 04/20] mm, arm64: untag user pointers passed to memory syscalls To: Catalin Marinas Cc: Steven Rostedt , Will Deacon , Mark Rutland , Kees Cook , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Vincenzo Frascino , Eric Dumazet , "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , Peter Zijlstra , Arnaldo Carvalho de Melo , Mauro Carvalho Chehab , Jens Wiklander , Alex Williamson , Linux ARM , Linux Memory Management List , linux-arch , LKML , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Ruben Ayrapetyan , Luc Van Oostenryck , Dave Martin , Kevin Brodsky , Szabolcs Nagy Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 26, 2019 at 4:17 PM Catalin Marinas wrote: > > On Tue, Apr 02, 2019 at 02:47:34PM +0200, Andrey Konovalov wrote: > > On Fri, Mar 29, 2019 at 11:30 AM Catalin Marinas > > wrote: > > > On Thu, Mar 28, 2019 at 02:19:34PM -0400, Steven Rostedt wrote: > > > > On Thu, 28 Mar 2019 19:10:07 +0100 > > > > Andrey Konovalov wrote: > > > > > > > > > > > Signed-off-by: Andrey Konovalov > > > > > > > --- > > > > > > > ipc/shm.c | 2 ++ > > > > > > > mm/madvise.c | 2 ++ > > > > > > > mm/mempolicy.c | 5 +++++ > > > > > > > mm/migrate.c | 1 + > > > > > > > mm/mincore.c | 2 ++ > > > > > > > mm/mlock.c | 5 +++++ > > > > > > > mm/mmap.c | 7 +++++++ > > > > > > > mm/mprotect.c | 1 + > > > > > > > mm/mremap.c | 2 ++ > > > > > > > mm/msync.c | 2 ++ > > > > > > > 10 files changed, 29 insertions(+) > > > > > > > > > > > > I wonder whether it's better to keep these as wrappers in the arm64 > > > > > > code. > > > > > > > > > > I don't think I understand what you propose, could you elaborate? > > > > > > > > I believe Catalin is saying that instead of placing things like: > > > > > > > > @@ -1593,6 +1593,7 @@ SYSCALL_DEFINE3(shmat, int, shmid, char __user *, shmaddr, int, shmflg) > > > > unsigned long ret; > > > > long err; > > > > > > > > + shmaddr = untagged_addr(shmaddr); > > > > > > > > To instead have the shmaddr set to the untagged_addr() before calling > > > > the system call, and passing the untagged addr to the system call, as > > > > that goes through the arm64 architecture specific code first. > > > > > > Indeed. For example, we already have a SYSCALL_DEFINE6(mmap, ...) in > > > arch/arm64/kernel/sys.c, just add the untagging there. We could do > > > something similar for the other syscalls. I don't mind doing this in the > > > generic code but if it's only needed for arm64, I'd rather keep the > > > generic changes to a minimum. > > > > Do I understand correctly, that I'll need to add ksys_ wrappers for > > each of the memory syscalls, and then redefine them in > > arch/arm64/kernel/sys.c with arm64_ prefix, like it is done for the > > personality syscall right now? This will require generic changes as > > well. > > Yes. My aim is to keep the number of untagged_addr() calls in the > generic code to a minimum (rather than just keeping the generic code > changes small). OK, will do in v14 (despite it still being unclear whether we should do untagging here or not). > > -- > Catalin