Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1104686imm; Wed, 17 Oct 2018 13:27:40 -0700 (PDT) X-Google-Smtp-Source: ACcGV62tFcBMaVJMCGASxoAg1s92UM0+H0hhz7kUFIPvWywX+qg4L/4iE+RsIiilOA26VQb73KM+ X-Received: by 2002:a63:c508:: with SMTP id f8-v6mr25927365pgd.412.1539808060873; Wed, 17 Oct 2018 13:27:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539808060; cv=none; d=google.com; s=arc-20160816; b=ItLroqXlKZ1lL2EnJLEveBeu458zVZHsWvBYKJ3Q5wiiVf/pVCAVe5ZFUNo5qnueAP Zv48YCWa1E89VTZmtKNnMBiDofEJwu0gCmeSF2Lhj8T+OX8pwGIjGIiS6IrWzn+x/Iog JbvQrhmc8JUPUuXwAXPIN3f8tOfJVC2nTmpxCnXx2xdEgSWrP7jcjJ/VLJTLJUEKpI3R GyVJEo9r3CN1BR2em20q4BdX4LG2yYf9enT1HDh7iOQ90utOWxoav7B2NGm3HitZtRRw cAwE17s8iet3OzqtkJRxO4swykjrRZvHIzYZlQ+MZIXjZ12BKL4nOSIl4leyW1YFzLbi roEg== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature; bh=Pr6NILnK9XPPFR1l7yWWQR1rB4C+P+FS3n0AEKO7BDc=; b=npDTDySriQks/S+Jj0Fdk3xzTD/CwjTCL3gRqFRgDiIGXEtaQzQMBpt7US1uJI0qg6 wlyx+Sf2zKvimHUX9+3F3KVXQkVtOL8m2QqsNtJPPJ8k6Zfma3icSlGZXJT98u/TwYNE zxEBDydPl1mQi2TLNjXbatK07bXP3WitL1DTSdYvQ3Wtq4dnZvBGisdstADy1g4HNzbm jeUh03vIESdXwr56Jot4Z6xpQfNcgMLRwPVVX4H95bZ6wtXnlUUe7xp6HR3p53g1gCK8 DYh7WKl/fhU+SW2ziSaDmrXPuvBz2AEibZnkWMxsCX8nBJkw1jlWA7BY8zO2rXobZrpM 9tew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jFTSmNWc; 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 16-v6si21679696pfc.21.2018.10.17.13.27.25; Wed, 17 Oct 2018 13:27:40 -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=jFTSmNWc; 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 S1727196AbeJREXF (ORCPT + 99 others); Thu, 18 Oct 2018 00:23:05 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:46138 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbeJREXE (ORCPT ); Thu, 18 Oct 2018 00:23:04 -0400 Received: by mail-vs1-f68.google.com with SMTP id i10so21606816vsm.13 for ; Wed, 17 Oct 2018 13:25:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Pr6NILnK9XPPFR1l7yWWQR1rB4C+P+FS3n0AEKO7BDc=; b=jFTSmNWcTSIZZDas/tokxDkKeXwVqvdP8rJM+77xs9AZTjaexvX2dUIPs4xLjjDKSh +AX49Tw5r5ZMagEjB+V1pfcaOmg6w3YkqkQBLEdmYe4d2FLS+GJIOijnGYVNW4ZZN9IH D5/on1OvnJNyMlxm/whqMRxocDIYosAk7twGiO5umyoKuNbWwvWCZX+pp4hFO0Qngwd7 XiTus8y3yRkeJfOEbw0sivgKk4taWzRfcy2c3xSwlgYHuXTyvM2m9+30YrG7K7/wdu8P PnQDiHV8yTFHJig2dpbV0uzA2UEosH7yC30zsllsNGmYHp1pwnjuLsBDbttR6+kvNVs6 sTaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Pr6NILnK9XPPFR1l7yWWQR1rB4C+P+FS3n0AEKO7BDc=; b=qLC2pR5/9//cX1XwEHCShxe+AJz8ueXV5616/opWLFJ47VxKqQcoU8Hyq1Xtl0mZOL enLuKAISmRPTwQPCkDhcn1M17LwxYjzrhZM4WLfacLkCUATs8wqzCZF1ifMV6BL+Z+1O 3DSLKapWPy5NN+9GDrZ0YRqTcomQ/FKPQLZdSP9kk+oQWlQHkg0drfdSPf50B7L7gfqE oU6OFu9HAMpW+bZuuDnEewDEjpjldW7VbRDSOkctfgS/ASbj7yuUip7wHWcwepNdU6h7 GLUisBom10jEsZ5P9d1BAwSznAnntckWpaqrBTs8hH8APgltfzy8JV4nwQJ8g9ZuwhaN izTg== X-Gm-Message-State: ABuFfojU48iqC8hujdb4N4kUteOVb92okPkPFX0T4Xd1iHfwhdVMSNkb ot4MVlhN9MHLR3Pw/3i9gtbj2RPIBg/3lZuCpHbKGA== X-Received: by 2002:a67:3f94:: with SMTP id q20mr11298747vsi.1.1539807942636; Wed, 17 Oct 2018 13:25:42 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1f:c284:0:0:0:0:0 with HTTP; Wed, 17 Oct 2018 13:25:42 -0700 (PDT) In-Reply-To: References: From: Evgenii Stepanov Date: Wed, 17 Oct 2018 13:25:42 -0700 Message-ID: Subject: Re: [PATCH v7 0/8] arm64: untag user pointers passed to the kernel To: Andrey Konovalov Cc: Vincenzo Frascino , 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 , "open list:DOCUMENTATION" , Linux Memory Management List , linux-arch , "open list:KERNEL SELFTEST FRAMEWORK" , LKML , Chintan Pandya , Jacob Bramley , Ruben Ayrapetyan , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Luc Van Oostenryck Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 17, 2018 at 7:20 AM, Andrey Konovalov w= rote: > On Wed, Oct 17, 2018 at 4:06 PM, Vincenzo Frascino > wrote: >> Hi Andrey, >> I have been thinking a bit lately on how to address the problem of user = tagged pointers passed to the kernel through syscalls, and IMHO probably th= e best way we have to catch them all and make sure that the approach is mai= ntainable in the long term is to introduce shims that tag/untag the pointer= s passed to the kernel. >> >> In details, what I am proposing can live either in userspace (preferred = solution so that we do not have to relax the ABI) or in kernel space and ca= n be summarized as follows: >> - A shim is specific to a syscall and is called by the libc when it nee= ds to invoke the respective syscall. >> - It is required only if the syscall accepts pointers. >> - It saves the tags of a pointers passed to the syscall in memory (same= approach if the we are passing a struct that contains pointers to the kern= el, with the difference that all the tags of the pointers in the struct nee= d to be saved singularly) >> - Untags the pointers >> - Invokes the syscall >> - Retags the pointers with the tags stored in memory >> - Returns >> >> What do you think? > > Hi Vincenzo, > > If I correctly understand what you are proposing, I'm not sure if that > would work with the countless number of different ioctl calls. For > example when an ioctl accepts a struct with a bunch of pointer fields. > In this case a shim like the one you propose can't live in userspace, > since libc doesn't know about the interface of all ioctls, so it can't > know which fields to untag. The kernel knows about those interfaces > (since the kernel implements them), but then we would need a custom > shim for each ioctl variation, which doesn't seem practical. The current patchset handles majority of pointers in a just a few common places, like copy_from_user. Userspace shims will need to untag & retag all pointer arguments - we are looking at hundreds if not thousands of shims. They will also be located in a different code base from the syscall / ioctl implementations, which would make them impossible to keep up to date.