Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8895711rwi; Tue, 25 Oct 2022 12:14:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6XxfVXHWCZk7lRbNJrxvPOU5iANUa5CvQsVf6bgcLP6HYxWiVy2IRl/ZbJBA+Hl7BmIAJP X-Received: by 2002:a05:6a00:24d2:b0:567:3c7d:d888 with SMTP id d18-20020a056a0024d200b005673c7dd888mr39699110pfv.33.1666725244725; Tue, 25 Oct 2022 12:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666725244; cv=none; d=google.com; s=arc-20160816; b=z78PtioOJ9i0cQriRHBbOtRF9J/b3c49o8O9vZCSb3a650O9wyoC42YJHwxsO8xPkw /loUNl55E/qi4E45eTlz5PzNGTfqCB8Jw3UsPR+spsCwURRg59wAaJCbVT5RS8hOsrzs 90eJWRzexMS6xSb/AOcmejlG9f4ZWidyxlpZOtqUrgfh9Y5mhpHTIs5ge+xsaFNPyGqg XhwjYpWEMDEcDMnc4nGOhbwwU6vULx8uiMX9apHFyan9quVI/Roi6bsUmGLngwOFmv10 5wdehLmD4jKUD6fZxWVHYh9l1AAEpVcm1ZrISMQvOz1qwBqScGy2Rc1VCmiaZVg2woOL yelw== 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=j6v7OmtMJ2b16XOxoV0FAPi5R9UZMGGxZ5W+ahrXitU=; b=H9HG64fdDJIpiDpoDLoMd8yw/nIHLBgm9WWnsnAbyFth+3tDJwCmF8ZR01jPn0NgHj fgbeFUJKnZVPvnj3+0B+AuwTyXbK9EHzzDEFrpUP7jGpUChGHTd21p5oOlCQwK3JXHwl nIRxVZI4FQzB7PF31Dg/6oopLW4oopJpQo+9W76TDoHdfTmlTHRqMat7wUgJnEdAWBId vwMaBfXP22u5dYmcXD65a+neFixqzypD8J30wmnjPI+dIRjuBDt2DxZrCQAUzxd795ep bMdFpWNOz/1lu9SBLZ9Xo6gw0IdH7hSwjseO3UhpKyzP9z5zdVvnPtgBqtaS113N0LWU u/NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=acruGIdn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020a170903228600b00176bcd1ccf3si3870618plh.591.2022.10.25.12.13.51; Tue, 25 Oct 2022 12:14:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@chromium.org header.s=google header.b=acruGIdn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231351AbiJYSiM (ORCPT + 99 others); Tue, 25 Oct 2022 14:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbiJYSiK (ORCPT ); Tue, 25 Oct 2022 14:38:10 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4C1EF036E for ; Tue, 25 Oct 2022 11:38:09 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id j12so11725630plj.5 for ; Tue, 25 Oct 2022 11:38:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=j6v7OmtMJ2b16XOxoV0FAPi5R9UZMGGxZ5W+ahrXitU=; b=acruGIdn9/xBNnQh1BycNFAI8FriRd/SRPwLinDXVN7o5iRN9oVVanxX4jocckw8KE rrBPuGxGWZ6Cez1O8LJl8D6ply4tTfSQNhWiQMsDvh5dJmerpIlgmpxfcO7HCTqyhiz1 5iKemh60aO1Vx52mirB7pUeRtXXBIv5O+XBxQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=j6v7OmtMJ2b16XOxoV0FAPi5R9UZMGGxZ5W+ahrXitU=; b=IT+4CtgfeGkPJRiq9JefkKFN3Diwoa7TX25vzOj1ppgUx8aYT/3ev24PO5oGdB8wmv tQa84XjuhNdVD9NMUoxpSvEQtR7HeN2n2H+6jSPOSavXQ1+OaGEQC8t9K+egFGT78j5v gRXtYXau2RcTtfbNEmvPGeFohOm0boL4XHtaArxR47PnqJc5oKXFPDMlGGlpdPi++SFE gHgfzKu4qq7kofKcyxCynavRk6moRriflFnllQtzZo7v7Ekbv/jms8bJZS+JcQKj4+HA 26hLmyKhNqnrU1ixOyczzoHt6RoSpYJr8U+3cc4XzeHCqSivoH/QzWd0SlLgy0hGVKMS MnWA== X-Gm-Message-State: ACrzQf1mZgAuA7vyyswWfF5MvoktONPtzfXVQ/v12y9k43ca+oLII0tt cRFed+xU7NPHHmO5FjBlV+R3dQ== X-Received: by 2002:a17:903:181:b0:185:5696:97c2 with SMTP id z1-20020a170903018100b00185569697c2mr39858718plg.160.1666723088910; Tue, 25 Oct 2022 11:38:08 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id m3-20020a63fd43000000b004393c5a8006sm1568091pgj.75.2022.10.25.11.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 11:38:08 -0700 (PDT) Date: Tue, 25 Oct 2022 11:38:06 -0700 From: Kees Cook To: Vlastimil Babka Cc: Christoph Lameter , Dmitry Vyukov , Jakub Kicinski , Paolo Abeni , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Vincenzo Frascino , linux-mm@kvack.org, kasan-dev@googlegroups.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] mm: Make ksize() a reporting-only function Message-ID: <202210251125.BAE72214E2@keescook> References: <20221022180455.never.023-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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-kernel@vger.kernel.org On Tue, Oct 25, 2022 at 01:53:54PM +0200, Vlastimil Babka wrote: > On 10/22/22 20:08, Kees Cook wrote: > > With all "silently resizing" callers of ksize() refactored, remove the > > logic in ksize() that would allow it to be used to effectively change > > the size of an allocation (bypassing __alloc_size hints, etc). Users > > wanting this feature need to either use kmalloc_size_roundup() before an > > allocation, or use krealloc() directly. > > > > For kfree_sensitive(), move the unpoisoning logic inline. Replace the > > some of the partially open-coded ksize() in __do_krealloc with ksize() > > now that it doesn't perform unpoisoning. > > > > [...] > > Signed-off-by: Kees Cook > > Acked-by: Vlastimil Babka Thanks! > > --- > > This requires at least this be landed first: > > https://lore.kernel.org/lkml/20221021234713.you.031-kees@kernel.org/ > > Don't we need all parts to have landed first, even if the skbuff one is the > most prominent? Yes, though, I suspect there will be some cases we couldn't easily find. Here are the prerequisites I'm aware of: in -next: 36875a063b5e ("net: ipa: Proactively round up to kmalloc bucket size") ab3f7828c979 ("openvswitch: Use kmalloc_size_roundup() to match ksize() usage") d6dd508080a3 ("bnx2: Use kmalloc_size_roundup() to match ksize() usage") reviewed, waiting to land (should I take these myself?) btrfs: send: Proactively round up to kmalloc bucket size https://lore.kernel.org/lkml/20220923202822.2667581-8-keescook@chromium.org/ dma-buf: Proactively round up to kmalloc bucket size https://lore.kernel.org/lkml/20221018090858.never.941-kees@kernel.org/ partially reviewed: igb: Proactively round up to kmalloc bucket size https://lore.kernel.org/lkml/20221018092340.never.556-kees@kernel.org/ unreviewed: coredump: Proactively round up to kmalloc bucket size https://lore.kernel.org/lkml/20221018090701.never.996-kees@kernel.org/ devres: Use kmalloc_size_roundup() to match ksize() usage https://lore.kernel.org/lkml/20221018090406.never.856-kees@kernel.org/ needs updating: mempool: Use kmalloc_size_roundup() to match ksize() usage https://lore.kernel.org/lkml/20221018090323.never.897-kees@kernel.org/ bpf: Use kmalloc_size_roundup() to match ksize() usage https://lore.kernel.org/lkml/20221018090550.never.834-kees@kernel.org/ -- Kees Cook