From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34EC7C433EF for ; Fri, 1 Oct 2021 23:57:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D584610A2 for ; Fri, 1 Oct 2021 23:57:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229976AbhJAX7O (ORCPT ); Fri, 1 Oct 2021 19:59:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:46948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232213AbhJAX53 (ORCPT ); Fri, 1 Oct 2021 19:57:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 266B561075; Fri, 1 Oct 2021 23:55:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1633132544; bh=FtBDHedcTcymmaRwgeB9JOtXhSgetXJNaDo7lHCIHfY=; h=Date:From:To:Subject:From; b=hSkqhw6DmUxlrJYODi+6VKMyHwsQN4DIqD1QeHtsYv0iGAIDNkeg32+hJrHv/Z2GB 06A2qZm7PWCsBZWij1woHt7gJWmi5qsRFuC5zKJd/XH5ubsCzeFkYjl6KFeRnwF9FQ F9Iqe6ZgQV2flhW4zCeLgURXN9lqdN9DIwlFDFU0= Date: Fri, 01 Oct 2021 16:55:43 -0700 From: akpm@linux-foundation.org To: alex.bou9@gmail.com, apw@canonical.com, cl@linux.com, danielmicay@gmail.com, dennis@kernel.org, dwaipayanray1@gmail.com, gustavoars@kernel.org, iamjoonsoo.kim@lge.com, ira.weiny@intel.com, jhubbard@nvidia.com, jingxiangfeng@huawei.com, joe@perches.com, jrdr.linux@gmail.com, keescook@chromium.org, lkp@intel.com, lukas.bulwahn@gmail.com, mm-commits@vger.kernel.org, mporter@kernel.crashing.org, nathan@kernel.org, ndesaulniers@google.com, ojeda@kernel.org, penberg@kernel.org, rdunlap@infradead.org, rientjes@google.com, tj@kernel.org, vbabka@suse.cz Subject: + mm-page_alloc-add-__alloc_size-attributes-for-better-bounds-checking.patch added to -mm tree Message-ID: <20211001235543.BwFennCVH%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: mm/page_alloc: add __alloc_size attributes for better bounds checking has been added to the -mm tree. Its filename is mm-page_alloc-add-__alloc_size-attributes-for-better-bounds-checking.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-page_alloc-add-__alloc_size-attributes-for-better-bounds-checking.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-page_alloc-add-__alloc_size-attributes-for-better-bounds-checking.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Kees Cook Subject: mm/page_alloc: add __alloc_size attributes for better bounds checking As already done in GrapheneOS, add the __alloc_size attribute for appropriate page allocator interfaces, to provide additional hinting for better bounds checking, assisting CONFIG_FORTIFY_SOURCE and other compiler optimizations. Link: https://lkml.kernel.org/r/20210930222704.2631604-8-keescook@chromium.org Signed-off-by: Kees Cook Co-developed-by: Daniel Micay Signed-off-by: Daniel Micay Cc: Andy Whitcroft Cc: Christoph Lameter Cc: David Rientjes Cc: Dennis Zhou Cc: Dwaipayan Ray Cc: Joe Perches Cc: Joonsoo Kim Cc: Lukas Bulwahn Cc: Miguel Ojeda Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Pekka Enberg Cc: Tejun Heo Cc: Vlastimil Babka Cc: Alexandre Bounine Cc: Gustavo A. R. Silva Cc: Ira Weiny Cc: Jing Xiangfeng Cc: John Hubbard Cc: kernel test robot Cc: Matt Porter Cc: Randy Dunlap Cc: Souptick Joarder Signed-off-by: Andrew Morton --- include/linux/gfp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/include/linux/gfp.h~mm-page_alloc-add-__alloc_size-attributes-for-better-bounds-checking +++ a/include/linux/gfp.h @@ -608,9 +608,9 @@ static inline struct page *alloc_pages(g extern unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order); extern unsigned long get_zeroed_page(gfp_t gfp_mask); -void *alloc_pages_exact(size_t size, gfp_t gfp_mask); +void *alloc_pages_exact(size_t size, gfp_t gfp_mask) __alloc_size(1); void free_pages_exact(void *virt, size_t size); -void * __meminit alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask); +__meminit void *alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask) __alloc_size(1); #define __get_free_page(gfp_mask) \ __get_free_pages((gfp_mask), 0) _ Patches currently in -mm which might be from keescook@chromium.org are rapidio-avoid-bogus-__alloc_size-warning.patch compiler-attributes-add-__alloc_size-for-better-bounds-checking.patch slab-clean-up-function-prototypes.patch slab-add-__alloc_size-attributes-for-better-bounds-checking.patch mm-kvmalloc-add-__alloc_size-attributes-for-better-bounds-checking.patch mm-vmalloc-add-__alloc_size-attributes-for-better-bounds-checking.patch mm-page_alloc-add-__alloc_size-attributes-for-better-bounds-checking.patch percpu-add-__alloc_size-attributes-for-better-bounds-checking.patch binfmt_elf-reintroduce-using-map_fixed_noreplace.patch