All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vinod.koul@intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: liam.r.girdwood@linux.intel.com, patches.audio@intel.com,
	alsa-devel@alsa-project.org, broonie@kernel.org
Subject: Re: [PATCH] amixer: add support for TLV byte control read
Date: Fri, 29 Jan 2016 16:43:47 +0530	[thread overview]
Message-ID: <20160129111347.GT11130@localhost> (raw)
In-Reply-To: <20160129065106.GS11130@localhost>

On Fri, Jan 29, 2016 at 12:21:06PM +0530, Vinod Koul wrote:
> On Thu, Jan 28, 2016 at 05:19:21PM +0100, Takashi Iwai wrote:
> > The line number doesn't match with the latest code in git, so
> > double-check that the problem happens with the latest alsa-lib and
> > alsa-utils, too.
> 
> I am on debian packages 1.0.27
> 
> > I'm thinking whether this is rather an issue in the kernel driver
> > side.  In skl_tplg_tlv_control_get(),
> 
> I think you are right, the buffer would overflow which would cause heap to
> go bad and free goes crashing
> 
> > 
> > 	if (bc->params) {
> > 		if (copy_to_user(data, &bc->param_id, sizeof(u32)))
> > 			return -EFAULT;
> > 		if (copy_to_user(data + 1, &size, sizeof(u32)))
> > 			return -EFAULT;
> > 		if (copy_to_user(data + 2, bc->params, size))
> > 			return -EFAULT;
> > 	}
> > 
> > But here, size is the size of the whole container, not the size in the
> > container.  In the code above, you're copying size+8 bytes total and
> > this breaks the boundary already.
> 
> Right, also I think we need to check for size vs size of parameters. We
> don't want to copy kernel memory to usermode if usermode gave a larger
> buffer
> 
> Let me test this, thanks for pointing

And you were right :)

with this change it works and dumps 4K bytes on my screen

@@ -913,6 +913,13 @@ static int skl_tplg_tlv_control_get(struct snd_kcontrol
*kcontrol,
                skl_get_module_params(skl->skl_sst, (u32 *)bc->params,
                                      bc->max, bc->param_id, mconfig);

+       /* decrement size for TLV header */
+       size -= 2 * sizeof(u32);
+
+       /* check size as we don't want to send kernel data */
+       if (size > bc->max)
+               size = bc->max;
+
        if (bc->params) {
                if (copy_to_user(data, &bc->param_id, sizeof(u32)))
                        return -EFAULT;

Thanks
-- 
~Vinod

  reply	other threads:[~2016-01-29 11:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-22  5:46 [PATCH] amixer: add support for TLV byte control read Vinod Koul
2016-01-22  6:19 ` Takashi Iwai
2016-01-22  7:46   ` Vinod Koul
2016-01-22  8:09     ` Takashi Iwai
2016-01-22  8:26       ` Takashi Iwai
2016-01-22  9:57         ` Vinod Koul
2016-01-22  9:56       ` Vinod Koul
2016-01-22 10:50         ` Takashi Iwai
2016-01-27 17:47           ` Vinod Koul
2016-01-27 18:49             ` Takashi Iwai
2016-01-28  4:25               ` Vinod Koul
2016-01-28  5:49                 ` Takashi Iwai
2016-01-28  9:26                   ` Vinod Koul
2016-01-28 16:19                     ` Takashi Iwai
2016-01-29  6:51                       ` Vinod Koul
2016-01-29 11:13                         ` Vinod Koul [this message]
2016-01-29 13:17                           ` Takashi Iwai
2016-01-29 13:53                             ` Vinod Koul
2016-01-29 13:53                               ` Takashi Iwai

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=20160129111347.GT11130@localhost \
    --to=vinod.koul@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=patches.audio@intel.com \
    --cc=tiwai@suse.de \
    /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.