Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1172468imu; Fri, 9 Nov 2018 12:07:38 -0800 (PST) X-Google-Smtp-Source: AJdET5c8o1JXaK0xD4D5MAniDNPhfEJw0qN37rtfF4GGvMkmq7vWBENgLlA5gUDkY0AWPJS0tAPu X-Received: by 2002:a17:902:5a43:: with SMTP id f3-v6mr10303674plm.57.1541794058393; Fri, 09 Nov 2018 12:07:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541794058; cv=none; d=google.com; s=arc-20160816; b=W7BU5vtVvPsjXVYQZV7HYWPKgv12UttiAw0mUtvGoFUhcKKDl8ZmSJttY2qwn9Dpc9 fbKRLL7wfP7+02Zafnd/pWl/EHOJbOl+rCRudyWuXwLGQx/iw5NaykQuJ1dPujWDxAPH OFd1xFixAzvJ7CyE5mZFPmjx3RuqN/qSVl4zp8VlAT2e2mjqAfRKK1apjMK1AzTu0RJQ xlE1u0u8jSyrf5HrXTuVjZFesAZZk2ecL6L+ey8zA0NrC8Fb1RL91wHKXp1/g06kXpwE RVEB+Ej1pZFPrJ35SU1ZbkttgnsA3VGvsmtTG+DtP4omyJl1ROTFprFXnrvsnEDwhPd7 w/VA== 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=xUFwZLkG3322nZXRMsXrrVbQjUnjyTIpP7ff0qsSub8=; b=jtd/8JVbZC9EFogQoZbUZojthe/yGYPKk4K28ZZIXuSlGGSlVGrJ+LUC89Q4ck8qHJ 7xNcdURLRdQ/RY2K+lzO7kuo2BOv3VPIyKan6nO7dH0yVJlF693dj5Bl7q2ePjZDA/2f 1kBKDuO8iub1rRouYp+BO63iDH4sOYvxDTddH9i3suss8fHAOWz+KPve9WcZrPHBAxbM uJAA2GFjBfVz26Y74ZIQW7NIuEKW8lOqF2NuZ83RNnHijMzhnDKLrtVy5ci8AG7gX1VU xTWgxqwZNtZ9Hrw4THZOhhpVJ4ImuwKWiRUKGttSrj0ji0fvQT9T9cJjUickwo2ULhaw XemA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GTNTcHks; 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 z14-v6si7737104pge.225.2018.11.09.12.07.16; Fri, 09 Nov 2018 12:07:38 -0800 (PST) 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=GTNTcHks; 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 S1726574AbeKJFtB (ORCPT + 99 others); Sat, 10 Nov 2018 00:49:01 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:37947 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbeKJFtB (ORCPT ); Sat, 10 Nov 2018 00:49:01 -0500 Received: by mail-ot1-f67.google.com with SMTP id f24so2751691otl.5 for ; Fri, 09 Nov 2018 12:06:54 -0800 (PST) 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=xUFwZLkG3322nZXRMsXrrVbQjUnjyTIpP7ff0qsSub8=; b=GTNTcHksHHTi8ChoQnEk787Gxg5f3rdjV0lM9oXCRRb0rfVz+qNlUbWRYvEIMh3xEE uATjNn3RlQ/XC5WcxLHS6B8WKTbk91pWdkWd1XKBq2Xhg1TqH+Ax2VK9Ez8G+Y+vdKcf eneJ7pWbt+Gt7R6rU1WzX4VmlbVISw7a1htrwzxRiGiRH7o3lAhUhBuP10AzBQsz6jS9 9UHg+TLVnRv12bttP2FIQhdYfDw3Qz9SWyesREXejsWqczM0wVK/f37qF82amtubknRw P0cTbT6frnRjiLkottKRnsezXmCDNpKJVwx3oirzBLYyb5Yyi50VDe8iHfCK2/rB3NGR VFYQ== 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=xUFwZLkG3322nZXRMsXrrVbQjUnjyTIpP7ff0qsSub8=; b=nF/B+ys7vhiyW4UXbXY59SfrB2l1V4Y/iqm0cnMfmXndMYCHBXiZgLsiW6xaRe67SJ x4fxDgGs4db5FkE3BJyArhgOS5ZoJa2J7inMGCQ0U43kugjGzxuWS8CHzWWQox6AdzYB O/+xlGfrqothBGRdcR8kOBCfzdx6/p1wcWVPe1h+gMNF1KkTfrFw3adcJTbTLrj6Xg// ZLsRGjK7co3SRWTgAF+EMeFTfNL+aNDCky/B4mdXGM/cyCE2QaEZlWEbW6lYqHJRQYAl MAUno8/I1vaL226jcvhC0YveW2C/Uxowg5LxoVwjmXy7mU6hACsYlLgo1Y94uoEPhj0q 6kkQ== X-Gm-Message-State: AGRZ1gK6u9FO3nG7SNAo11jt+BvZFqeVv2ed5SwA1tlbh/7ED3zu+Q+B lpDhmVfj7UN5XrHhF71Iv8JAopfJxuiEKiVjR9nIpg== X-Received: by 2002:a9d:460e:: with SMTP id y14mr6444829ote.198.1541794013885; Fri, 09 Nov 2018 12:06:53 -0800 (PST) MIME-Version: 1.0 References: <5be58a6e.w0IbLdKsiRknTygq%lkp@intel.com> In-Reply-To: <5be58a6e.w0IbLdKsiRknTygq%lkp@intel.com> From: Jann Horn Date: Fri, 9 Nov 2018 21:06:27 +0100 Message-ID: Subject: Re: afaef01c00 ("x86/entry: Add STACKLEAK erasing the kernel stack .."): double fault: 0000 [#1] To: alex.popov@linux.com, Andy Lutomirski , Kees Cook , Ingo Molnar , Thomas Gleixner Cc: lkp@01.org, lkp@intel.com, Kernel Hardening , linux-doc@vger.kernel.org, kernel list , Dave Hansen 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 +Andy, Thomas, Ingo On Fri, Nov 9, 2018 at 2:24 PM kernel test robot wrote: > 0day kernel testing robot got the below dmesg and the first bad commit is > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > > commit afaef01c001537fa97a25092d7f54d764dc7d8c1 > Author: Alexander Popov > AuthorDate: Fri Aug 17 01:16:58 2018 +0300 > Commit: Kees Cook > CommitDate: Tue Sep 4 10:35:47 2018 -0700 > > x86/entry: Add STACKLEAK erasing the kernel stack at the end of syscalls [...] > [ 127.808225] double fault: 0000 [#1] > [ 127.808695] CPU: 0 PID: 414 Comm: trinity-main Tainted: G T 4.19.0-rc2-00001-gafaef01 #1 > [ 127.809799] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 > [ 127.810760] RIP: 0010:ftrace_ops_test+0x27/0xa0 > [ 127.811289] Code: eb 9a 90 41 54 55 49 89 f4 53 48 89 d3 48 89 fd 48 81 ec b0 00 00 00 65 48 8b 04 25 28 00 00 00 48 89 84 24 a8 00 00 00 31 c0 54 df ff ff 48 85 db 74 57 e8 4a df ff ff 48 8b 85 d0 00 00 00 > [ 127.813385] RSP: 0018:fffffe0000001fb8 EFLAGS: 00010046 [...] > [ 127.819762] CR2: fffffe0000001fa8 CR3: 000000001579a000 CR4: 00000000000006b0 [...] > [ 127.822234] Call Trace: > [ 127.822530] > [ 127.822914] ? __ia32_sys_rseq+0x2f0/0x2f0 > [ 127.823395] ftrace_ops_list_func+0xa5/0x1b0 > [ 127.823922] ftrace_call+0x5/0x34 > [ 127.824318] ? stackleak_erase+0x5/0xf0 > [ 127.824789] ? stackleak_erase+0x43/0xf0 > [ 127.825260] stackleak_erase+0x5/0xf0 > [ 127.825699] syscall_return_via_sysret+0x61/0x81 > [ 127.826238] WARNING: stack recursion on stack type 4 > [ 127.826243] WARNING: can't dereference registers at (____ptrval____) for ip syscall_return_via_sysret+0x61/0x81 > [ 127.826246] > [ 127.828342] ---[ end trace e9f96d3f45575499 ]--- > [ 127.828911] RIP: 0010:ftrace_ops_test+0x27/0xa0 CR2: fffffe0000001fa8, RSP: 0018:fffffe0000001fb8; this is a pagefault on the stack. fffffe0000000000 is CPU_ENTRY_AREA_RO_IDT; fffffe0000001000 is CPU_ENTRY_AREA_PER_CPU; so fffffe0000002000 is the page with the entry stack for cpu 0, and you overflowed from that into the readonly gdt at fffffe0000001000, which doubles as a guard page for the entry stack: struct cpu_entry_area { char gdt[PAGE_SIZE]; /* * The GDT is just below entry_stack and thus serves (on x86_64) as * a a read-only guard page. */ struct entry_stack_page entry_stack_page; [...] }; In other words: You're calling C code on the entry trampoline stack; this C code can call into ftrace; and the entry trampoline stack isn't big enough for ftrace shenanigans. I think you probably shouldn't be calling C code on the entry stack, but maybe one of the X86 folks has a different opinion?