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: Wed, 27 Jan 2016 23:17:52 +0530	[thread overview]
Message-ID: <20160127174749.GB11130@localhost> (raw)
In-Reply-To: <s5hegd9sxb3.wl-tiwai@suse.de>

On Fri, Jan 22, 2016 at 11:50:08AM +0100, Takashi Iwai wrote:
> On Fri, 22 Jan 2016 10:56:48 +0100,
> Vinod Koul wrote:
> > > Hm, it has a check
> > > 
> > > static int snd_ctl_hw_elem_tlv(snd_ctl_t *handle, int op_flag,
> > > 			       unsigned int numid,
> > > 			       unsigned int *tlv, unsigned int tlv_size)
> > > {
> > > 	....
> > > 		if (xtlv->tlv[1] + 2 * sizeof(unsigned int) > tlv_size) {
> > > 			free(xtlv);
> > > 			return -EFAULT;
> > > 		}
> > > 		memcpy(tlv, xtlv->tlv, xtlv->tlv[1] + 2 * sizeof(unsigned int));
> > > 
> > > Do you mean somewhere here triggers a crash?
> > 
> > Yes while it tried to memcpy, in my case 30K sized data to 4K buffer, so I
> > allocated right one and got all the data
> 
> But it has the size check before memcpy()?

Okay I had some issues (yet again) so I rebuilt the ubuntu packages and tools and reran
this.

I get:

$ amixer -c0 cget numid=16
numid=16,iface=MIXER,name='mdl params'
  ; type=BYTES,access=-----RW-,values=30336
amixer: Control hw:0 element TLV read error: Bad address

Segmentation fault (core dumped)

And the alsa-lib returns an err and we try to free up tlv on error which
should be fine here but fails

Why should free cause a failure here (on 1.0.27)

On latest lib from git. I get same failure but in alsa-lib when it tries to
free xtlv on failure of this check

if (xtlv->tlv[1] + 2 * sizeof(unsigned int) > tlv_size) {
                   free(xtlv);

Why would that happen...? What am I missing :(

Also on second thought, even after working around this by setting right size
so that we don't hit failures (this patch), I get my screen spammed by 30K byes so based
on TLV access and bytes type I am thinking to not read and display on cget.

We should add new options for these controls ..

-- 
~Vinod

  reply	other threads:[~2016-01-27 17:44 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 [this message]
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
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=20160127174749.GB11130@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.