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 92DF8ECAAD8 for ; Thu, 22 Sep 2022 21:49:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA898940008; Thu, 22 Sep 2022 17:49:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C303E940007; Thu, 22 Sep 2022 17:49:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD1A6940008; Thu, 22 Sep 2022 17:49:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9E5DA940007 for ; Thu, 22 Sep 2022 17:49:12 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 62DC4A047F for ; Thu, 22 Sep 2022 21:49:12 +0000 (UTC) X-FDA: 79941062544.28.91F8D08 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf01.hostedemail.com (Postfix) with ESMTP id 14C8440012 for ; Thu, 22 Sep 2022 21:49:11 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id x1so10055503plv.5 for ; Thu, 22 Sep 2022 14:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date; bh=HR7XDnra6aPtamhjv2ZebPHNXJTov7JqNOvsimryjio=; b=SzXIxv6C1tCw5E3cmrWDJ/hT6jlBfbW+dFuRj81LBsGuMMA1AsgUJRpxwVsVSvwR2s HjojE3kOc43go5tDIXGrMTl5j+2eCPTyOeyLkDKEdQ6zWs58EaHgr7cs3m2ezx/7gyPH QYSAs2hvSa7UX6V/rYFn8OuKvubD7Tx83ZZcc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=HR7XDnra6aPtamhjv2ZebPHNXJTov7JqNOvsimryjio=; b=CByQIGIbgjV2g/tibpc8MXeM+2mN99wX1cDiFgI7S/ARhLiouee4MYhcLpPpWaeKk6 7cYs+/ZXcTXUvRvVi0l+Wuj0jur29veOciy/Bnbop1zU8uVSV1MQLIkAUIhAiNODS6sl FlCDlB2OuGRAU+fv1p1bIwSm1L4AseasxavcFN4N7VC/CfUWCdzoe13KKYqYHZG5ncoH yLoE7VRKbXhVIknSBeAzGUtQNzUIarOyy7mlfyK9DYOpqC3ACcma3UaHufQ5Xrg9EHe0 xTwtV1lhWMo6B2TKz25mqyWEBoi9sq3U59Bj4UAHkYAvJvtX7SwUBCLK+5ElEwpz5Ocl 4rww== X-Gm-Message-State: ACrzQf3vnDMkbLth2xsjoaB4VZLvsepRK9x7rtKc+80AFPErWU/tnbjW Ss4hhdd6D30ff3IUnJBkKjy7cw== X-Google-Smtp-Source: AMsMyM7EVCvewBY8ReI9lCX0qEaIkOeoxfNJfZf95NgQUB74fHJwtUZioqBUOFwe31SWjNTGJEPjqg== X-Received: by 2002:a17:902:d2d2:b0:177:4940:cc0f with SMTP id n18-20020a170902d2d200b001774940cc0fmr5257349plc.4.1663883350927; Thu, 22 Sep 2022 14:49:10 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id j6-20020a170902da8600b00176acc23a73sm4597636plx.281.2022.09.22.14.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 14:49:10 -0700 (PDT) Date: Thu, 22 Sep 2022 14:49:08 -0700 From: Kees Cook To: Vlastimil Babka Cc: Christian =?iso-8859-1?Q?K=F6nig?= , Pekka Enberg , Feng Tang , 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 , 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, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: Re: [PATCH 00/12] slab: Introduce kmalloc_size_roundup() Message-ID: <202209221446.5E90AEED@keescook> References: <20220922031013.2150682-1-keescook@chromium.org> <673e425d-1692-ef47-052b-0ff2de0d9c1d@amd.com> <202209220845.2F7A050@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663883352; a=rsa-sha256; cv=none; b=c1K+yVMdD80TQI5nMQ6ei/oZFy/CYMJwwId/x2KooP3zLHbB7mNHD23vVD6Mawi/Ndg04D oxFQyaYI08XMth4Ddm+q/Zn2VZuzFXLKiHrmGqnsUR8Mmd+em5ETOB+euYf2l3pF8HGhkU 1ZxHXIkLujyenvWKZVt4T+0QJEiHP50= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=SzXIxv6C; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf01.hostedemail.com: domain of keescook@chromium.org designates 209.85.214.175 as permitted sender) smtp.mailfrom=keescook@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663883352; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HR7XDnra6aPtamhjv2ZebPHNXJTov7JqNOvsimryjio=; b=QOBsfWMmJnRyZa1nNiT3i9yPYMJ/8HjUnFLTOeufKNUQ+gbRrJXwBxltxBp6/7LlMHWw0U yb9zGLDwleT3SFMDQa0qzsc+Evozg6IX/8tgH4kW2I7l2iC2qii+rcMyBC0kvRNMwKH35z Y7ZDgJMknmsYhYmSkyxa3QrDqpEAQCI= X-Rspamd-Server: rspam04 X-Rspam-User: X-Rspamd-Queue-Id: 14C8440012 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=SzXIxv6C; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf01.hostedemail.com: domain of keescook@chromium.org designates 209.85.214.175 as permitted sender) smtp.mailfrom=keescook@chromium.org X-Stat-Signature: kduya59m9ymj3oyusynru6ykzap69pt9 X-HE-Tag: 1663883351-339197 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 Thu, Sep 22, 2022 at 11:05:47PM +0200, Vlastimil Babka wrote: > On 9/22/22 17:55, Kees Cook wrote: > > On Thu, Sep 22, 2022 at 09:10:56AM +0200, Christian König wrote: > > [...] > > > 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. > > > > Yeah, my goal would be to eliminate ksize(), and it seems possible if > > other cases are satisfied with tracking their allocation sizes directly. > > I think we could leave ksize() to determine the size without a need for > external tracking, but from now on forbid callers from using that hint to > overflow the allocation size they actually requested? Once we remove the > kasan/kfence hooks in ksize() that make the current kinds of usage possible, > we should be able to catch any offenders of the new semantics that would appear? That's correct. I spent the morning working my way through the rest of the ksize() users I didn't clean up yesterday, and in several places I just swapped in __ksize(). But that wouldn't even be needed if we just removed the kasan unpoisoning from ksize(), etc. I am tempted to leave it __ksize(), though, just to reinforce that it's not supposed to be used "normally". What do you think? -- Kees Cook