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: <20200121092350.466f62a8@litschi.hi.pengutronix.de>
Date:   Tue, 21 Jan 2020 09:23:50 +0100
From:   Michael Tretter <m.tretter@...gutronix.de>
To:     Chuhong Yuan <hslester96@...il.com>
Cc:     Pengutronix Kernel Team <kernel@...gutronix.de>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-media@...r.kernel.org, devel@...verdev.osuosl.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] media: allegro: add missed checks in allegro_open()

On Mon, 13 Jan 2020 13:59:51 +0800, Chuhong Yuan wrote:
> allegro_open() misses checks for v4l2_m2m_ctx_init() and results of
> v4l2_ctrl_new* calls.
> Add checks and error handlers to fix the problems.
> 
> Signed-off-by: Chuhong Yuan <hslester96@...il.com>
> ---
> Changes in v3:
>   - Make code cleaner.
>   - Add a check for handler->error.
> 
>  .../staging/media/allegro-dvt/allegro-core.c  | 24 +++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/media/allegro-dvt/allegro-core.c b/drivers/staging/media/allegro-dvt/allegro-core.c
> index 6f0cd0784786..e86001e42963 100644
> --- a/drivers/staging/media/allegro-dvt/allegro-core.c
> +++ b/drivers/staging/media/allegro-dvt/allegro-core.c
> @@ -2270,15 +2270,12 @@ static int allegro_open(struct file *file)
>  	struct allegro_channel *channel = NULL;
>  	struct v4l2_ctrl_handler *handler;
>  	u64 mask;
> +	int ret;
>  
>  	channel = kzalloc(sizeof(*channel), GFP_KERNEL);
>  	if (!channel)
>  		return -ENOMEM;
>  
> -	v4l2_fh_init(&channel->fh, vdev);
> -	file->private_data = &channel->fh;
> -	v4l2_fh_add(&channel->fh);
> -
>  	init_completion(&channel->completion);
>  
>  	channel->dev = dev;
> @@ -2328,6 +2325,11 @@ static int allegro_open(struct file *file)
>  			V4L2_CID_MIN_BUFFERS_FOR_OUTPUT,
>  			1, 32,
>  			1, 1);
> +	if (handler->error != 0) {
> +		ret = handler->error;
> +		goto error;
> +	}
> +
>  	channel->fh.ctrl_handler = handler;
>  
>  	channel->mcu_channel_id = -1;
> @@ -2341,7 +2343,21 @@ static int allegro_open(struct file *file)
>  	channel->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, channel,
>  						allegro_queue_init);
>  
> +	if (IS_ERR(channel->fh.m2m_ctx)) {
> +		ret = PTR_ERR(channel->fh.m2m_ctx);
> +		goto error;
> +	}
> +
> +	v4l2_fh_init(&channel->fh, vdev);

This call sets channel->fh.ctrl_handler to vdev->ctrl_handler, which
has previously been overriden by the driver to handler. Therefore, this
patch breaks all controls. I think we should initialize channel->fh
before setting any fields of this struct.

Michael

> +	file->private_data = &channel->fh;
> +	v4l2_fh_add(&channel->fh);
> +
>  	return 0;
> +
> +error:
> +	v4l2_ctrl_handler_free(handler);
> +	kfree(channel);
> +	return ret;
>  }
>  
>  static int allegro_release(struct file *file)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ