Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7114496yba; Thu, 2 May 2019 04:37:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwh84QFDWzLnm48zdwZy8CvHgZds6yPwmyhpkzP/VZQC/810c13J58rzg9yGObEtQ176JuY X-Received: by 2002:a65:5c89:: with SMTP id a9mr3505453pgt.334.1556797027230; Thu, 02 May 2019 04:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556797027; cv=none; d=google.com; s=arc-20160816; b=eEzWSvRYykWiDYZ/rOnTnCozVtkPrnwxsQ2X+0xRm5TebiveAtTW/RN0EoUgx09zoR kDogXSfah7xZFpGi/rtZhUKeU33S7GKee5+2Tad4HyMquZq8alZ4Gl+52eK4SJ6qIbbr 69oh0l9cyLXpR0aaHLieAn1qPFwOmUDJNBJs0U9cUCpkAPv641nJs0348HXlh9rHtRDv rduoCdWBVm5hLbjOLYqrFRmG5V9kbEGDB3B+ReYJPgizsoceraCSOGBW4r9rph3cvJZs y+YmM6JXMtXxxTiqX/qNi7S9HLFatYSxP2lsIHT7LqxrfVj7Pfm6f/WXjjbAD5BXvzfu QIIw== 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 :reply-to:in-reply-to:references:mime-version:dkim-signature; bh=j++TiTibQtSVl9YAF3/oqacqYf/6ZNJGN6BZGgzoCww=; b=gtdclIBYgb6QfevGMcd5NOAkHZla+v1SGsnlJG/TUjHRmQrc4rf9YJSDUyBBqzVQ1h ebrMlZoPa2htxM8OqozJAYhyPH5yiwR1ZRXwWcUyIz7gcdm2D8IGHhBObSNX1zn00wWq hLmp5mfHRMPZudkkrywNlvsAL3NN/JkE7hGC2k1vpaD6juZ+16zsme23ihYV8DpW0i/f 8ZITanWPdIdK81PyQlwHDC/Qcj4c/LGLic97gM52yJIP889+gXtK+e1Itbu2vsLu5LUq deBUM4i2Ram7JVGaSIOGWUfUswGWh6HwtEbSr/wk3rn9arQ3Rcjh8brSK1VPWdFHqjuo DAkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ocallahan-org.20150623.gappssmtp.com header.s=20150623 header.b=0H9qZOLd; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si1201339pgf.112.2019.05.02.04.36.51; Thu, 02 May 2019 04:37:07 -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=@ocallahan-org.20150623.gappssmtp.com header.s=20150623 header.b=0H9qZOLd; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726320AbfEBLft (ORCPT + 99 others); Thu, 2 May 2019 07:35:49 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:33776 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726278AbfEBLfs (ORCPT ); Thu, 2 May 2019 07:35:48 -0400 Received: by mail-lf1-f66.google.com with SMTP id j11so1640007lfm.0; Thu, 02 May 2019 04:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ocallahan-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=j++TiTibQtSVl9YAF3/oqacqYf/6ZNJGN6BZGgzoCww=; b=0H9qZOLdO21+HdB9rbdwA4TdkIwgdYm+/OeqS3IwlILWryk4o/i6fMK92cnzjlf5d+ 0OAwzQOkeD28c7YH6eco8BUodMbodQLIvMA9K/+hCj9FFBanIhHsDTxWIaOFko8EKel3 zSFRM58Enni/0sfu1lojb+Rh0349rNJQwgnCVUMe353c38F3CMEFovePsjxDPeRfeIx/ utSiV3/LMYR2Dqu3XV4xeErBtRaiDgc5Sv6BSJuLmXC6Es8cPhdkIirs2LVr0GMugKnW NBPJtLw2jgN5szGLBemMxX5/jwWj73+3M2fiJlRQZpw9YccJDve++TtuuJsE8ML9PRrE NoqA== 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:reply-to :from:date:message-id:subject:to:cc; bh=j++TiTibQtSVl9YAF3/oqacqYf/6ZNJGN6BZGgzoCww=; b=LzL8/o0JZ8WQ/PaA9eYx8Nz886+Ks3cXE67uAJEtk51k96rwG38RpQ/lvsfFYuFlaA TrjzaPVGxRflPQgqNagU+anIfDO1S2JrrxqOyXGxfFCj1d/OZa8lhN8oUNn/3HVxp4x8 TKKF+ckYezFEDIv0v8jQovfZpjL4Y2OsLmE3LLI/0pQo83i7rP/qX8HKTfKo6QoKRLpy 1hKg9L5drT6T5WlzMARwmrN2V6/Pp70nSsLRpVVtzNb/EmPTPKOqo0YbtUEa16ejKPft 53FQMZ5qPHZKT9U57YxD/rqXoFlhgdbskH7caVMt75P48VXWJHY4eRWCJ5bkt9i6s56L 6PAA== X-Gm-Message-State: APjAAAWwhPUmxxRP/42BqWUBXaJWJIbUUg3GSTJbkmCPx0V3+ct15LNL fVA7Cx/ZQswpkHMWDboT7kiAvinvVt4a/Nj+5Hk= X-Received: by 2002:ac2:5a47:: with SMTP id r7mr1883560lfn.116.1556796946527; Thu, 02 May 2019 04:35:46 -0700 (PDT) MIME-Version: 1.0 References: <1556228754-12996-1-git-send-email-rppt@linux.ibm.com> <1556228754-12996-3-git-send-email-rppt@linux.ibm.com> <20190426083144.GA126896@gmail.com> <20190426095802.GA35515@gmail.com> <20190427084752.GA99668@gmail.com> <20190427104615.GA55518@gmail.com> In-Reply-To: <20190427104615.GA55518@gmail.com> Reply-To: robert@ocallahan.org From: "Robert O'Callahan" Date: Thu, 2 May 2019 23:35:35 +1200 Message-ID: Subject: Re: [RFC PATCH 2/7] x86/sci: add core implementation for system call isolation To: Ingo Molnar Cc: Andy Lutomirski , Mike Rapoport , LKML , Alexandre Chartre , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , James Bottomley , Jonathan Adams , Kees Cook , Paul Turner , Peter Zijlstra , Thomas Gleixner , Linux-MM , LSM List , X86 ML , Linus Torvalds , Peter Zijlstra , Andrew Morton 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 Sat, Apr 27, 2019 at 10:46 PM Ingo Molnar wrote: > - A C language runtime that is a subset of current C syntax and > semantics used in the kernel, and which doesn't allow access outside > of existing objects and thus creates a strictly enforced separation > between memory used for data, and memory used for code and control > flow. > > - This would involve, at minimum: > > - tracking every type and object and its inherent length and valid > access patterns, and never losing track of its type. > > - being a lot more organized about initialization, i.e. no > uninitialized variables/fields. > > - being a lot more strict about type conversions and pointers in > general. > > - ... and a metric ton of other details. Several research groups have tried to do this, and it is very difficult to do. In particular this was almost exactly the goal of C-Cured [1]. Much more recently, there's Microsoft's CheckedC [2] [3], which is less ambitious. Check the references of the latter for lots of relevant work. If anyone really pursues this they should talk directly to researchers who've worked on this, e.g. George Necula; you need to know what *didn't* work well, which is hard to glean from papers. (Academic publishing is broken that way.) One problem with adopting "safe C" or Rust in the kernel is that most of your security mitigations (e.g. KASLR, CFI, other randomizations) probably need to remain in place as long as there is a significant amount of C in the kernel, which means the benefits from eliminating them will be realized very far in the future, if ever, which makes the whole exercise harder to justify. Having said that, I think there's a good case to be made for writing kernel code in Rust, e.g. sketchy drivers. The classes of bugs prevented in Rust are significantly broader than your usual safe-C dialect (e.g. data races). [1] https://web.eecs.umich.edu/~weimerw/p/p477-necula.pdf [2] https://www.microsoft.com/en-us/research/uploads/prod/2019/05/checkedc-post2019.pdf [3] https://github.com/Microsoft/checkedc Rob -- Su ot deraeppa sah dna Rehtaf eht htiw saw hcihw, efil lanrete eht uoy ot mialcorp ew dna, ti ot yfitset dna ti nees evah ew; deraeppa efil eht. Efil fo Drow eht gninrecnoc mialcorp ew siht - dehcuot evah sdnah ruo dna ta dekool evah ew hcihw, seye ruo htiw nees evah ew hcihw, draeh evah ew hcihw, gninnigeb eht morf saw hcihw taht.