From: Wu Fengguang <fengguang.wu@intel.com>
To: alsa-devel@alsa-project.org
Cc: Takashi Iwai <tiwai@suse.de>, Chaohong Guo <chaohong.guo@intel.com>
Subject: Re: [PATCH] hda: add bounds checking for the codec command fields
Date: Fri, 17 Jul 2009 16:27:03 +0800 [thread overview]
Message-ID: <20090717082703.GA21835@localhost> (raw)
In-Reply-To: <20090717082410.GA20628@localhost>
On Fri, Jul 17, 2009 at 04:24:10PM +0800, Wu Fengguang wrote:
> A recent bug involves passing auto detected >0x7f NID to codec command,
> creating an invalid codec addr field, and finally lead to cmd timeout
> and fall back into single command mode. Jaroslav fixed that bug in
> alc880_parse_auto_config().
>
> It would be safer to further check the bounds of all cmd fields.
>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
> ---
> diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
> index 462e2ce..7d09650 100644
> --- a/sound/pci/hda/hda_codec.c
> +++ b/sound/pci/hda/hda_codec.c
> @@ -150,6 +150,16 @@ make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int direct,
> {
> u32 val;
>
> + if ((direct & ~1) || (nid & ~0x7f) ||
> + (verb & ~0xfff) || (parm & ~0xff)) {
> + printk(KERN_ERR "hda-codec: out of range cmd %x:%x:%x:%x:%x\n",
> + codec->addr, direct, nid, verb, parm);
Maybe we shall simply return here?
> + direct &= 1;
> + nid &= 0x7f;
> + verb &= 0xfff;
> + parm &= 0xff;
> + }
> +
> val = (u32)(codec->addr & 0x0f) << 28;
> val |= (u32)direct << 27;
> val |= (u32)nid << 20;
next prev parent reply other threads:[~2009-07-17 8:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-17 8:24 [PATCH] hda: add bounds checking for the codec command fields Wu Fengguang
2009-07-17 8:27 ` Wu Fengguang [this message]
2009-07-17 8:49 ` [PATCH] hda: add bounds checking for the codec command fields v2 Wu Fengguang
2009-07-17 9:28 ` Takashi Iwai
[not found] ` <BB1F052FCDB1EA468BD99786C8B1ED2C05871FFCB9@PDSMSX501.ccr.corp.intel.com>
[not found] ` <s5hljmn8u52.wl%tiwai@suse.de>
2009-07-17 10:53 ` Takashi Iwai
2009-07-17 11:10 ` Wu Fengguang
2009-07-17 11:05 ` Wu Fengguang
2009-07-20 2:13 ` Guo, Chaohong
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=20090717082703.GA21835@localhost \
--to=fengguang.wu@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=chaohong.guo@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox