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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CB7DC6FA93 for ; Thu, 22 Sep 2022 15:57:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230058AbiIVP55 (ORCPT ); Thu, 22 Sep 2022 11:57:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229734AbiIVP5w (ORCPT ); Thu, 22 Sep 2022 11:57:52 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87323E5FBD for ; Thu, 22 Sep 2022 08:57:49 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id o99-20020a17090a0a6c00b002039c4fce53so2851526pjo.2 for ; Thu, 22 Sep 2022 08:57:49 -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; bh=DFca6W2geua6z8QZaei3L7obYL69ycUV+0eXMSxJFmM=; b=jvl2IXIRx3EhOhhqaTOf5Lt+fk9xx9Irq6xcu/7k7oCaAudZivnlCg4zfyCIBsgQa9 qBtVWGjfuRNfAqWNaj6IsSNxrO0lvCUNMMis5T9m3env78npe1AQYwW4n7mGlSRQHwQP cG9vbxRd7c25yIHtYw1xafxyLneU1vdiRP2x0= 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; bh=DFca6W2geua6z8QZaei3L7obYL69ycUV+0eXMSxJFmM=; b=UzsFgtFWeaDf/41uVXIUAkZmpK6eMwE8IxV31OluCZS16zqefI0TgAP+zSnCGCEh+0 fC7NNfyvTwbsZ0d9wdxK35KjXKMkW8pqsw8rQdHJKhCjrQ/h/p3uIoqXkTBnqd69BS4a wM4+dsrDJXSGVLEYFgEivmmzg4CHTaCuq29VcdDkn4FEPiTjheBT/DqkFg/Ispx4vkhs E9rlutmwBIrbMOWXLf4y4YxlEpugbWd85oLqDfcmkwCvLzm2zJBpyFyhPrxnlG+zs5dK GrMU1b966bCSP/heV7fGFA/Cq8Bmgj+MrvyWbQs/Ivp5KvDjrYU934nqryOmgxYKCC9u klWQ== X-Gm-Message-State: ACrzQf1uTn9Txjz9Im+zq+F93LS77cx8I3mqpDIF+Kc82KNO21oDg3Cs tzwarQf/T35L8fQOBFvGh2CvAg== X-Google-Smtp-Source: AMsMyM4DbOcH8T52s44Y0t4Ur0sebk5QTw9RJNQKJ+FFAkxJV0gLFIOVmBX/n1oFJJpAp4+llFExqQ== X-Received: by 2002:a17:902:e848:b0:176:c746:1f69 with SMTP id t8-20020a170902e84800b00176c7461f69mr3892270plg.125.1663862268452; Thu, 22 Sep 2022 08:57:48 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id p63-20020a625b42000000b005367c28fd32sm4575617pfb.185.2022.09.22.08.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 08:57:47 -0700 (PDT) Date: Thu, 22 Sep 2022 08:57:46 -0700 From: Kees Cook To: Alex Elder Cc: Vlastimil Babka , Alex Elder , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Greg Kroah-Hartman , Nick Desaulniers , Josef Bacik , David Sterba , Sumit Semwal , Christian =?iso-8859-1?Q?K=F6nig?= , Jesse Brandeburg , Daniel Micay , Yonghong Song , Marco Elver , Miguel Ojeda , Jacob Shin , linux-kernel@vger.kernel.org, linux-mm@kvack.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 Subject: Re: [PATCH 03/12] net: ipa: Proactively round up to kmalloc bucket size Message-ID: <202209220857.A6EBCF031E@keescook> References: <20220922031013.2150682-1-keescook@chromium.org> <20220922031013.2150682-4-keescook@chromium.org> <4d75a9fd-1b94-7208-9de8-5a0102223e68@ieee.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4d75a9fd-1b94-7208-9de8-5a0102223e68@ieee.org> Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Thu, Sep 22, 2022 at 08:45:19AM -0500, Alex Elder wrote: > On 9/21/22 10:10 PM, Kees Cook wrote: > > Instead of discovering the kmalloc bucket size _after_ allocation, round > > up proactively so the allocation is explicitly made for the full size, > > allowing the compiler to correctly reason about the resulting size of > > the buffer through the existing __alloc_size() hint. > > > > Cc: Alex Elder > > Cc: "David S. Miller" > > Cc: Eric Dumazet > > Cc: Jakub Kicinski > > Cc: Paolo Abeni > > Cc: netdev@vger.kernel.org > > Signed-off-by: Kees Cook > > --- > > drivers/net/ipa/gsi_trans.c | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c > > index 18e7e8c405be..cec968854dcf 100644 > > --- a/drivers/net/ipa/gsi_trans.c > > +++ b/drivers/net/ipa/gsi_trans.c > > @@ -89,6 +89,7 @@ int gsi_trans_pool_init(struct gsi_trans_pool *pool, size_t size, u32 count, > > u32 max_alloc) > > { > > void *virt; > > + size_t allocate; > > I don't care about this but the reverse Christmas tree > convention would put the "allocate" variable definition > above "virt". Oops, yes; thank you! -Kees -- Kees Cook