From: Takashi Iwai <tiwai@suse.de>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>,
alsa-devel@alsa-project.org,
Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] OSS: keep index within bounds of midi_devs[]
Date: Mon, 16 Nov 2009 17:46:56 +0100 [thread overview]
Message-ID: <s5hfx8eifi7.wl%tiwai@suse.de> (raw)
In-Reply-To: <4B01782E.80802@gmail.com>
At Mon, 16 Nov 2009 17:05:02 +0100,
Roel Kluin wrote:
>
> When the {orig,midi}_dev equals num_midis, that's one too
> large already.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> In MIDIbuf_open() sound/oss/midibuf.c:166
>
> if (num_midis > MAX_MIDI_DEV)
> {
> printk(KERN_ERR "midi: Too many midi interfaces\n");
> num_midis = MAX_MIDI_DEV;
> }
>
> num_midis is at most MAX_MIDI_DEV.
>
> `git grep -n MAX_MIDI_DEV' and note that when the index equals
> num_midis this causes reads/writes outside array bounds for
> midi_devs, midi2synth, dev_conf and others (below check in patch).
The fix looks correct to me. Applied now.
Thanks.
Takashi
>
> sound/oss/midi_synth.c | 2 +-
> sound/oss/mpu401.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/oss/midi_synth.c b/sound/oss/midi_synth.c
> index 9e45098..3bc7104 100644
> --- a/sound/oss/midi_synth.c
> +++ b/sound/oss/midi_synth.c
> @@ -426,7 +426,7 @@ midi_synth_open(int dev, int mode)
> int err;
> struct midi_input_info *inc;
>
> - if (orig_dev < 0 || orig_dev > num_midis || midi_devs[orig_dev] == NULL)
> + if (orig_dev < 0 || orig_dev >= num_midis || midi_devs[orig_dev] == NULL)
> return -ENXIO;
>
> midi2synth[orig_dev] = dev;
> diff --git a/sound/oss/mpu401.c b/sound/oss/mpu401.c
> index 734b8f9..0af9d24 100644
> --- a/sound/oss/mpu401.c
> +++ b/sound/oss/mpu401.c
> @@ -770,7 +770,7 @@ static int mpu_synth_ioctl(int dev, unsigned int cmd, void __user *arg)
>
> midi_dev = synth_devs[dev]->midi_dev;
>
> - if (midi_dev < 0 || midi_dev > num_midis || midi_devs[midi_dev] == NULL)
> + if (midi_dev < 0 || midi_dev >= num_midis || midi_devs[midi_dev] == NULL)
> return -ENXIO;
>
> devc = &dev_conf[midi_dev];
>
prev parent reply other threads:[~2009-11-16 16:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-16 16:05 Roel Kluin
2009-11-16 16:46 ` Takashi Iwai [this message]
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=s5hfx8eifi7.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=roel.kluin@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome