Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4524199imm; Tue, 7 Aug 2018 03:04:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdU41md6/e+rZXc4A6h997FY1mxum+9bmO+cEqNpO/BSb06xpU3eASWkP2iFlSmH3mSMLRz X-Received: by 2002:a17:902:b28:: with SMTP id 37-v6mr17157870plq.337.1533636255051; Tue, 07 Aug 2018 03:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533636255; cv=none; d=google.com; s=arc-20160816; b=TQDcbhsJWOT7wwd4cXHJgk4KTbIymZOjBKMY/mt2ycmLA4egCIRWRCrmS+V6d3l230 1jVTNV60l2hQf0rAeYTEE1bcNn+ia4rCqL0/1hY7l0fs9TaEEfki5Sx/z+w94YtXI65V I9xphxK4bznzNIcBPp2F8W+dKQjRuYJozHhPRV6ykOfZUWmbOJgoqsircxv34MoPpJJj VnC7Q0+QrqJDOc6jnrj/DOFKgj+75RIZ+8cNUNtk+00nksJKAOBAv3imM2jNTH0P7wFj 1YqHBeEIkcw9q6GxM5gbMoBlUxg15sNtJX6fADp/knbY+H/LDLIskxYbu9H+TRCfS2DP P3nA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=LG3L7ONXJU/+yBC1ImjBjMAawDLs9B+fSM+nsoC/jaM=; b=Gii7nZa3brO8rrrhSQR+iU4N9s1ER7EZ8tE9l5cKAxBARAX/CgwWwDZuzXuhMMBB3v KmxG5ISk+jLABHSbQ1ml7s2TTm37RTweR7CC+5vhNbftbYEGaDY4LYuVrD1XNf6STSLS mDrEvSgEciTu95EkHIZjnErR+3h7TDBF4yF2DW9xqATOlodNvAwauCIrfE6+EGmRXHRV oztULJcGdnxHgzrbtNOcaNJlvfYhiiPqRWeMFLDnUDDbZPb7XYgRF6+LCBRrCiMBqD6I /qjpNDs9KdeE7k6yAMczsaa/TEvmvKO4RkTW+ZJS6I4+1CEmyqgRuSnB3HgN74n/BYox GHwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="K71Otv/G"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m24-v6si1035377pgl.452.2018.08.07.03.04.00; Tue, 07 Aug 2018 03:04:15 -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=fail header.i=@gmail.com header.s=20161025 header.b="K71Otv/G"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387536AbeHGMQs (ORCPT + 99 others); Tue, 7 Aug 2018 08:16:48 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42969 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727194AbeHGMQr (ORCPT ); Tue, 7 Aug 2018 08:16:47 -0400 Received: by mail-wr1-f65.google.com with SMTP id e7-v6so15158294wrs.9 for ; Tue, 07 Aug 2018 03:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=LG3L7ONXJU/+yBC1ImjBjMAawDLs9B+fSM+nsoC/jaM=; b=K71Otv/GdEnVdiB//Lsv8mDGA0ll3647nPi2Qle7+9u2VjnOQb9bJJ93Q3R2JKmmOV YXB7e2OnafN9b2Ed7IFbxzmK493iCFYT1W1zCfbN0B+bvJ55enlUYbv2YkVj2wIS8PcQ ERSa4ALOLfkTQENJSGxPdvNfNDhYv4X06xgq1IJWQHOx8DvcHvFaocNC6QhwxAdzEN31 lvUMGpI1MS1LKrFEEpod19GFsTqpA5JHOFMOrrOgUUd0KCTauf8CkJh5viknxUhi+Vrf 0sVD7/0lp9DMh1XhVWtYfZq0cISf07pX4tCypydEMlmgnbEEux+kl5k13zyIpuYvS2R/ cXcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=LG3L7ONXJU/+yBC1ImjBjMAawDLs9B+fSM+nsoC/jaM=; b=kaqAEFg8MryfSdVUo7d7MIe2s0KLpKxr2gMyMT+x6f6zNg6tesTNvM9rf7UvyUeBtL p+BSzyjeoL+V5W1fPer0UXyHbnI3P/pssAFhBzVboJf3G7WBYhvVuWleMguv4qaWkAC5 xZ1dU9Kox14er+9D2DVTjWnevRcBygTRBo3+dbfaBrRCFndBU8K39RmLrPUl/h8HVFpc fo+2ScwU/PsWV295yJM5Imc/Lq9x6ObTg5T3MOWvKlIkiSqUORfYla/uelI2Yvuh3/Wk MtdF2f6vAaHPng+7jSZFYKa50iI42obHh4fP4jmXWqqKb9wp2xpYPRGcBKcF+1y4U0a/ V3qA== X-Gm-Message-State: AOUpUlF+MWAH++G27TZxV0HQULk79WuJBFrLExnjrGuADfA+teQjlaez XaQUsVxTEUmi7LrERJ6sIuXFXWgX X-Received: by 2002:adf:fb81:: with SMTP id a1-v6mr11726420wrr.219.1533636192245; Tue, 07 Aug 2018 03:03:12 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id f8-v6sm1363545wrj.9.2018.08.07.03.03.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Aug 2018 03:03:11 -0700 (PDT) Date: Tue, 7 Aug 2018 12:03:09 +0200 From: Ingo Molnar To: Andy Lutomirski Cc: Jann Horn , Kees Cook , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org, Andy Lutomirski , dvyukov@google.com Subject: Re: [RFC PATCH 1/2] x86: WARN() when uaccess helpers fault on kernel addresses Message-ID: <20180807100309.GB12200@gmail.com> References: <20180807012257.20157-1-jannh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Andy Lutomirski wrote: > > On Aug 6, 2018, at 6:22 PM, Jann Horn wrote: > > > > There have been multiple kernel vulnerabilities that permitted userspace to > > pass completely unchecked pointers through to userspace accessors: > > > > - the waitid() bug - commit 96ca579a1ecc ("waitid(): Add missing > > access_ok() checks") > > - the sg/bsg read/write APIs > > - the infiniband read/write APIs > > > > These don't happen all that often, but when they do happen, it is hard to > > test for them properly; and it is probably also hard to discover them with > > fuzzing. Even when an unmapped kernel address is supplied to such buggy > > code, it just returns -EFAULT instead of doing a proper BUG() or at least > > WARN(). > > > > This patch attempts to make such misbehaving code a bit more visible by > > WARN()ing in the pagefault handler code when a userspace accessor causes > > #PF on a kernel address and the current context isn't whitelisted. > > I like this a lot, and, in fact, I once wrote a patch to do something similar. It was before > the fancy extable code, though, so it was a mess. Here are some thoughts: Agreed - please move this series beyond the RFC phase. > - It should be three patches. One patch to add the _UA annotations, one to improve the info > passes to the handlers, and one to change behavior. > > - You should pass the vector, the error code, and the address to the handler. > > - The uaccess handler should IMO WARN if the vector is anything other than #PF (which mainly > means warning if it’s #GP). I think it should pr_emerg() and return false if the vector is > #PF and the address is too high. > > - Arguably most non-uaccess fixups should at least warn for anything other than #GP and #UD. Ack. Thanks, Ingo