From: Takashi Iwai <tiwai@suse.de>
To: Karsten Wiese <annabellesgarden@yahoo.de>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu,
alsa-devel@lists.sourceforge.net
Subject: Re: [PATCH] Reset file->f_op in snd_card_file_remove(). Take 2
Date: Fri, 29 Sep 2006 12:48:02 +0200 [thread overview]
Message-ID: <s5hmz8j3q59.wl%tiwai@suse.de> (raw)
In-Reply-To: <200609282228.02611.annabellesgarden@yahoo.de>
At Thu, 28 Sep 2006 22:28:02 +0200,
Karsten Wiese wrote:
>
> Hi
>
> It oopses with 2.6.18-rt4 + alsa-kernel-1.0.13rc3 now.
> I wrote before, 2.6.18-rt3 + alsa-driver-1.0.13rc3 would be ok,
> but its not. bug showed again reliably under memory-pressure.
>
> Karsten
>
> ===
>
> Reset file->f_op in snd_card_file_remove(). Take 2
>
>
> i think what happens here is:
>
> us428control runs, kernel has allocated a struct file for /dev/hwC1D0.
>
> usb disconnect
>
> snd_usb_usx2y calls snd_card_disconnect,
> tells us428control to exit.
>
> snd_card_disconnect replaces /dev/hwC1D0's file->f_op
> with a kmalloc()ed version, that would only allow releases.
>
> us428control starts exiting
>
> __fput is called with struct file for /dev/hwC1D0.
>
> snd_card_file_remove() is called, alsa notices struct file
> for /dev/hwC1D0 is about to be closed.
> with patch below, file->f_op would be set NULL now.
>
> snd_usb_usx2y's free()s snd_card instance and /dev/hwC1D0's
> file->f_ops, those that would only allow releases.
>
> for reason I would like to know,
> __fput is called again with struct file for /dev/hwC1D0
> from us428control's do_exit().
> __fput see's file->f_op is still set.
> Without patch and under memory pressure, file->f_op can
> point to anything now.
>
>
> Signed-off-by: Karsten Wiese <annabellesgarden@yahoo.de>
I guess this bug is fixed by Florin's patch below, juding from your
explanation. Could you check it?
Takashi
Subject: [PATCH] Dereference after free in snd_hwdep_release()
From: Florin Malita <fmalita@gmail.com>
Date: Thu, 28 Sep 2006 19:45:50 -0400
snd_card_file_remove() may free hw->card so we can't dereference
hw->card->module after that.
Coverity ID 1420.
Signed-off-by: Florin Malita <fmalita@gmail.com>
---
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index 9aa9d94..46b4768 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -158,6 +158,7 @@ static int snd_hwdep_release(struct inod
{
int err = -ENXIO;
struct snd_hwdep *hw = file->private_data;
+ struct module *mod = hw->card->module;
mutex_lock(&hw->open_mutex);
if (hw->ops.release) {
err = hw->ops.release(hw, file);
@@ -167,7 +168,7 @@ static int snd_hwdep_release(struct inod
hw->used--;
snd_card_file_remove(hw->card, file);
mutex_unlock(&hw->open_mutex);
- module_put(hw->card->module);
+ module_put(mod);
return err;
}
next prev parent reply other threads:[~2006-09-29 10:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-28 20:28 Karsten Wiese
2006-09-29 10:48 ` Takashi Iwai [this message]
2006-09-29 12:29 ` Karsten Wiese
2006-09-29 12:26 ` Ingo Molnar
2006-09-29 12:45 ` Takashi Iwai
2006-10-01 18:29 ` Karsten Wiese
2006-10-04 9:22 ` Takashi Iwai
[not found] ` <200610041247.19624.annabellesgarden@yahoo.de>
2006-10-04 14:18 ` Takashi Iwai
2006-10-04 15:36 ` Karsten Wiese
2006-10-04 15:57 ` Takashi Iwai
2006-10-04 20:01 ` Karsten Wiese
2006-10-04 20:15 ` Takashi Iwai
2006-10-04 23:41 ` Karsten Wiese
2006-10-05 10:43 ` [Alsa-devel] " Takashi Iwai
2006-10-05 11:33 ` Karsten Wiese
2006-10-05 14:12 ` Karsten Wiese
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=s5hmz8j3q59.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@lists.sourceforge.net \
--cc=annabellesgarden@yahoo.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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
all inboxes | Powered by JetHome®