Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3511422ybc; Thu, 21 Nov 2019 09:22:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzq8Jow9ZlCNFPBZcFm80JOcFZ7qY2v5JF1JEH+hzXrbPMugjgW3Sx5b96LwPGF+evJg0xi X-Received: by 2002:a17:906:2241:: with SMTP id 1mr15201796ejr.16.1574356956840; Thu, 21 Nov 2019 09:22:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574356956; cv=none; d=google.com; s=arc-20160816; b=hpyLQxQTYFWn5cyMbah3dduwOUV32wvxIjUUayPn4yywplfNYFJtrBRiRBbpOqumKr 9x3GCT6XhyrWLiYUiJrz3uVbRSlwiBlvbjBhd0AWVu9WmJmnTk91U7hCGC0q5D7ryNXi zHftvTsXdpyi/cK29YxFlKFGIYf52JngS+8oCYhRKyDPA/bQ7a6X3yZyobNPbi/giPvE 7cU80xUgxyJnwWTz9gFkw1m47VG1BSHkq//sRtConM3uDOYT8y6f65aJ72PIjymLdjuL rdp4LzurIE6j8ouw38nEE3DbFDTOum2Op6kejOGh9Jg6HKyHA5WM0K+/FE4Jz3z9lrvo lBOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=B9Cd6lsebgbNm4s313iOukfjAkgVHP26MAXbnw9I+ys=; b=FLvDmMPErdoAtzXY1EcDvUH/5EOkq3XV+EyZlZT49uqkKda0nge7AnmtJLkcPO2LEc dVMN9zxnuudoyJxeKO5rgh+5NJhmvoxwsttpo80rEpDdUB1CS6EpxLqLRurE6bgQuI4g jKfmwYuPSOlB/SKNPm+ydytEB5mWRORK/eV1nZtwjM+i1Zi2a9PgscLmnS1gSB0IlTrd B6qPVvUJCXuSYNGgNknRhSV+gHBz/hfNPIvyMELh+0tqZ5vTwaRQSPPMU2Mc4IpwRlbJ PHNTokHFAUnnBcrY4j/x3TWTzbQkq8CqUe6E9m48pWN77XHhRVJISu2I7nACpYxT0Ugv 0Eag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lwi+PHw2; 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 u9si2291767ejk.388.2019.11.21.09.22.11; Thu, 21 Nov 2019 09:22:36 -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=lwi+PHw2; 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 S1726701AbfKURU6 (ORCPT + 99 others); Thu, 21 Nov 2019 12:20:58 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45369 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726279AbfKURU6 (ORCPT ); Thu, 21 Nov 2019 12:20:58 -0500 Received: by mail-pg1-f196.google.com with SMTP id k1so1904284pgg.12 for ; Thu, 21 Nov 2019 09:20:57 -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:references:mime-version :content-disposition:in-reply-to; bh=B9Cd6lsebgbNm4s313iOukfjAkgVHP26MAXbnw9I+ys=; b=lwi+PHw2zxipBVCVjR3p0f6wVaizQv25tJnVjtPp9YRV2Yxli9DfKpaiSyNmEHpftc n7IvneVZSZroQY+XDIkuwKzSa7l1m9VThgY6uvAHhnsZmCyZNlymdXYRzMvPfiCVr3ft PQrtb2P/6tSvAmXY7k3qs8rJk1MPVAYmDAbR0= 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:references :mime-version:content-disposition:in-reply-to; bh=B9Cd6lsebgbNm4s313iOukfjAkgVHP26MAXbnw9I+ys=; b=F1XsaVfTM6PjOHx5ioC36iyZ5kSFgbyvjPgirKvykI92wcap97SOqqf0xxAGU/e7d3 l5ozdoBnuHcfzgcbz439Pi+ofSiBA52hPJQYi/ld+lLUVUg5c45UT5Iasiqvj6yRKFJb k+F0CMaPV3yHF1ENQ8uXB1GmIlxASadhA/NCGbX+naeZEg0PnWr4SDxIkZv8dXX1tg0f rsCpr3zinr2MW8S2vcgrxEI3D7MawyhGEK8EKZZ9X5pl9qDfbS3SxYgVOqWA7VqYQCUz H6WUllZapf80H3sTQdg5+cnr+q+Z0fZNKmefA8oNnRdujVtx/JViTJdkyBJY7sXzomGv jDZA== X-Gm-Message-State: APjAAAX8pmloO8CUVTVedWIdRjPRjIkjkuATAHABxq91X52t1WMGhnsD u5lSBq9RXUCO/Pr79u75/DSl1g== X-Received: by 2002:a63:df09:: with SMTP id u9mr10657407pgg.20.1574356857223; Thu, 21 Nov 2019 09:20:57 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id v3sm4017698pfn.129.2019.11.21.09.20.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 09:20:56 -0800 (PST) Date: Thu, 21 Nov 2019 09:20:55 -0800 From: Kees Cook To: Andrey Ryabinin Cc: Elena Petrova , Alexander Potapenko , Dmitry Vyukov , Linus Torvalds , Dan Carpenter , "Gustavo A. R. Silva" , Arnd Bergmann , Ard Biesheuvel , Andrew Morton , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: Re: [PATCH 1/3] ubsan: Add trap instrumentation option Message-ID: <201911210917.F672B39C32@keescook> References: <20191120010636.27368-1-keescook@chromium.org> <20191120010636.27368-2-keescook@chromium.org> <35fa415f-1dab-b93d-f565-f0754b886d1b@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <35fa415f-1dab-b93d-f565-f0754b886d1b@virtuozzo.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 21, 2019 at 03:52:52PM +0300, Andrey Ryabinin wrote: > On 11/20/19 4:06 AM, Kees Cook wrote: > > > > +config UBSAN_TRAP > > + bool "On Sanitizer warnings, stop the offending kernel thread" > > That description seems inaccurate and confusing. It's not about kernel threads. > UBSAN may trigger in any context - kernel thread/user process/interrupts... > Probably most of the kernel code runs in the context of user process, so "stop the offending kernel thread" > doesn't sound right. > > > > > + depends on UBSAN > > + depends on $(cc-option, -fsanitize-undefined-trap-on-error) > > + help > > + Building kernels with Sanitizer features enabled tends to grow > > + the kernel size by over 5%, due to adding all the debugging > > + text on failure paths. To avoid this, Sanitizer instrumentation > > + can just issue a trap. This reduces the kernel size overhead but > > + turns all warnings into full thread-killing exceptions. > > I think we should mention that enabling this option also has a potential to > turn some otherwise harmless bugs into more severe problems like lockups, kernel panic etc.. > So the people who enable this would better understand what they signing up for. Good point about other contexts. I will attempt to clarify and send a v2. BTW, which tree should ubsan changes go through? The files are actually not mentioned by anything in MAINTAINERS. Should the KASAN entry gain paths to cover ubsan too? Something like: diff --git a/MAINTAINERS b/MAINTAINERS index 9dffd64d5e99..585434c013c4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8824,7 +8824,7 @@ S: Maintained F: Documentation/hwmon/k8temp.rst F: drivers/hwmon/k8temp.c -KASAN +KERNEL SANITIZERS (KASAN, UBSAN) M: Andrey Ryabinin R: Alexander Potapenko R: Dmitry Vyukov @@ -8834,9 +8834,13 @@ F: arch/*/include/asm/kasan.h F: arch/*/mm/kasan_init* F: Documentation/dev-tools/kasan.rst F: include/linux/kasan*.h +F: lib/Kconfig.ubsan F: lib/test_kasan.c +F: lib/test_ubsan.c +F: lib/ubsan.c F: mm/kasan/ F: scripts/Makefile.kasan +F: scripts/Makefile.ubsan KCONFIG M: Masahiro Yamada -- Kees Cook