From: Liviu Dudau <liviu.dudau@arm.com> To: Zhou Qingyang <zhou1615@umn.edu> Cc: kjlu@umn.edu, "James (Qian) Wang" <james.qian.wang@arm.com>, Mihail Atanassov <mihail.atanassov@arm.com>, Brian Starkey <brian.starkey@arm.com>, David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] drm/komeda: Fix an undefined behavior bug in komeda_plane_add() Date: Wed, 1 Dec 2021 13:28:55 +0000 [thread overview] Message-ID: <Yad4l3HXBRavsE0y@e110455-lin.cambridge.arm.com> (raw) In-Reply-To: <20211201033704.32054-1-zhou1615@umn.edu> On Wed, Dec 01, 2021 at 11:37:03AM +0800, Zhou Qingyang wrote: > In komeda_plane_add(), komeda_get_layer_fourcc_list() is assigned to > formats and used in drm_universal_plane_init(). > drm_universal_plane_init() passes formats to > __drm_universal_plane_init(). __drm_universal_plane_init() further > passes formats to memcpy() as src parameter, which could lead to an > undefined behavior bug on failure of komeda_get_layer_fourcc_list(). > > Fix this bug by adding a check of formats. > > This bug was found by a static analyzer. The analysis employs > differential checking to identify inconsistent security operations > (e.g., checks or kfrees) between two code paths and confirms that the > inconsistent operations are not recovered in the current function or > the callers, so they constitute bugs. > > Note that, as a bug found by static analysis, it can be a false > positive or hard to trigger. Multiple researchers have cross-reviewed > the bug. > > Builds with CONFIG_DRM_KOMEDA=m show no new warnings, > and our static analyzer no longer warns about this code. > > Fixes: 61f1c4a8ab75 ("drm/komeda: Attach komeda_dev to DRM-KMS") > Signed-off-by: Zhou Qingyang <zhou1615@umn.edu> Thanks for the fix! Reviewed-by: Liviu Dudau <liviu.dudau@arm.com> Best regards, Liviu > --- > Changes in v2 > - Use kfree and return instead of using 'goto' > > drivers/gpu/drm/arm/display/komeda/komeda_plane.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c > index d63d83800a8a..aa193c58f4bf 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c > @@ -265,6 +265,10 @@ static int komeda_plane_add(struct komeda_kms_dev *kms, > > formats = komeda_get_layer_fourcc_list(&mdev->fmt_tbl, > layer->layer_type, &n_formats); > + if (!formats) { > + kfree(kplane); > + return -ENOMEM; > + } > > err = drm_universal_plane_init(&kms->base, plane, > get_possible_crtcs(kms, c->pipeline), > -- > 2.25.1 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯
WARNING: multiple messages have this Message-ID (diff)
From: Liviu Dudau <liviu.dudau@arm.com> To: Zhou Qingyang <zhou1615@umn.edu> Cc: David Airlie <airlied@linux.ie>, kjlu@umn.edu, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, "James \(Qian\) Wang" <james.qian.wang@arm.com>, Mihail Atanassov <mihail.atanassov@arm.com> Subject: Re: [PATCH v2] drm/komeda: Fix an undefined behavior bug in komeda_plane_add() Date: Wed, 1 Dec 2021 13:28:55 +0000 [thread overview] Message-ID: <Yad4l3HXBRavsE0y@e110455-lin.cambridge.arm.com> (raw) In-Reply-To: <20211201033704.32054-1-zhou1615@umn.edu> On Wed, Dec 01, 2021 at 11:37:03AM +0800, Zhou Qingyang wrote: > In komeda_plane_add(), komeda_get_layer_fourcc_list() is assigned to > formats and used in drm_universal_plane_init(). > drm_universal_plane_init() passes formats to > __drm_universal_plane_init(). __drm_universal_plane_init() further > passes formats to memcpy() as src parameter, which could lead to an > undefined behavior bug on failure of komeda_get_layer_fourcc_list(). > > Fix this bug by adding a check of formats. > > This bug was found by a static analyzer. The analysis employs > differential checking to identify inconsistent security operations > (e.g., checks or kfrees) between two code paths and confirms that the > inconsistent operations are not recovered in the current function or > the callers, so they constitute bugs. > > Note that, as a bug found by static analysis, it can be a false > positive or hard to trigger. Multiple researchers have cross-reviewed > the bug. > > Builds with CONFIG_DRM_KOMEDA=m show no new warnings, > and our static analyzer no longer warns about this code. > > Fixes: 61f1c4a8ab75 ("drm/komeda: Attach komeda_dev to DRM-KMS") > Signed-off-by: Zhou Qingyang <zhou1615@umn.edu> Thanks for the fix! Reviewed-by: Liviu Dudau <liviu.dudau@arm.com> Best regards, Liviu > --- > Changes in v2 > - Use kfree and return instead of using 'goto' > > drivers/gpu/drm/arm/display/komeda/komeda_plane.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c > index d63d83800a8a..aa193c58f4bf 100644 > --- a/drivers/gpu/drm/arm/display/komeda/komeda_plane.c > +++ b/drivers/gpu/drm/arm/display/komeda/komeda_plane.c > @@ -265,6 +265,10 @@ static int komeda_plane_add(struct komeda_kms_dev *kms, > > formats = komeda_get_layer_fourcc_list(&mdev->fmt_tbl, > layer->layer_type, &n_formats); > + if (!formats) { > + kfree(kplane); > + return -ENOMEM; > + } > > err = drm_universal_plane_init(&kms->base, plane, > get_possible_crtcs(kms, c->pipeline), > -- > 2.25.1 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯
next prev parent reply other threads:[~2021-12-01 13:29 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-30 14:23 [PATCH] drm/komeda: Fix an undefined behavior bug in komeda_plane_add() Zhou Qingyang 2021-11-30 14:23 ` Zhou Qingyang 2021-11-30 18:17 ` Liviu Dudau 2021-11-30 18:17 ` Liviu Dudau 2021-12-01 3:37 ` [PATCH v2] " Zhou Qingyang 2021-12-01 3:37 ` Zhou Qingyang 2021-12-01 13:28 ` Liviu Dudau [this message] 2021-12-01 13:28 ` Liviu Dudau
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=Yad4l3HXBRavsE0y@e110455-lin.cambridge.arm.com \ --to=liviu.dudau@arm.com \ --cc=airlied@linux.ie \ --cc=brian.starkey@arm.com \ --cc=daniel@ffwll.ch \ --cc=dri-devel@lists.freedesktop.org \ --cc=james.qian.wang@arm.com \ --cc=kjlu@umn.edu \ --cc=linux-kernel@vger.kernel.org \ --cc=mihail.atanassov@arm.com \ --cc=zhou1615@umn.edu \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.