Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp82693rwb; Thu, 22 Sep 2022 14:50:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7L/suRIZkrfz7j5NOaRRnxp37aL/cPD61lfJmt3SNTwPxoXYFGS9pz5Bf1YRnkXtG65Jxk X-Received: by 2002:a17:902:e1c2:b0:178:4751:e68e with SMTP id t2-20020a170902e1c200b001784751e68emr5301211pla.121.1663883418642; Thu, 22 Sep 2022 14:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663883418; cv=none; d=google.com; s=arc-20160816; b=YD2WOou60to/s7Q0uk44+FXKTeDIYz9h4HqriCCpfrJnNoRUcJ8ULXzooJDqKMcRft 4jTVhYjv4DwyllauKTEDwAod14/vpTmGlKmMveHyJCbTANb+Yq4OQSI1Wl8VDVd/8mIK kH0ElGqHA4tRmnsCpxELQ42B/71mDaF0per9XemqJOZ8qY4//4wOUZ25mUGNM3OWkazk N4uK0941k+TjcuAH7ELHNM560eosS8wy84ruZamqOnqJ75PxIUMUlKsa/Xvnj0uTMfve iyrMxVu+jfSzAUBjktp1Tbd+Qe5Sw7gCnIaUYKUpPpolKHw2E2sQT9u59sLk1ZyNzEYl I9AA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=HR7XDnra6aPtamhjv2ZebPHNXJTov7JqNOvsimryjio=; b=FZ/xxaHpp7z696qdvUI6BXcdDqvYiUGSxPVGyvb9tgmxxZ1Oymjow6gDS2HGcwcsC5 lXduAL2LwODnhZaac47aC/q04mPchugEdh9FMfn9W/BSiD3aHZZPG4/MjF1lHTvDGcPJ 3VelPBeSekA6Ve6OTR9oO7G9FFQB1l6Mfj3coGVKlFr8mdGJcKxkEbS+GnqFU6+mxLTQ M3YwTVKEd7NjIK69H2WHec+5PqZjBCjPlNUGolfIS30udjTGmc/6ZSKveWbl3+gDJkv9 srDnhVqg2EOgDYhRSDc4hgNditXetuASkwdYBJ2DFILwxmRdDCcsKKdlf4DWpaGWuqmh oaPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SzXIxv6C; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 d36-20020a634f24000000b0043a256f5b17si7866424pgb.555.2022.09.22.14.50.07; Thu, 22 Sep 2022 14:50:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=SzXIxv6C; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 S231583AbiIVVtP (ORCPT + 62 others); Thu, 22 Sep 2022 17:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230102AbiIVVtN (ORCPT ); Thu, 22 Sep 2022 17:49:13 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D5D8EEEA8 for ; Thu, 22 Sep 2022 14:49:11 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id w13so10069626plp.1 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=R90qgFIh87kABvIzjktnPpr7Py94OQ0vbIOUkR1wslIDXgxbkyzuip69rRpjpxTpfR vPrDItfTa4ESuH6JVhF4rWQzHaPphciKsP4vFI7IWLhZNGE3y3dcluiPndOIbiDW7urq PVjtDpROVXksHv/4YPuKbZ5ooX57hiWGwpwxJieCPHgaQwMQ5vq4NLcYfPhEinvYVfRI IeYKjU0LahYc0L3cqbKacEO3MoEAee3bJtM3t+N2E2Q1kCbRM89+Xk4znHvTOG35jYmX Y882u/jrZDXpSBr1MC0qxbG9cx5RJduG2LbWy0AYm7oCuGKVE1uWL1gfOQD3esfHldvM QYzw== X-Gm-Message-State: ACrzQf0jNG7R/p8xPwbJv5emapfa5dWIJV7FIhPdilG8dWiaRFF3g2kj BCTirzMWt3hsytSiTt5Zla68dQ== 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: X-Spam-Status: No, score=-2.1 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 autolearn=unavailable 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-wireless@vger.kernel.org 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