Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp579932lqh; Fri, 31 May 2024 09:49:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXOEVY34QhR5eZimuFe5XVFfF2KGUPYRgTVE6IM2W9aCMAV8IeXTGXNTDbJq5GWiZUvYDB6WaniRRRS9GcEcZZBQS3fql3P7C5QLbrjdA== X-Google-Smtp-Source: AGHT+IEHU+9vZqBDnIFprU8OAVf70E95+3kZbpRPZaUYRFuMM+aDQ5hpYdMRJ1DMfHjGKggWBT9i X-Received: by 2002:a05:620a:9db:b0:794:9ab7:7ef9 with SMTP id af79cd13be357-794f5c7c75bmr214849785a.20.1717174190742; Fri, 31 May 2024 09:49:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717174190; cv=pass; d=google.com; s=arc-20160816; b=MX/Xz58x82/LkeDoBtPIzBDTRHBh3GajqoNQo6LYw4IbLSFqunVTQX8vaKH7wUk1Nu /jvMDM+dAs+F6TSqfMGgWMPX9HYXsgy4rnhITqD1oIy2Dzn9pPOnylIwRrHoc3ZFlvRe 8ZUbHbu3NP7kYdoxzS8qIxq2wtPEiOwYCPU/iaN70iQcQgWI7xTOBpxbjD2DKAnk9RZs l1wUPPC2IyanXjq6cwU7N+4RTt5twVkGYG0dpwUhDyx3+49fy9Ps9TA3MI4XY0tJih3F t7+mTAUkqTrCXnuGhEa5+IDW1oiZWy0+Ffh9qff339kDOM9gzf2tc7BHKTW8T126vZ18 oFbA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=29vk2gJr4Loo22NlID5VIANKOSHLbXd4LOF/hsULovg=; fh=M3m3gcudhIdw5cZjEYErE7N6fQbYN+v22srE4vgu5/Q=; b=zsjZSSGiIwr8mckj7kf1Z/4OdG6D7ClAhiq3VtN7/l65SJYocGKNxP+VBDW92rPnD9 ZR7haImn4XyYEQOLcIQM9ixafv51RYqGWxhH9wcAHMPJLroocw+6X1lMhyg0g1Qx2gG5 6j4nlNiY9qhmBwkCzNZDoh5DG08UAksDxPYd7tCww0ca2RP/JViulqQZRlmFoiKeMjk+ s04iaeScI0I5LWcnA1Tw43t4vmmETWPhZ1K6DPS4H3WPp3X9EV17fQTBatHQTcuG5stE 9hHnTqshVuWswoCUrZdEcakGKs8n4+AOtswO9gMhBnIjf4Yd7ULghBQXHhGlfciNt3ZF f0Mg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NbobTXkM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197189-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197189-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43ff23ac36dsi12615601cf.62.2024.05.31.09.49.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 09:49:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197189-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NbobTXkM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-197189-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197189-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E43511C258FD for ; Fri, 31 May 2024 16:49:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 614A016DECA; Fri, 31 May 2024 16:48:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NbobTXkM" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E7437F7F7; Fri, 31 May 2024 16:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717174130; cv=none; b=EEJqtvCo2JJ+xF7W/4/ZKfEnGnrrnRv9twval+ztsjK121msC9kEOGfoIxHqp/VuvRDew7Z2bHyGpcqWUqFrYugy9X3f3QgD006KLRZenX1atTeLce4LbGZyMKEwgtcjMaIHW2V7kSVaqq0lMkevIRZGSV+F/wzG3nYY48z0RdU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717174130; c=relaxed/simple; bh=7NIOshqsMg6hd7t1Z6w0jLoqyFdwJa2iySu2w9THERY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iRj+TPe9lNl9lSgl1qJ5wiiECnIzGCU9Ap/ekJLGphXK9BMGMbrFKwHPQ41W/to5E3d+CaxGSChnT9x0xdvu9UsRElm4Sum9kE/109tSW87cLmd8CGE8PYPdEn+rKQbYQc3dS24/ce5xQm5pKh+RT1OMP+A7FeA0uHddXO+fMWU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NbobTXkM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0E9DC116B1; Fri, 31 May 2024 16:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717174130; bh=7NIOshqsMg6hd7t1Z6w0jLoqyFdwJa2iySu2w9THERY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NbobTXkMaJCoz8B1Mrm3hCVPLVj/NtKblGSDve2mUncZusGL8g4sYRgASjGF0gVvM uCXWBjYEm5z39Dpy2JAiFmaQH9YjEoZJx/22LEC+tlKiTV3D2lngXBWtn+0l//J/Nd 47LbbMukEOiDqfEhkwK3kbyMXEX1/0Zt6eKey2ulLmMiQM8P7RTt8rpvMrnmXTvaAm S9MNZ241fc2loO7sYCqfh9pZ3K5HmYz4V9Pn0k4rJmI/QJ5KnIWoWAd1GkEwXj8lMN LepKOZmBmhsp4aKFd8NIVqnJEqpqHfqEsXEoTdu12NZmcSESILKLamATqeIiup3/Wd OpMQ38+d7Dz/Q== Date: Fri, 31 May 2024 09:48:49 -0700 From: Kees Cook To: Kent Overstreet Cc: Vlastimil Babka , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-hardening@vger.kernel.org, "GONG, Ruiqi" , Xiu Jianfeng , Suren Baghdasaryan , Jann Horn , Matteo Rizzo , Thomas Graf , Herbert Xu , julien.voisin@dustri.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/6] mm/slab: Plumb kmem_buckets into __do_kmalloc_node() Message-ID: <202405310943.D9818A4FE@keescook> References: <20240424213019.make.366-kees@kernel.org> <20240424214104.3248214-2-keescook@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, May 24, 2024 at 11:01:40AM -0400, Kent Overstreet wrote: > On Wed, Apr 24, 2024 at 02:40:59PM -0700, Kees Cook wrote: > > To be able to choose which buckets to allocate from, make the buckets > > available to the lower level kmalloc interfaces by adding them as the > > first argument. Where the bucket is not available, pass NULL, which means > > "use the default system kmalloc bucket set" (the prior existing behavior), > > as implemented in kmalloc_slab(). > > I thought the plan was to use codetags for this? That would obviate the > need for all this plumbing. > > Add fields to the alloc tag for: > - allocation size (or 0 if it's not a compile time constant) > - union of kmem_cache, kmem_buckets, depending on whether the > allocation size is constant or not I want to provide "simple" (low-hanging fruit) coverage that can live separately from the codetags-based coverage. The memory overhead for this patch series is negligible, but I suspect the codetags expansion, while not giant, will be more than some deployments will want. I want to avoid an all-or-nothing solution -- which is why I had intended this to be available "by default". But I will respin this with kmem_buckets under a Kconfig. -- Kees Cook