Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1160781pxb; Thu, 19 Aug 2021 22:28:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwc6TtN5tqvZLX0HBAcHTTRCbDkxCzQKYDybn3/ddx0L799o+weLilQuqMzJsqxuvX5rPRm X-Received: by 2002:a02:1942:: with SMTP id b63mr16093758jab.111.1629437302979; Thu, 19 Aug 2021 22:28:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629437302; cv=none; d=google.com; s=arc-20160816; b=lhTS/z6HQB+Nm585YXWl7xwI1tle2LcvHyOCj2JpzsZ1Rf+3cBspz185SbVwdtCETg NwEKnTKtzm+88eW3UYcjpbHtd0h0bG0VjkMlTqvF7EDYBeFatNMYzif2A1/u5L4uCyMr DauzZZfoec4NyFEHHhr6AJdikziXvcly55lpPbRhMIUPjU5VEkX3PVUgtpt2nv9eTyR/ /y3AftouO6hPIEnYMM3l+DDH3Fn5BQArLKuoZnQwyc5p6HTMdlFoO4+2AkmiKjkJ03yH GYKtqrrLM/C42jX6uQC/uD1/i5Ct+QzrsYfRLKVqUHQR9h5Ix1ILA6ZcaAk7xhnCFBew 0qZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SGRbSAfBSvn06RBLUf1ChYkatAx1DB8aY9rwM3r+UEw=; b=wcypwm/GO/Sq6p1t/D81aHxSgTqucdQDMbT/jU4vBGtbfGLwotCQzFNi3RvNtUrio/ 3fbS491VTma2cPwlrumG4aNjxvQL/9Z271OEA4PKdyoDXiYWJSFrKsOvR13QGgUgllS7 W2FMwlzSbrsTSNiuA4l88EGhlnpOD2D9Lb1IYvR4xpVvyPuMeKsWdDZ/C94owdG9ez+O sehdL6Bc624urw//nPS42J8DgRXSwQiE0R7JmDM63Fe57DRofFu24NEIe5EnhkhE+8aS Q2Jrn2vSoMnlvbAZmFXZJ4aE2kryGvK6TTLUtQwS11oxloFDCwqndKm/FY7y4BHtMAsG FwFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=e8yLPfT1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id k8si4949549jaa.51.2021.08.19.22.28.11; Thu, 19 Aug 2021 22:28:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=e8yLPfT1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231784AbhHTF2G (ORCPT + 99 others); Fri, 20 Aug 2021 01:28:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232499AbhHTF2F (ORCPT ); Fri, 20 Aug 2021 01:28:05 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CE05C061756 for ; Thu, 19 Aug 2021 22:27:28 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id o10so5382163plg.0 for ; Thu, 19 Aug 2021 22:27:28 -0700 (PDT) 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=SGRbSAfBSvn06RBLUf1ChYkatAx1DB8aY9rwM3r+UEw=; b=e8yLPfT1ZSJ15iZJiMw6qxGa0HiNLjixxvbjRpRN6qn/MyzHf3UPtdtI1dJB26alb+ Qiv4vMyVf+ZBzt5qL2e7P26WvObBL+fntQjp3AuRoh1x7ufZ1AuoO3AP7hJdvmFloS5X C2Sk1T60D/qeAxP9SnkCnfuqUHGYhywaprLOU= 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=SGRbSAfBSvn06RBLUf1ChYkatAx1DB8aY9rwM3r+UEw=; b=qprcfbQ2mV+2oFEWdmtHBWpfvQrx74/8RrY1NpU9WWqrU1YnXWcX1Tcjl9MUkaFCAI l7m6GDVFMFzFEcqv1M/ePlyaz/ZDsT801l20bthBTEejlB/j27IES35jS9BFhEbOkPWI kCgkzUrKN6cSGLsleCQKZy6Iu8OjBcStJXF3d5V0uXbu+QO64oQPDWWFoJIDtZl0Sojz 7vho//kJ03vZ+aGecn7On8oaJrqAm23pKRQ9Zvb0TXkCVMAf5nv7IJPhRjxSqMrkQ5B1 Ykaw1vv8Q6t6YXkBBx9S9TLIa1Bpa9KoHTLrp3UscdXGL18edNqCytxSQ0G13dVVfeN+ HEjg== X-Gm-Message-State: AOAM5307h5M6zdnFnll+F4Lw2s3fC/rgH1Emzr00HENnYdDiYV4u4OtN lHPdyN/OH0vAtomgYmZ99ATJbg== X-Received: by 2002:a17:90a:bd08:: with SMTP id y8mr2815251pjr.123.1629437247529; Thu, 19 Aug 2021 22:27:27 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 10sm5639485pjc.41.2021.08.19.22.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 22:27:27 -0700 (PDT) Date: Thu, 19 Aug 2021 22:27:26 -0700 From: Kees Cook To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Daniel Micay , Dennis Zhou , Tejun Heo , Christoph Lameter , linux-mm@kvack.org, Joe Perches , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Andy Whitcroft , Dwaipayan Ray , Lukas Bulwahn , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Masahiro Yamada , Michal Marek , clang-built-linux@googlegroups.com, linux-kbuild@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2 6/7] percpu: Add __alloc_size attributes for better bounds checking Message-ID: <202108192221.396DFDC9@keescook> References: <20210818214021.2476230-1-keescook@chromium.org> <20210818214021.2476230-7-keescook@chromium.org> <20210819221115.b3a34e280cfe748ad6a76b04@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210819221115.b3a34e280cfe748ad6a76b04@linux-foundation.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 19, 2021 at 10:11:15PM -0700, Andrew Morton wrote: > On Wed, 18 Aug 2021 14:40:20 -0700 Kees Cook wrote: > > > As already done in GrapheneOS, add the __alloc_size attribute for > > appropriate percpu allocator interfaces, to provide additional hinting > > for better bounds checking, assisting CONFIG_FORTIFY_SOURCE and other > > compiler optimizations. > > > > Caught one, I assume: > > In file included from ./include/linux/string.h:262, > from ./include/linux/bitmap.h:11, > from ./include/linux/cpumask.h:12, > from ./arch/x86/include/asm/cpumask.h:5, > from ./arch/x86/include/asm/msr.h:11, > from ./arch/x86/include/asm/processor.h:22, > from ./arch/x86/include/asm/cpufeature.h:5, > from ./arch/x86/include/asm/thread_info.h:53, > from ./include/linux/thread_info.h:60, > from ./arch/x86/include/asm/preempt.h:7, > from ./include/linux/preempt.h:78, > from ./include/linux/spinlock.h:55, > from ./include/linux/mmzone.h:8, > from ./include/linux/gfp.h:6, > from ./include/linux/slab.h:15, > from drivers/misc/lkdtm/heap.c:7: > In function 'memset', > inlined from 'lkdtm_VMALLOC_LINEAR_OVERFLOW' at drivers/misc/lkdtm/heap.c:27:2: > ./include/linux/fortify-string.h:172:3: error: call to '__write_overflow' declared with attribute error: detected write beyond size of object passed as 1st parameter > 172 | __write_overflow(); > | ^~~~~~~~~~~~~~~~~~ > make[3]: *** [drivers/misc/lkdtm/heap.o] Error 1 > make[2]: *** [drivers/misc/lkdtm] Error 2 > make[1]: *** [drivers/misc] Error 2 > make: *** [drivers] Error 2 > > I want to get a kernel release out, so I'll hide > mm-vmalloc-add-__alloc_size-attributes-for-better-bounds-checking.patch > for now. In the cover letter[1], I listed the needed fixes that were sent separately from this series. Quoting here: > To build without warnings, this series needs a couple small fixes for > allmodconfig, which I sent separately: > https://lore.kernel.org/lkml/20210818174855.2307828-5-keescook@chromium.org/ > https://lore.kernel.org/lkml/20210818044252.1533634-1-keescook@chromium.org/ > https://lore.kernel.org/lkml/20210818043912.1466447-1-keescook@chromium.org/ What you hit is the first one, which is already in Greg's tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/commit/?h=char-misc-next&id=e6d468d32cd084edd030a8bae76440b17b854b5c The other two have also been taken: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?h=staging-next&id=cbe34165cc1b7d1110b268ba8b9f30843c941639 https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git/commit/?id=a31e5a4158d03595ca4258b94397d4097be0ebe4 -Kees [1] https://lore.kernel.org/lkml/20210818214021.2476230-1-keescook@chromium.org/ -- Kees Cook