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 CC152C4332F for ; Wed, 19 Oct 2022 05:37:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E4B046B0072; Wed, 19 Oct 2022 01:37:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DFAC96B0073; Wed, 19 Oct 2022 01:37:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC2E36B0074; Wed, 19 Oct 2022 01:37:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id BC94E6B0072 for ; Wed, 19 Oct 2022 01:37:12 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 769F8402DA for ; Wed, 19 Oct 2022 05:37:11 +0000 (UTC) X-FDA: 80036590662.12.91CB8BD Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf29.hostedemail.com (Postfix) with ESMTP id 14D8A120031 for ; Wed, 19 Oct 2022 05:37:10 +0000 (UTC) Received: by mail-pg1-f169.google.com with SMTP id q9so15277460pgq.8 for ; Tue, 18 Oct 2022 22:37:10 -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=gaB7r0jtcqd2LLd1zpImUKzyF4vb0y3pjRPBPmzYZ4Y=; b=A50nB2myoBrpOIvb3e4Ap+0R9BCF2YinNE2QnvkCYhYLCUUM7DBKYMS6gk092eZU3O B2/fZxbo7disNyN568ZmLcCeHRhHlCeI8yn2kVzs5e32APmmUAzE0roYLmvwX7uXrWTK sK9lV4oZrZg6wGNBET8UFhqJe7sBndgRlCUaE= 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=gaB7r0jtcqd2LLd1zpImUKzyF4vb0y3pjRPBPmzYZ4Y=; b=78LGeUUUPMzL/YP2GJwLjkVxTicJim4Yu7KB4CraFNDo/Vfcazd7XCtcv/qNFIe6hx ixOO0j+hGgednFIatXdpQ13jkM9ydrN0KPafWyhY3RufnJlbst+S0Ch0SN6AzZ1KhhDB JovMB1kSzHSelOsQ+Y/wXxrTAoWnwQ54JFG1WVSRUe8mMSKntLc2+rk4kFS86GdlF7+p UlDYh9xft3VnFkoKtYgP9S6XyxfWmRlLmsP2GzRNj3prcKC8lxuO9q9p7dP+Asejbs72 wudS/Phw87PyC7ZZ0LGiOZP7mMVk8UNklOxNKY2gs5seB4QMc0ZjQm5AtO+qV2P9XgQg RWOQ== X-Gm-Message-State: ACrzQf0QTlQlfytSWSqUsjiXJizi5kdeIgj/TGNKGnW+AFASToArxBGx 5+2hh29UEi0P+XFPNWAOGX4/59nSaUqxcg== X-Google-Smtp-Source: AMsMyM7fiBtyRBbHFGloOmwtzRNGHuoxgWogV6EAP5VJPWG6EE61GeFExwx/EPTvx0a3W+O4+gXIog== X-Received: by 2002:a63:ed0a:0:b0:442:2514:95f5 with SMTP id d10-20020a63ed0a000000b00442251495f5mr5867397pgi.402.1666157829640; Tue, 18 Oct 2022 22:37:09 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id d8-20020a170902cec800b0017f7b6e970esm9799332plg.146.2022.10.18.22.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 22:37:08 -0700 (PDT) Date: Tue, 18 Oct 2022 22:37:07 -0700 From: Kees Cook To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] mempool: Use kmalloc_size_roundup() to match ksize() usage Message-ID: <202210182235.3B19DFCB28@keescook> References: <20221018090323.never.897-kees@kernel.org> <20221018155137.f6898d165aade2e3a5f0b2d3@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221018155137.f6898d165aade2e3a5f0b2d3@linux-foundation.org> ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=A50nB2my; spf=pass (imf29.hostedemail.com: domain of keescook@chromium.org designates 209.85.215.169 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666157831; a=rsa-sha256; cv=none; b=ybTMre25LvgqpFDxLQyYLBuHQmhNWyelP32I0+mUPsBOMjVouxuvHPT3eTyl7RR2h88VND xl8YWn4gswWzNGkaoaIqdyDeb/ysH6J2Fg3zovF/j5BA/oCrn1JxnrTYJLcp2Izw1KCzPH nAr7bAChRRkdmH3wLKK+1mZ26py0SjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666157831; 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=gaB7r0jtcqd2LLd1zpImUKzyF4vb0y3pjRPBPmzYZ4Y=; b=gh2+BLzDSRbjLGVmTFCLxfvqXSNu4nEg8F/Zv1uw3i/RXSXQxBfoHcN5JwCmUeq1Gu/Fcb q8EEA0FCc2PwVU7oP5KYEUvabAmRWFnqBPjkMUum1maO4WT8oYhBKYJMkzGFzZtn5+Q2lS /qwjnUGYSLg9hQfXAtDNapLUn5+RWxk= X-Stat-Signature: pinat4rcp3wo3wrkhn46kbzeen18cqsh X-Rspamd-Queue-Id: 14D8A120031 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=A50nB2my; spf=pass (imf29.hostedemail.com: domain of keescook@chromium.org designates 209.85.215.169 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1666157830-661401 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 18, 2022 at 03:51:37PM -0700, Andrew Morton wrote: > On Tue, 18 Oct 2022 02:03:29 -0700 Kees Cook wrote: > > > Round up allocations with kmalloc_size_roundup() so that mempool's use > > of ksize() is always accurate and no special handling of the memory is > > needed by KASAN, UBSAN_BOUNDS, nor FORTIFY_SOURCE. > > Confused. If the special handling is not needed, why doesn't the patch > removed the no longer needed special handling? The special handling is in the ksize() implementation, so it can't be removed[1] until all the ksize()-affected users are updated to see their true allocation sizes first. [1] https://lore.kernel.org/lkml/20220923202822.2667581-16-keescook@chromium.org/ -- Kees Cook