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
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADnq5_O=PAK3qZJ-kHUX9jQDkmEYOX+iOhOX7gNaaXp+tC7nUg@mail.gmail.com>
Date:   Mon, 20 May 2019 22:32:49 -0400
From:   Alex Deucher <alexdeucher@...il.com>
To:     "Pan, Xinhui" <Xinhui.Pan@....com>
Cc:     Daniel Vetter <daniel@...ll.ch>,
        "Zhou, David(ChunMing)" <David1.Zhou@....com>,
        "airlied@...ux.ie" <airlied@...ux.ie>,
        xiaolinkui <xiaolinkui@...inos.cn>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "amd-gfx@...ts.freedesktop.org" <amd-gfx@...ts.freedesktop.org>,
        "dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
        "Deucher, Alexander" <Alexander.Deucher@....com>,
        "Quan, Evan" <Evan.Quan@....com>,
        "Koenig, Christian" <Christian.Koenig@....com>
Subject: Re: [PATCH] gpu: drm: use struct_size() in kmalloc()

On Mon, May 20, 2019 at 7:19 PM Pan, Xinhui <Xinhui.Pan@....com> wrote:
>
> Daniel, what you are talking about is totally wrong.
> 1) AFAIK, only one zero-size array can be in the end of a struct.
> 2) two struct_size will add up struct itself twice. the sum is wrong then.
>
> No offense. I can't help feeling lucky that you are in intel.

Xinhui,

Please keep things civil.  There is no need for comments like this.

Alex

>
>
> 发件人: Daniel Vetter <daniel.vetter@...ll.ch> 代表 Daniel Vetter <daniel@...ll.ch>
> 发送时间: 2019年5月21日 0:28
> 收件人: Pan, Xinhui
> 抄送: Deucher, Alexander; Koenig, Christian; Zhou, David(ChunMing); airlied@...ux.ie; daniel@...ll.ch; Quan, Evan; xiaolinkui; amd-gfx@...ts.freedesktop.org; dri-devel@...ts.freedesktop.org; linux-kernel@...r.kernel.org
> 主题: Re: [PATCH] gpu: drm: use struct_size() in kmalloc()
>
> [CAUTION: External Email]
>
> On Fri, May 17, 2019 at 04:44:30PM +0000, Pan, Xinhui wrote:
> > I am going to put more members which are also array after this struct,
> > not only obj[].  Looks like this struct_size did not help on multiple
> > array case. Thanks anyway.  ________________________________
>
> You can then add them up, e.g. kmalloc(struct_size()+struct_size(),
> GFP_KERNEL), so this patch here still looks like a good idea.
>
> Reviewed-by: Daniel Vetter <daniel.vetter@...ll.ch>
>
> Cheers, Daniel
>
> > From: xiaolinkui <xiaolinkui@...inos.cn>
> > Sent: Friday, May 17, 2019 4:46:00 PM
> > To: Deucher, Alexander; Koenig, Christian; Zhou, David(ChunMing); airlied@...ux.ie; daniel@...ll.ch; Pan, Xinhui; Quan, Evan
> > Cc: amd-gfx@...ts.freedesktop.org; dri-devel@...ts.freedesktop.org; linux-kernel@...r.kernel.org; xiaolinkui@...inos.cn
> > Subject: [PATCH] gpu: drm: use struct_size() in kmalloc()
> >
> > [CAUTION: External Email]
> >
> > Use struct_size() helper to keep code simple.
> >
> > Signed-off-by: xiaolinkui <xiaolinkui@...inos.cn>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> > index 22bd21e..4717a64 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> > @@ -1375,8 +1375,7 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
> >         if (con)
> >                 return 0;
> >
> > -       con = kmalloc(sizeof(struct amdgpu_ras) +
> > -                       sizeof(struct ras_manager) * AMDGPU_RAS_BLOCK_COUNT,
> > +       con = kmalloc(struct_size(con, objs, AMDGPU_RAS_BLOCK_COUNT),
> >                         GFP_KERNEL|__GFP_ZERO);
> >         if (!con)
> >                 return -ENOMEM;
> > --
> > 2.7.4
> >
> >
> >
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@...ts.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ