Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp369118rwb; Thu, 22 Sep 2022 00:14:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4PHJ8YiRlIlnoXBXYaIKwSAM7FVZD73cfcdChxNqq1mns8pEpHGKZ75DambUME8VFklBLi X-Received: by 2002:a05:6402:3c8:b0:454:44b3:2e2a with SMTP id t8-20020a05640203c800b0045444b32e2amr1789207edw.283.1663830848751; Thu, 22 Sep 2022 00:14:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663830848; cv=pass; d=google.com; s=arc-20160816; b=ejEI0GF1f013aKd1rHtCLl6BupJA1ZaChHpIFHiZqkx72rdga25diTFOOz8E/i85eP Jm5/ZH20SvWqMnwf7fwFyXngxHEgT565UBfkwccB3dSb3uwDeY8Hd/lW3BX+p7tI8f6S FqpV1S/JlfFK9VkdIyzUYhrhxlkc8vVF336VHEicD8wNsnISn9SJMcgnus9Wk32wIX0w fOuyebu4pN4wmVtJwp8zQ/rngLxDKl9Aq7/UY8vU23g2NBY8vGO1B25skgRHr55Bli2K OuxcuCEHo0yBt0iIrPdU8twShNr4+ijiQiT9AltP59yxh5v4+GalYQGajMIa9rPvz3qD 77Og== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=cRT7WjmYurREJU7Dp5P+Ksp1qpA9oYbR9BO3SH8gD58=; b=csXZURV5VvZkwDmu6HYadxYiggOr56+KP6EEapKrSfU8e42Tx9LMyuibqDTeZZoo6s 1oI/U9EAxHGPuFY9SFyTCG4DTG5DIWYI9usE6I+d0mo0efnknyUgZIVIBaTmUglHy979 6oXoYMhtlCzrz0rtpmLsVbJCINT6KxravPDk8Uzt02yhqgtHDP84/Myqk1/VLB9d/rbx O0GZx1eoiLYtbPe+qxFHa8U+6eL06Lnvre/DEg6N6w0VLq88JD3IPqjJr7NVmv2p+y4c g7Sviaum9egc2DZ4e9m3V1110noChZG/1CFJttEnqLE/cVVUhmSPsUnSVDtw1Xj3A7aG Ny5g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=MZcgXrc5; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a50fd03000000b00452e416643dsi3907389eds.308.2022.09.22.00.13.48; Thu, 22 Sep 2022 00:14:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=MZcgXrc5; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230350AbiIVHLc (ORCPT + 63 others); Thu, 22 Sep 2022 03:11:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbiIVHLY (ORCPT ); Thu, 22 Sep 2022 03:11:24 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2057.outbound.protection.outlook.com [40.107.220.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C454FB7768; Thu, 22 Sep 2022 00:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AOgxSHfdPwJTCVUd3Y2x0b0aUPTVLgrQFkNYB1OLJNtjmmWXrsAfPcEx3pIeZXsLA8GMU0QDkU2wcCsje091BnYWSrrFx2a8QgK8lKoHG11h1WivQ03LuGUZKIcBFGqRlDhC4mogJXfNTZCqaAweiCYfvjed2DbqqendPdWiolLTVVH79akkAKpl1ZlFxFscRM3pcPYqAKCtZWVEEY1+obI5FDrBg0C/sRBWJtSNGhVFTStrh1yTgSCHyX4pr47Zp4vWMe8lMJDCGlubqkozv5ZqZK8udCSuIrunHORfDiPcpHe0QSjIiooiQxvP8Pwn8LPzwdsUFOkEdpKMlI+VUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cRT7WjmYurREJU7Dp5P+Ksp1qpA9oYbR9BO3SH8gD58=; b=Yt+AXil1xZaXtv/ATuAJcH2sE6o4GFLgt5zEQMF42QIrPOAnVTaIwHPwRryOpjuJgSYOfn153XzoG9/TNKlKxk/tLTkDZ7oRJcGfP0/QyMbAXgS1ZGYVqEEM/xd1B5IjBsSR/GicAU7nWQWrQHISCDSQcSJ45tLosBNKbGg6aiz3maJI8GwVH/KtlxP90o/red6rbh0gwMWVT09V5M/A2lJXrzH8JMXRqi7tsvP+FS1GGZhWi/Pylwg4qjAXSoEU1c0L1XruKANPlu6OpKaoD1Up0BFvCqKCd6VPmPpRdeIJoV5BfICOe3x4I/Slhgulw28bWrYEIRTcLbbW54ru8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cRT7WjmYurREJU7Dp5P+Ksp1qpA9oYbR9BO3SH8gD58=; b=MZcgXrc59CSdt4pL5rr9nppCP345m0sxsjfu8U/x8fyEPl2xWjwE2DbkDywy0s/nLAWcCnhHCAYW1Mqbvf2Xw1oqJK73qavNVs0qIb2JamSpV2B4Eq5BUZo1kAMGhC/wmzwqrep8iJu5zgizz21tEu23Bc0D1mlwaX9NcheLmCQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by IA1PR12MB6353.namprd12.prod.outlook.com (2603:10b6:208:3e3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14; Thu, 22 Sep 2022 07:11:15 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::653f:e59b:3f40:8fed]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::653f:e59b:3f40:8fed%6]) with mapi id 15.20.5654.016; Thu, 22 Sep 2022 07:11:15 +0000 Message-ID: <673e425d-1692-ef47-052b-0ff2de0d9c1d@amd.com> Date: Thu, 22 Sep 2022 09:10:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 00/12] slab: Introduce kmalloc_size_roundup() Content-Language: en-US To: Kees Cook , Vlastimil Babka Cc: Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Greg Kroah-Hartman , Nick Desaulniers , Alex Elder , Josef Bacik , David Sterba , Sumit Semwal , Jesse Brandeburg , Daniel Micay , Yonghong Song , Marco Elver , Miguel Ojeda , Jacob Shin , linux-kernel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-fsdevel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, dev@openvswitch.org, x86@kernel.org, linux-wireless@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org References: <20220922031013.2150682-1-keescook@chromium.org> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20220922031013.2150682-1-keescook@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR0P281CA0122.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:97::12) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8PR12MB3587:EE_|IA1PR12MB6353:EE_ X-MS-Office365-Filtering-Correlation-Id: ed9216c7-500f-49bd-c604-08da9c69a36d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hSPWu19WqtbGOL+TAFpX9azBYsWMTzLFXVzaM4r/AL98cZ7Yn2JRIYQ0a+TSX4Cl8jqW181nagWy9e+s0mg7YeN/BjukFfnh/h0mZHzSCJULOzCn8XSPrLcRGq/EZ9zB7R0SSxNwjq4iz4RQrUSbl7R8E3FsY8HZtTgzPg8dOHjlyo8+hWsJKb0cHuNB+DwlFP6XxzV9asE40kzkmPzq5sN+tJurpB7xSAh9evwjXcUgPnUM8XHnXWTTB3wsXWoIFdUtyWDQv8ZhL6CGY0c5Z5vJ5KHIs1lQjPmqukQT9Uv+VvWe9hMdDsIBRwNvf0wiMBUoyORP1aPChs9ObBeRhmnQVHvxMdiqF5oD+6Q2JOZFURWe5vXJcvVa2n9A/WnZ0c+/mcxuVSJutfvcAZWU0lh8R6Nx6aoJeFIEFjSOfC3BqdjW51rJiOhWNYE5sV0rvDXsKPFdCRWElMfiI9HKYRz4Kyr324MgDpW70Vdp3gCQE/4adtgoef7rnJtb7/wdl8Vdb5gUWcBWXorwe2ZIXluRajO0DrhybGoOA32tnkWWEOxfN9rJnhDMyhjNJ1BtJupETxafkNzIts57Vyh6RXiKnERIn17lLyhkfyWtulAjCmnk3pDbn8jGbKrD8UYzjfMp9wPWd1Qw/JZtUZvP/OWD0C/TwT0Z1Hjl7gYs9FZgGRM8Hprr7t8SQxe9+jPSomULVztn0EeqyMtC/3vnyOwGwNw1JQ0zWWMPRQfRqs0lmYZozfEgCm+3D9pGnU/vePhJv1sLqgUTc9rVzeljfBc9ofYR8yeisuktOUtlmMYCA+fxGOaixOD45l1sdiGiD1RVxC4JQsaJ9eejrxGA3Hn+wQcc5V93R3XmswQAN+JXWYNs4Hrm2Tuwj+YISwpv X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(366004)(136003)(346002)(376002)(396003)(451199015)(8676002)(31686004)(6666004)(36756003)(966005)(7416002)(7406005)(478600001)(41300700001)(66946007)(66476007)(66556008)(8936002)(5660300002)(4326008)(110136005)(316002)(45080400002)(2906002)(54906003)(31696002)(38100700002)(86362001)(2616005)(186003)(6486002)(26005)(83380400001)(6512007)(6506007)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?WThBU0ZDRSs2OEw2NGdCSTlQZVdYVDJOYTNqSFZrLzc5YXBVTGIrQXRLM1l1?= =?utf-8?B?RVd4NW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Ty9CMFJt?= =?utf-8?B?cUZlcmxNbWFHbjlGb2xQNlZBWlRRelIwbnM4dkN4aExhZHRYbW5oQXdpVFRZ?= =?utf-8?B?TWRxVHVkbE1jVVpKWnhsanc4S3dSTFNyNVltaEdNQjlPUURXUTNPaHdsVG9S?= =?utf-8?B?eG96ZVZFSVQ2TGdiSFBqQWFvalZGcnlXWWVHR1BTdUxzWktTbHFHMFhXRUhh?= =?utf-8?B?b09Mbit3dFk3Yzg2LzAwNXF2M3R0bThDVkcvSzZqZDZYeVYvaDI0cjVXMzg2?= =?utf-8?Q?38WmNmx6VbQEPYBPQbj48OvRh?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed9216c7-500f-49bd-c604-08da9c69a36d X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 07:11:15.5913 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: f3DuJH1j2Vv5LVJdXfe2ol4tKB5UPthfhlY8EhhHjRI64BAzT90Cn7u6CgdGs6TX X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6353 X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Am 22.09.22 um 05:10 schrieb Kees Cook: > Hi, > > This series fixes up the cases where callers of ksize() use it to > opportunistically grow their buffer sizes, which can run afoul of the > __alloc_size hinting that CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE > use to perform dynamic buffer bounds checking. Good cleanup, but one question: What other use cases we have for ksize() except the opportunistically growth of buffers? Of hand I can't see any. So when this patch set is about to clean up this use case it should probably also take care to remove ksize() or at least limit it so that it won't be used for this use case in the future. Regards, Christian. > Quoting the first patch: > > > In the effort to help the compiler reason about buffer sizes, the > __alloc_size attribute was added to allocators. This improves the scope > of the compiler's ability to apply CONFIG_UBSAN_BOUNDS and (in the near > future) CONFIG_FORTIFY_SOURCE. For most allocations, this works well, > as the vast majority of callers are not expecting to use more memory > than what they asked for. > > There is, however, one common exception to this: anticipatory resizing > of kmalloc allocations. These cases all use ksize() to determine the > actual bucket size of a given allocation (e.g. 128 when 126 was asked > for). This comes in two styles in the kernel: > > 1) An allocation has been determined to be too small, and needs to be > resized. Instead of the caller choosing its own next best size, it > wants to minimize the number of calls to krealloc(), so it just uses > ksize() plus some additional bytes, forcing the realloc into the next > bucket size, from which it can learn how large it is now. For example: > > data = krealloc(data, ksize(data) + 1, gfp); > data_len = ksize(data); > > 2) The minimum size of an allocation is calculated, but since it may > grow in the future, just use all the space available in the chosen > bucket immediately, to avoid needing to reallocate later. A good > example of this is skbuff's allocators: > > data = kmalloc_reserve(size, gfp_mask, node, &pfmemalloc); > ... > /* kmalloc(size) might give us more room than requested. > * Put skb_shared_info exactly at the end of allocated zone, > * to allow max possible filling before reallocation. > */ > osize = ksize(data); > size = SKB_WITH_OVERHEAD(osize); > > In both cases, the "how large is the allocation?" question is answered > _after_ the allocation, where the compiler hinting is not in an easy place > to make the association any more. This mismatch between the compiler's > view of the buffer length and the code's intention about how much it is > going to actually use has already caused problems[1]. It is possible to > fix this by reordering the use of the "actual size" information. > > We can serve the needs of users of ksize() and still have accurate buffer > length hinting for the compiler by doing the bucket size calculation > _before_ the allocation. Code can instead ask "how large an allocation > would I get for a given size?". > > Introduce kmalloc_size_roundup(), to serve this function so we can start > replacing the "anticipatory resizing" uses of ksize(). > > [1] https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FClangBuiltLinux%2Flinux%2Fissues%2F1599&data=05%7C01%7Cchristian.koenig%40amd.com%7C491e7c24ddc64e9e505b08da9c47fe36%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637994130356907320%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=te%2BJ46%2B8L8oBTyGS3C7ueORFYI%2BhMRbfEoflVErr4k0%3D&reserved=0 > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKSPP%2Flinux%2Fissues%2F183&data=05%7C01%7Cchristian.koenig%40amd.com%7C491e7c24ddc64e9e505b08da9c47fe36%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637994130356907320%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=lrOCZN6EE%2BnDBA5DfOqteQt0nKCbJJ9bxlh2F13%2B3Es%3D&reserved=0 > ------- > > And after adding kmalloc_size_roundup(), put it to use with the various > ksize() callers, restore the previously removed __alloc_size hint, > and fix the use of __malloc annotations. > > I tried to trim the CC list on this series since it got rather long. I > kept all the suggested mailing lists, though. :) > > Thanks! > > -Kees > > Kees Cook (12): > slab: Introduce kmalloc_size_roundup() > skbuff: Proactively round up to kmalloc bucket size > net: ipa: Proactively round up to kmalloc bucket size > btrfs: send: Proactively round up to kmalloc bucket size > dma-buf: Proactively round up to kmalloc bucket size > coredump: Proactively round up to kmalloc bucket size > igb: Proactively round up to kmalloc bucket size > openvswitch: Proactively round up to kmalloc bucket size > x86/microcode/AMD: Track patch allocation size explicitly > iwlwifi: Track scan_cmd allocation size explicitly > slab: Remove __malloc attribute from realloc functions > slab: Restore __alloc_size attribute to __kmalloc_track_caller > > arch/x86/include/asm/microcode.h | 1 + > arch/x86/kernel/cpu/microcode/amd.c | 3 +- > drivers/dma-buf/dma-resv.c | 9 +++- > drivers/net/ethernet/intel/igb/igb_main.c | 1 + > drivers/net/ipa/gsi_trans.c | 7 ++- > drivers/net/wireless/intel/iwlwifi/dvm/dev.h | 1 + > drivers/net/wireless/intel/iwlwifi/dvm/scan.c | 10 +++- > drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 3 +- > drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 3 +- > drivers/net/wireless/intel/iwlwifi/mvm/scan.c | 6 +-- > fs/btrfs/send.c | 11 +++-- > fs/coredump.c | 7 ++- > include/linux/compiler_types.h | 13 ++---- > include/linux/slab.h | 46 ++++++++++++++++--- > mm/slab_common.c | 17 +++++++ > net/core/skbuff.c | 34 +++++++------- > net/openvswitch/flow_netlink.c | 4 +- > 17 files changed, 125 insertions(+), 51 deletions(-) >