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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3285C38A2D for ; Tue, 25 Oct 2022 18:38:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DA9E8E0002; Tue, 25 Oct 2022 14:38:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 463DB8E0001; Tue, 25 Oct 2022 14:38:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3044A8E0002; Tue, 25 Oct 2022 14:38:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1CD988E0001 for ; Tue, 25 Oct 2022 14:38:11 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C1339AAE2E for ; Tue, 25 Oct 2022 18:38:10 +0000 (UTC) X-FDA: 80060331540.07.329C9CF Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf05.hostedemail.com (Postfix) with ESMTP id 4FB35100010 for ; Tue, 25 Oct 2022 18:38:10 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id z5-20020a17090a8b8500b00210a3a2364fso2033611pjn.0 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=HbJpwrsRXHR9CPXXMUfcG4gwvUnYC2yLSpHIJO25Kn/QZYSi8j7jxckiYQQuw4mT/J duXHG9eCMf23876VhUiVenS1KaFf/4wFzHpt9dezegSML+bR6DCTqqfkyJjplkeefnCZ 7beGGp9M51x6NS58anLl+18WfGI0tmQ48gUjQ0rbkZS1+eXuxm35Pq/cbCHI3+H5q7n+ JnybksKQJxNqfAx8PXzvZGdI6jNEhm0s+ZxsIV31d/V+OULY5FywO3wqWmtxkVmdgETt 6oqUXM+etzbPX4WDS2W/jMgByw9Jr0pzbNa25NfiJZN0uc4JhC1wmAWAU+FXISjAVK2t Odiw== X-Gm-Message-State: ACrzQf3xkVqEBw5LhiuUL3V/n99s9KMl93J2Yx378xYX6+59qb1xbQO7 Ij36uH5M9Rkxa58/pziUDqUnuA== X-Google-Smtp-Source: AMsMyM5rGUo3WGRSfCNWAsvk0fN3/AawwDye31UvQzmNmzr7avz0RZdscsKFX344zjBDmEmPlJNpAA== 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: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666723090; a=rsa-sha256; cv=none; b=rVID3kYLjZVvMGjcomWW8c/yNNUbhtN+zuPeDPc2j5EXGaHwMSbAtteTijaALPUbIBEPH1 lTVoMOEDWPgkW/6TxuaayhwYiDL3R7etAF92BEyHihPYNn8YEoW0vWDEJh88ZXhHZJLWm9 1wxoKF/4hqID/QG0CNOEbmXzw5t5N9s= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=acruGIdn; spf=pass (imf05.hostedemail.com: domain of keescook@chromium.org designates 209.85.216.53 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666723090; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=j6v7OmtMJ2b16XOxoV0FAPi5R9UZMGGxZ5W+ahrXitU=; b=zw1uxOpyYJDHwypeDDXR1wQ2oJl0oX3iJMytHZB7XN6GazU+yYlBWW3Y236sanCLFGsqjK eu/Fqq76F4cKuv3xnbdkacxfoFEWAdXPYXlAqt1ghczeEMjMldxWjO9HqYmRld1w5Rvo4O tBwR8UY9MSEMtlSU4S7RAXlPauvt4zk= X-Rspamd-Queue-Id: 4FB35100010 X-Rspam-User: Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=acruGIdn; spf=pass (imf05.hostedemail.com: domain of keescook@chromium.org designates 209.85.216.53 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam04 X-Stat-Signature: 6rzsxspn5gmfi41rnqrwfqey9oyz5w96 X-HE-Tag: 1666723090-678771 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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