All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shaobo <shaobo@cs.utah.edu>
To: linux-media@vger.kernel.org, pawel@osciak.com,
	m.szyprowski@samsung.com, laurent.pinchart@ideasonboard.com
Subject: Problematic code in media/v4l2-core/v4l2-mem2mem.c
Date: Thu, 21 Feb 2019 11:11:32 -0700	[thread overview]
Message-ID: <4c01f7987951d7a66350a069f471c129@cs.utah.edu> (raw)

Hello everyone,

I think I brought up this issue before but didn't resolve it completely. 
Now I'd like to double check this and if we can agree on it, I'd also 
like to submit a patch to fix it. The problem is that function 
`get_queue_ctx` can never return a NULL pointer unless pointer overflow 
occurs, which is very unlikely. To be more specific,

```
static struct v4l2_m2m_queue_ctx *get_queue_ctx(struct v4l2_m2m_ctx 
*m2m_ctx,
						enum v4l2_buf_type type)
{
	if (V4L2_TYPE_IS_OUTPUT(type))
		return &m2m_ctx->out_q_ctx;
	else
		return &m2m_ctx->cap_q_ctx;
}
```

The address returned by this function is either `(char*)m2m_ctx+968` or 
`(char*)m2m_ctx+16`, so for it to be NULL, `m2m_ctx` must be a large 
unsigned value. Yet the return value of this function is NULL-checked, 
for example in v4l2_m2m_get_vq.

Please let me know if it makes sense.

Best,
Shaobo

             reply	other threads:[~2019-02-21 18:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21 18:11 Shaobo [this message]
2019-02-21 21:50 ` Problematic code in media/v4l2-core/v4l2-mem2mem.c Laurent Pinchart
2019-02-22  0:27   ` Shaobo He

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=4c01f7987951d7a66350a069f471c129@cs.utah.edu \
    --to=shaobo@cs.utah.edu \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=pawel@osciak.com \
    /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 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.