linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ricardo Ribalda <ribalda@chromium.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Kees Cook <keescook@chromium.org>,
	ionut_n2001@yahoo.com, Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH] media: uvcvideo: Silence memcpy() run-time false positive warnings
Date: Wed, 22 Feb 2023 14:14:46 +0100	[thread overview]
Message-ID: <CANiDSCtjX6+xZn=YkSfqY8xTi7e=OZWbUNtuJ_d=OreFbrgaog@mail.gmail.com> (raw)
In-Reply-To: <Y+LLeYF7CtLjeLbt@smile.fi.intel.com>

Hi Andy

On Tue, 7 Feb 2023 at 23:07, Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
>
> On Mon, Jan 09, 2023 at 11:46:00AM +0100, Ricardo Ribalda wrote:
> > Hi Laurent
> >
> > I was thinking about something on the line of the attached patch,
> >
> > uvc_frame_header->data could also be replaced with a union.
> >
> > Warning, not tested ;)
>
> ...
>
> > +struct uvc_frame_header {
> > +     u8 length;
> > +     u8 flags;
> > +     u8 data[];
> > +} __packed;
>
> __packed! (See below)
>
> ...
>
> > +             pts = (u32 *) header->data;
>
> Ai-ai-ai.
> Here is just a yellow flag...
>
> ...
>
> >       uvc_dbg(stream->dev, FRAME,
> >               "%s(): t-sys %lluns, SOF %u, len %u, flags 0x%x, PTS %u, STC %u frame SOF %u\n",
> >               __func__, ktime_to_ns(time), meta->sof, meta->length,
> >               meta->flags,
> > +             has_pts ? *pts : 0,
>
> ...and here is a red flag. What you need to have is

Thanks! you are absolutely right :)

Luckily  Laurent merged the original patch not mine.

Regards!

>
>         void *pts;
>         u32 pts_val;
>
>         pts_val = get_unaligned_be32(); // or le32
>
>         ...use pts_val...
>
> > +             has_scr ? scr->scr : 0,
> > +             has_scr ? scr->frame_sof & 0x7ff : 0);
>
>
> --
> With Best Regards,
> Andy Shevchenko
>
>


-- 
Ricardo Ribalda

      reply	other threads:[~2023-02-22 13:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06  6:17 [PATCH] media: uvcvideo: Silence memcpy() run-time false positive warnings Kees Cook
2023-01-06 11:43 ` Ricardo Ribalda
2023-01-06 20:19   ` Kees Cook
2023-01-07  1:42     ` Laurent Pinchart
2023-01-09 10:46       ` Ricardo Ribalda
2023-02-07 22:06         ` Andy Shevchenko
2023-02-22 13:14           ` Ricardo Ribalda [this message]

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='CANiDSCtjX6+xZn=YkSfqY8xTi7e=OZWbUNtuJ_d=OreFbrgaog@mail.gmail.com' \
    --to=ribalda@chromium.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=ionut_n2001@yahoo.com \
    --cc=keescook@chromium.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /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).