From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Zhou Qingyang <zhou1615@umn.edu>
Cc: kjlu@umn.edu, Neil Armstrong <narmstrong@baylibre.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Kevin Hilman <khilman@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Maxime Jourdan <mjourdan@baylibre.com>,
linux-media@vger.kernel.org, linux-amlogic@lists.infradead.org,
linux-staging@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] media: meson: vdec: Fix a NULL pointer dereference in amvdec_add_ts()
Date: Tue, 14 Dec 2021 14:46:13 +0100 [thread overview]
Message-ID: <20211214144613.35fec82a@coco.lan> (raw)
In-Reply-To: <20211202160357.75173-1-zhou1615@umn.edu>
Em Fri, 3 Dec 2021 00:03:57 +0800
Zhou Qingyang <zhou1615@umn.edu> escreveu:
> In amvdec_add_ts(), there is a dereference of kzalloc(), which could lead
> to a NULL pointer dereference on failure of kzalloc().
>
> I fix this bug by adding a NULL check of new_ts.
>
> 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_VIDEO_MESON_VDEC=m show no new warnings,
> and our static analyzer no longer warns about this code.
>
> Fixes: 876f123b8956 ("media: meson: vdec: bring up to compliance")
> Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
> ---
> Changes in v2:
> - Delete dev_err() message
>
> drivers/staging/media/meson/vdec/vdec_helpers.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/staging/media/meson/vdec/vdec_helpers.c b/drivers/staging/media/meson/vdec/vdec_helpers.c
> index b9125c295d1d..ac60514c475b 100644
> --- a/drivers/staging/media/meson/vdec/vdec_helpers.c
> +++ b/drivers/staging/media/meson/vdec/vdec_helpers.c
> @@ -234,6 +234,9 @@ void amvdec_add_ts(struct amvdec_session *sess, u64 ts,
> unsigned long flags;
>
> new_ts = kzalloc(sizeof(*new_ts), GFP_KERNEL);
> + if (!new_ts)
> + return;
> +
> new_ts->ts = ts;
> new_ts->tc = tc;
> new_ts->offset = offset;
I don't think this change is ok. Sure, it needs to check if
kzalloc() fails, but it should return -ENOMEM and the caller
should check if it returns an error. So, I would expect
that this patch would also touch the caller function at
drivers/staging/media/meson/vdec/esparser.c.
Regards,
Mauro
Thanks,
Mauro
next prev parent reply other threads:[~2021-12-14 13:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-30 16:12 [PATCH] media: meson: vdec: Fix a NULL pointer dereference in amvdec_add_ts() Zhou Qingyang
2021-12-01 8:41 ` Dan Carpenter
2021-12-02 16:03 ` [PATCH v2] " Zhou Qingyang
2021-12-03 13:30 ` Dan Carpenter
2021-12-14 13:46 ` Mauro Carvalho Chehab [this message]
2021-12-14 14:16 ` Greg Kroah-Hartman
2021-12-15 3:35 ` [PATCH v3] " Zhou Qingyang
2022-01-11 9:16 ` Hans Verkuil
[not found] ` <CA+Cm_xSOv5NnW5GXcKKGi8bQSvT45iH6=65YJk3EG6uW0c5_Vw@mail.gmail.com>
2022-01-12 8:57 ` Neil Armstrong
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=20211214144613.35fec82a@coco.lan \
--to=mchehab@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=kjlu@umn.edu \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=martin.blumenstingl@googlemail.com \
--cc=mjourdan@baylibre.com \
--cc=narmstrong@baylibre.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).