lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <a07c4a5e-1668-3609-334c-8aee2834ff90@gmail.com> Date: Mon, 26 Sep 2022 11:29:20 +0200 From: Christian König <ckoenig.leichtzumerken@...il.com> To: Kees Cook <keescook@...omium.org>, Vlastimil Babka <vbabka@...e.cz> Cc: Sumit Semwal <sumit.semwal@...aro.org>, Christian König <christian.koenig@....com>, linux-media@...r.kernel.org, dri-devel@...ts.freedesktop.org, linaro-mm-sig@...ts.linaro.org, "Ruhl, Michael J" <michael.j.ruhl@...el.com>, Hyeonggon Yoo <42.hyeyoo@...il.com>, Christoph Lameter <cl@...ux.com>, Pekka Enberg <penberg@...nel.org>, David Rientjes <rientjes@...gle.com>, Joonsoo Kim <iamjoonsoo.kim@....com>, Andrew Morton <akpm@...ux-foundation.org>, "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Nick Desaulniers <ndesaulniers@...gle.com>, Alex Elder <elder@...nel.org>, Josef Bacik <josef@...icpanda.com>, David Sterba <dsterba@...e.com>, Jesse Brandeburg <jesse.brandeburg@...el.com>, Daniel Micay <danielmicay@...il.com>, Yonghong Song <yhs@...com>, Marco Elver <elver@...gle.com>, Miguel Oj eda <ojeda@...nel.org>, linux-kernel@...r.kernel.org, linux-mm@...ck.org, netdev@...r.kernel.org, linux-btrfs@...r.kernel.org, linux-fsdevel@...r.kernel.org, intel-wired-lan@...ts.osuosl.org, dev@...nvswitch.org, x86@...nel.org, llvm@...ts.linux.dev, linux-hardening@...r.kernel.org Subject: Re: [Linaro-mm-sig] [PATCH v2 08/16] dma-buf: Proactively round up to kmalloc bucket size Am 23.09.22 um 22:28 schrieb Kees Cook: > 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: Sumit Semwal <sumit.semwal@...aro.org> > Cc: "Christian König" <christian.koenig@....com> > Cc: linux-media@...r.kernel.org > Cc: dri-devel@...ts.freedesktop.org > Cc: linaro-mm-sig@...ts.linaro.org > Signed-off-by: Kees Cook <keescook@...omium.org> Reviewed-by: Christian König <christian.koenig@....com> > --- > drivers/dma-buf/dma-resv.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c > index 205acb2c744d..5b0a4b8830ff 100644 > --- a/drivers/dma-buf/dma-resv.c > +++ b/drivers/dma-buf/dma-resv.c > @@ -98,12 +98,17 @@ static void dma_resv_list_set(struct dma_resv_list *list, > static struct dma_resv_list *dma_resv_list_alloc(unsigned int max_fences) > { > struct dma_resv_list *list; > + size_t size; > > - list = kmalloc(struct_size(list, table, max_fences), GFP_KERNEL); > + /* Round up to the next kmalloc bucket size. */ > + size = kmalloc_size_roundup(struct_size(list, table, max_fences)); > + > + list = kmalloc(size, GFP_KERNEL); > if (!list) > return NULL; > > - list->max_fences = (ksize(list) - offsetof(typeof(*list), table)) / > + /* Given the resulting bucket size, recalculated max_fences. */ > + list->max_fences = (size - offsetof(typeof(*list), table)) / > sizeof(*list->table); > > return list;
Powered by blists - more mailing lists