Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5903247ybc; Wed, 27 Nov 2019 11:21:19 -0800 (PST) X-Google-Smtp-Source: APXvYqx5V8pUmf3MMQVOT48cajXlAClDabRbEoUUat3O/jvCtl6W95R3k0GIpEnfRVwcUATuJEU6 X-Received: by 2002:a17:906:b2d2:: with SMTP id cf18mr7930111ejb.204.1574882478896; Wed, 27 Nov 2019 11:21:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574882478; cv=none; d=google.com; s=arc-20160816; b=MvZtCw7Gma8a9j0eVU0kpPQQonWOJ6fYHhxJZTCG7ezocLmgWoYRScs9dzbEyju1I+ oatO5axtXW1kfxm82RXqUdfWYpceFgZw4goVLrBBmKEFiJbkkQyPuR9ymujWkPAT/ShA tfXIFtFHbyaVjdhdfu4loaGWC0SeIx3TdsW7H2CdetS7UM/XSvnoynH6pfshCcHQszUT ZjqzD93Koe9Ol1h2RlbjTxafWOBthihRHMjyGi95WhIjU6H6RA8MD9Cn6peX/3qr56GW U4Rz5qOAqDhuaB9m9QsxPEN44itPRkmLpaF8FFfvs+sH6WrUfHQ8hX0BYLCfccxgYZs0 5jhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=oBrPJ9sYwDSW4uj7Uc4h3NOiqrxzVdYSDRLTKeRx8Eg=; b=p5rubwPVYqDj54IQTrD+rccZxJBWNrct9DzsY7Sa2eja/VIM4ej1PVaQqzL02N8fya huV+m6hTtJKCTm1S0AhxeiP90yYBExg7m7sWuooYuio5OuR1d3Nrwwi9J40PE0/Mbqsx JFhtB3Lxw2kRIY7cG7nwpLhILjNNfgKzyZD/Vq5b6uWN2PSLegWH3v2b7K9fhb5RTUOL R2Tkk7g6qcsBwqNk2mY4S9O0ka2WNc6851NPUhtQ/Ol7lrJsmZRSGn/Ru/iqKP2+vvSK UOyIk1Owg/q/UbeBUWsN1E3yDwqlAFNntahESNF/Bb0P3fEI1GTUbeCe0D0G/GpqfjvQ xgwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Nnj6zwNi; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si10047838eja.168.2019.11.27.11.20.54; Wed, 27 Nov 2019 11:21:18 -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=@chromium.org header.s=google header.b=Nnj6zwNi; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727016AbfK0TTX (ORCPT + 99 others); Wed, 27 Nov 2019 14:19:23 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:44165 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726593AbfK0TTW (ORCPT ); Wed, 27 Nov 2019 14:19:22 -0500 Received: by mail-pl1-f195.google.com with SMTP id az9so10213379plb.11 for ; Wed, 27 Nov 2019 11:19:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=oBrPJ9sYwDSW4uj7Uc4h3NOiqrxzVdYSDRLTKeRx8Eg=; b=Nnj6zwNiP1jBcxqwMJNmRsPBkVa7voDaE/gzEtXMxDXNX2dbQd2U4+VRuT4aeLAPn/ lz29M7KcV2j2wutA8IbIa94L2myqXeIsTfYgOyT55FzSf/IR+QJVw2Oip8M/b9hkhjJJ zkp8xRrPJ+bQhYflquHOjRJsWZMiF/nKorceQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=oBrPJ9sYwDSW4uj7Uc4h3NOiqrxzVdYSDRLTKeRx8Eg=; b=D7Uo6j3yT8YentsfXL+s/zfCUfTSAc+YfOVg+0BzRmyLmitEQnaJo1mlXrDV2mwa6/ NwQmiQO5phB7e9N4+Q0Ldf1E2F8Go+HSVZejwuJL1b3Gw2SRX4+9IBh0HRNO+3j65Wjv bvCUywNXxn5aD0Vm6AvldsY2R1pwN6mQ3mjwlHX4tPjpW/t32s/P2DJDB0szZGPVFggF xCboVez+KdRYvMHdl6kVLSan0UllZvblL48kyuhjbMHqVtfaGMmLrrSZmFg2Glr+XESy KG96rnnLpoi7q3j9OEvCcU/PJOHolOGROmOyjH/iR5cr3gzx2bCFE/C86akPa0iOHiUP KE2g== X-Gm-Message-State: APjAAAWFTDWJl7q18n+KMVsWuwlSHU9psaHw6IAJq9KgjwjxwkvfVgpt 7FEK/FNEHMYeJhEGIDGGSyh6uZDE/54= X-Received: by 2002:a17:90b:46cf:: with SMTP id jx15mr8092360pjb.19.1574882362151; Wed, 27 Nov 2019 11:19:22 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id w5sm17977385pfd.31.2019.11.27.11.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:19:21 -0800 (PST) Date: Wed, 27 Nov 2019 11:19:20 -0800 From: Kees Cook To: Ingo Molnar Cc: Andy Lutomirski , x86 , linux-kernel@vger.kernel.org Subject: [PATCH] lkdtm/bugs: Avoid ifdefs for DOUBLE_FAULT Message-ID: <201911271118.FCC2D04F@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org LKDTM test visibility shouldn't change, so remove the ifdefs on DOUBLE_FAULT and make sure test failure doesn't crash the system. Link: https://lore.kernel.org/lkml/20191127184837.GA35982@gmail.com Fixes: b09511c253e5 ("lkdtm: Add a DOUBLE_FAULT crash type on x86") Signed-off-by: Kees Cook --- applies on top of tip/x86/urgent --- drivers/misc/lkdtm/bugs.c | 8 +++++--- drivers/misc/lkdtm/core.c | 4 +--- drivers/misc/lkdtm/lkdtm.h | 2 -- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/misc/lkdtm/bugs.c b/drivers/misc/lkdtm/bugs.c index a4fdad04809a..22f5293414cc 100644 --- a/drivers/misc/lkdtm/bugs.c +++ b/drivers/misc/lkdtm/bugs.c @@ -342,9 +342,9 @@ void lkdtm_UNSET_SMEP(void) #endif } -#ifdef CONFIG_X86_32 void lkdtm_DOUBLE_FAULT(void) { +#ifdef CONFIG_X86_32 /* * Trigger #DF by setting the stack limit to zero. This clobbers * a GDT TLS slot, which is okay because the current task will die @@ -373,6 +373,8 @@ void lkdtm_DOUBLE_FAULT(void) asm volatile ("movw %0, %%ss; addl $0, (%%esp)" :: "r" ((unsigned short)(GDT_ENTRY_TLS_MIN << 3))); - panic("tried to double fault but didn't die\n"); -} + pr_err("FAIL: tried to double fault but didn't die!\n"); +#else + pr_err("FAIL: this test is only available on 32-bit x86.\n"); #endif +} diff --git a/drivers/misc/lkdtm/core.c b/drivers/misc/lkdtm/core.c index ee0d6e721441..7082ef8a2b99 100644 --- a/drivers/misc/lkdtm/core.c +++ b/drivers/misc/lkdtm/core.c @@ -116,6 +116,7 @@ static const struct crashtype crashtypes[] = { CRASHTYPE(STACK_GUARD_PAGE_LEADING), CRASHTYPE(STACK_GUARD_PAGE_TRAILING), CRASHTYPE(UNSET_SMEP), + CRASHTYPE(DOUBLE_FAULT), CRASHTYPE(UNALIGNED_LOAD_STORE_WRITE), CRASHTYPE(OVERWRITE_ALLOCATION), CRASHTYPE(WRITE_AFTER_FREE), @@ -171,9 +172,6 @@ static const struct crashtype crashtypes[] = { CRASHTYPE(USERCOPY_KERNEL_DS), CRASHTYPE(STACKLEAK_ERASING), CRASHTYPE(CFI_FORWARD_PROTO), -#ifdef CONFIG_X86_32 - CRASHTYPE(DOUBLE_FAULT), -#endif }; diff --git a/drivers/misc/lkdtm/lkdtm.h b/drivers/misc/lkdtm/lkdtm.h index c56d23e37643..f4952efd6785 100644 --- a/drivers/misc/lkdtm/lkdtm.h +++ b/drivers/misc/lkdtm/lkdtm.h @@ -28,9 +28,7 @@ void lkdtm_CORRUPT_USER_DS(void); void lkdtm_STACK_GUARD_PAGE_LEADING(void); void lkdtm_STACK_GUARD_PAGE_TRAILING(void); void lkdtm_UNSET_SMEP(void); -#ifdef CONFIG_X86_32 void lkdtm_DOUBLE_FAULT(void); -#endif /* lkdtm_heap.c */ void __init lkdtm_heap_init(void); -- 2.17.1 -- Kees Cook