Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp5138520pxb; Tue, 5 Oct 2021 18:49:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8JxYfyVu/TjOyfcAiGvUkxlETeu9dkbpvlHkWChbjDdydyvdzfnezX0VuHh9ntiyIUz7s X-Received: by 2002:a05:6402:19ad:: with SMTP id o13mr31212594edz.109.1633484949694; Tue, 05 Oct 2021 18:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633484949; cv=none; d=google.com; s=arc-20160816; b=QgiRWgl1D2NW0jIoQy6PO5ZMV3TJCVjoQp5Tip/Mybtp2A8CUR0bPr5fzzTT6H7wgy evshesaENningw2bkQkZktm6ClsTnz0TYmUzEoA1iULGtwBko5I4jQDPuxH9ZHrK7G5N LQeD4T3O931MUi7kA9zXVmmcLs83E+j+ngJzP3ux+n6dMoo1RsLiKGmsi+SqWtKC5myv QScjum9siWBFlm8i9xI2LWtCH8VvttKvvlPtrL/yX/DyyYYpOZuKzYfe2NpMv0fih4a2 S+dFm19oQbl1I9XFxLIchjsHqHTxzx5poaBz/XfPxn2lv0KfIpP1UCsWY/xqbt8TEiJe ZJDg== 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=9lVsR8viyeOaNuq1ktr/jxXNA4FJbIMaWzpFsunm0o4=; b=H40YgFHlWRfnzX1zwS3ugLXEwfFqrOp4ALkLK3mGeQfmF1YxBk3WIcMueDG61hCi4X 3Q/EOUP1/qopt2vUHWXj0zQJw49qKaUQ80mNViOWTa5vqymeDR3FDQMrS3PLq1nG4QqD H132a1wBm8FU7p07Q2VeiBKipRz/sfBRJxJoh8Lg1GeiPYZaNE4SiESFFStvyG96ZjdX 58nKk6HyJuYaleJme+IgI3Fv6Fcr61/HX17pWJMI0P4eLAMFgVl2Q5rfOKbo2O1AgLjQ dfeTqpUdfvNfag0EHO9/+AEDvHzPFNCSBdikKL1PCvHQOZBbabOTP+qoC92JMA/2YCx6 HHzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=IxA2DMOO; 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 b5si23309843ejb.4.2021.10.05.18.48.45; Tue, 05 Oct 2021 18:49:09 -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=IxA2DMOO; 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 S237139AbhJFBtM (ORCPT + 99 others); Tue, 5 Oct 2021 21:49:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:60526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbhJFBtL (ORCPT ); Tue, 5 Oct 2021 21:49:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D00A611CC; Wed, 6 Oct 2021 01:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1633484838; bh=Xt+wZ6PkpbqGmpCET0SN48ylqvwvPAINuGHGp2TK1uY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IxA2DMOOXNCn02Sbwsru0IXmgNMs9rv4nMcyqr06+2YctzkpKzNPO6CCXPdKM1Np0 t7lmbu0FEO37bLus65CjV0G166hksDhs7XFigmUyv4IM9aFkaL9zjCRpK2rOMsWEqX EkL6cytWknEjtB//VUBv0jEX19efvyxzhNHUIrns= Date: Tue, 5 Oct 2021 18:47:17 -0700 From: Andrew Morton To: Kees Cook Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Andy Whitcroft , Dennis Zhou , Dwaipayan Ray , Joe Perches , Lukas Bulwahn , Miguel Ojeda , Nathan Chancellor , Tejun Heo , Daniel Micay , Nick Desaulniers , Masahiro Yamada , Michal Marek , clang-built-linux@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v3 4/8] slab: Add __alloc_size attributes for better bounds checking Message-Id: <20211005184717.65c6d8eb39350395e387b71f@linux-foundation.org> In-Reply-To: <20210930222704.2631604-5-keescook@chromium.org> References: <20210930222704.2631604-1-keescook@chromium.org> <20210930222704.2631604-5-keescook@chromium.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; 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 Thu, 30 Sep 2021 15:27:00 -0700 Kees Cook wrote: > As already done in GrapheneOS, add the __alloc_size attribute for regular > kmalloc interfaces, to provide additional hinting for better bounds > checking, assisting CONFIG_FORTIFY_SOURCE and other compiler > optimizations. x86_64 allmodconfig: In file included 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/mm.h:10, from ./include/linux/mman.h:5, from lib/test_kasan_module.c:10: In function 'check_copy_size', inlined from 'copy_user_test' at ./include/linux/uaccess.h:191:6: ./include/linux/thread_info.h:213:4: error: call to '__bad_copy_to' declared with attribute error: copy destination size is too small 213 | __bad_copy_to(); | ^~~~~~~~~~~~~~~ In function 'check_copy_size', inlined from 'copy_user_test' at ./include/linux/uaccess.h:199:6: ./include/linux/thread_info.h:211:4: error: call to '__bad_copy_from' declared with attribute error: copy source size is too small 211 | __bad_copy_from(); | ^~~~~~~~~~~~~~~~~ make[1]: *** [lib/test_kasan_module.o] Error 1 make: *** [lib] Error 2