Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1155182pxb; Thu, 19 Aug 2021 22:17:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyT+f92QWmy3t6Xszc4BMP54NC3ZNioingt98q+X7rr8KnYJD/TGlqeYOnws+IwMJQUvngC X-Received: by 2002:a05:6402:64b:: with SMTP id u11mr21012808edx.4.1629436644365; Thu, 19 Aug 2021 22:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629436644; cv=none; d=google.com; s=arc-20160816; b=JocbpDdVychZ98uUAs+1lmKlaknYSbFbXAuQYF8yhzI0v1G5bz7PR/h8J1UmC1gAQy jfjdoVOvug5DQo/hAFW+ZxXR94XjsgHTmWeZuIhte6SOnaEMf7zYsmtc3ISVuEcpDbMN kOsNe73eDzS5FVaUnfk/tj5vAwFq4DF8aXzEzvKVllS0a6uNphR9E6vgBSr8OdKMuRqD xQY6WiYYcq9J8WbxcVy94NfLrRrnD0YDD0BGXzRsAbo+41FaNx3u6NZJp33kg66sVz+B neWgdG7ncuUHVZijaBcKckKN7oO/m/apLRePW1nB3xGdnwWMZzAiU/4y3dufL60pNhMq H09w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=NKcjszTjOxf0g7w2LtGewET4owcsnETxlRLGiLmkzcY=; b=bcPAiJ90/XObzvTS1B7dkPx+DqcJC7NBG5dYiDTVL1w8CiJD+psDBhVQjyHgDoRYji bDgoPkC+TfRp+mM3Pa2DKXbTQT+iOUBIzgLWdKcvFHscBVNQIaMMI+rU900lfMJKRjlW 2jbtAee+HMZ3dyVpJFV+qx9mg7D6A78ANKSnBJD725Nr4uSNjfD9uZlC72SCcEJWaVik nKwwciXRlcewrsIOVCKjRASNiM3m9uEQE7k0+8yv/yEG8Wwhauy5MbJtO7RHyuYBfWRs s8Bm+k7JKgLMCqXPONb4e0IpRbFObVhm08F2fqlZx7L5EHcvvHcL3esib9qXYkQg0XJP yE5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=bvG0F0sK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si6757753ejm.145.2021.08.19.22.17.00; Thu, 19 Aug 2021 22:17:24 -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=@linux-foundation.org header.s=korg header.b=bvG0F0sK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233825AbhHTFL4 (ORCPT + 99 others); Fri, 20 Aug 2021 01:11:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:48880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231524AbhHTFLz (ORCPT ); Fri, 20 Aug 2021 01:11:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DC1966054E; Fri, 20 Aug 2021 05:11:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1629436278; bh=cc0SAzsXcx00EyeJ0FnbHDyCca6n3ae4I61WSDxYEwA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=bvG0F0sKpl38gpuSoBBM0DZ34c97J/dKjpUWMG8mSl3eY714SZ4ZWdp1CQY8YNrA2 SPU8krSWxILdcGpNCLNNpl3SdCjAgi0zjp2U1rC0n6EVvrIEJaZlb50Q7cdfCLrPAX lEVaPGgaOoS19JK0+ItRQJeLSQeMZf5dbV0xOzew= Date: Thu, 19 Aug 2021 22:11:15 -0700 From: Andrew Morton To: Kees Cook 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: <20210819221115.b3a34e280cfe748ad6a76b04@linux-foundation.org> In-Reply-To: <20210818214021.2476230-7-keescook@chromium.org> References: <20210818214021.2476230-1-keescook@chromium.org> <20210818214021.2476230-7-keescook@chromium.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.