Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp725840imm; Wed, 17 Oct 2018 07:23:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV61AWJ2GEmezFz7ajdxx3NqLnsYuw4DHWaVRSXaoQ+jB6FuIqCBM2lU1THV8yjVrhSuSmMzT X-Received: by 2002:a62:ed04:: with SMTP id u4-v6mr27264772pfh.2.1539786229536; Wed, 17 Oct 2018 07:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539786229; cv=none; d=google.com; s=arc-20160816; b=lDHVb/6u4V/O+wggm3X+epHgdobar03eUNVW63PPVQqRoKRLVVTSXCyL12xzwcCb69 HZNA2c97KZ94p7GOBeIMsKlInzEmRqOegIssYQEBHxlFO6tKBR1Mo8OThB0T2G1TOuPZ 8okQk8u9DsLPAjiE48Om/BZVpfbKj68wrKjLWUcW+0M67dc5ffsvgQubKwi5HEM43Dry hYSb9OSps0W4yYcQPc3evPx6ETHBUuW+JBiN4wyPovocTYz3N31fbhN9Buy/Js16+jvE CFUWVTkkUiGLGOe+GeaS84MEHuRdI3im8Y9XVTiZcMOtAs60YC/Oc02+VsvZumsTpjPQ 0H2w== 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=KPdp+rW27wHQyFO6nfUOPLD9Kud1YSjqrG6RP/U4vO4=; b=Qfp2l63YfRGfoyvBZBPgU1LhTlm6dRxAdlRCswzEjOUawbVguCup0tLfLvWzuvmtR5 igpWbVArmUUCZT8G+1oY4QgRhrPizne7zo4xs7c68NiQltf/xqxTCbQSqGvSlc50+heK 2zqEMXggNRhOmHPPwGJ56aU3NyG/+d1387c71Kx2i8NRZljHgJCsQsjVNuzVm7wRzstU oi6AfVw7+lJw7bgx/RY/Hy+lL7h9gdfvOB9lVg0kNO2cmFBT0OCAB88ud5pFDQegGGEl ApwkNk0fL31MpmvVQMkxXy+Cw3NPKPyMqNmwoY8J0pqeOGbCupB4Y8oNAUBM+AiooLlV pwvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pl68ASzF; 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 p6-v6si17012052plk.429.2018.10.17.07.23.32; Wed, 17 Oct 2018 07:23:49 -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=pl68ASzF; 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 S1727605AbeJQWQi (ORCPT + 99 others); Wed, 17 Oct 2018 18:16:38 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:40104 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726727AbeJQWQh (ORCPT ); Wed, 17 Oct 2018 18:16:37 -0400 Received: by mail-io1-f68.google.com with SMTP id w16-v6so18888729iom.7 for ; Wed, 17 Oct 2018 07:20:42 -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=KPdp+rW27wHQyFO6nfUOPLD9Kud1YSjqrG6RP/U4vO4=; b=pl68ASzFVQ+2xtpAA8zTjWi98A1rIKG9CJKpMk/r36jQ01qiPPVVMZePVU0kwz9ZbD p/Gh/hAwsRS4EODiilGDQay0utTHcfNUNBwtaf7jckHnBJdC529id2E/dxYPNZ3FluEk jknc0oKbCw902OVFq6yNx+V5nC5TXvksJsy8TB1tnC/iU4ZxEPl2tuo+lzZzL/hAMCvW 8SRkdMXzCaHy11+nA582qx9/ZCZx/YrKqkIGQVyDDp7forlvZiyCuSxF7FSE95Qoy2/l Ts2mjnPRSUUzmuGjHgQqUKQxTbyZfQF2ew+jLNEpHSD/EJzBmhFxNoqB+yR3cOUmMVg8 X07g== 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=KPdp+rW27wHQyFO6nfUOPLD9Kud1YSjqrG6RP/U4vO4=; b=m2XGCSsqlxMbeirbxlZLCZhDsveVgt6y7uNGi0sSh/MRNUXV3nik7m15xQUcwuBdlR +31SwNpQrWwTEVlpmKhv7Yj/BRZTIxxvkFtys7YWUnizuzVmOSKEP78mPMdYkwj2zfG/ O0vXt4ks+K65kLDv+fM4c095GnEV5Gtegye8crEqZg2cZCQTdia4vE7QdOyPvJhhN+H1 7yGzFukZO6pOf8Qxh6GD3PvKWLGWnqeElwuEz5QacRNa5parTPOCSbvHaYve/HrWbnFI zd1rMVCrgPH1TaTI0Msw2dDBBxgFL9Ur5MrdqIpE27O3js51jE7n8leiNExhPKyykTtE LIcw== X-Gm-Message-State: ABuFfogXNnySW3df87UrYeYOf8L+WBwwMbQ/4PzNmUHl5+xUTKuq1ROl Ijl3f65KtukCWHiWMFg5qBo4KGzlNkb5XGpL/WhnVg== X-Received: by 2002:a6b:93d6:: with SMTP id v205-v6mr16087356iod.192.1539786041605; Wed, 17 Oct 2018 07:20:41 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:3d47:0:0:0:0:0 with HTTP; Wed, 17 Oct 2018 07:20:41 -0700 (PDT) In-Reply-To: References: From: Andrey Konovalov Date: Wed, 17 Oct 2018 16:20:41 +0200 Message-ID: Subject: Re: [PATCH v7 0/8] arm64: untag user pointers passed to the kernel To: Vincenzo Frascino Cc: 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 , Evgeniy Stepanov 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 4:06 PM, Vincenzo Frascino wrote: > Hi Andrey, > I have been thinking a bit lately on how to address the problem of user t= agged pointers passed to the kernel through syscalls, and IMHO probably the= best way we have to catch them all and make sure that the approach is main= tainable in the long term is to introduce shims that tag/untag the pointers= passed to the kernel. > > In details, what I am proposing can live either in userspace (preferred s= olution so that we do not have to relax the ABI) or in kernel space and can= be summarized as follows: > - A shim is specific to a syscall and is called by the libc when it need= s 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 kerne= l, with the difference that all the tags of the pointers in the struct need= 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. Thanks!