lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 26 Jun 2019 10:27:11 +0200
From:   Takashi Iwai <tiwai@...e.de>
To:     "Evan Green" <evgreen@...omium.org>
Cc:     <alsa-devel@...a-project.org>,
        "Thomas Gleixner" <tglx@...utronix.de>,
        "Amadeusz S*awi*ski" <amadeuszx.slawinski@...ux.intel.com>,
        "Greg Kroah-Hartman" <gregkh@...uxfoundation.org>,
        "Jaroslav Kysela" <perex@...ex.cz>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] ALSA: hda: Use correct start/count for sysfs init

On Tue, 25 Jun 2019 23:54:18 +0200,
Evan Green wrote:
> 
> The normal flow through the widget sysfs codepath is that
> snd_hdac_refresh_widgets() is called once without the sysfs bool set
> to set up codec->num_nodes and friends, then another time with the
> bool set to actually allocate all the sysfs widgets. However, during
> the first time allocation, hda_widget_sysfs_reinit() ignores the new
> num_nodes passed in via parameter and just calls hda_widget_sysfs_init(),
> using whatever was in codec->num_nodes before the update. This is not
> correct in cases where num_nodes changes. Here's an example:
> 
> Sometime earlier:
> snd_hdac_refresh_widgets(hdac, false)
>   sets codec->num_nodes to 2, widgets is still not allocated
> 
> Now:
> snd_hdac_refresh_widgets(hdac, true)
>   hda_widget_sysfs_reinit(num_nodes=7)
>     hda_widget_sysfs_init()
>       widget_tree_create()
>         alloc(codec->num_nodes) // this is still 2
>   codec->num_nodes = 7
> 
> Pass num_nodes and start_nid down into widget_tree_create() so that
> the right number of nodes are allocated in all cases.
> 
> Signed-off-by: Evan Green <evgreen@...omium.org>

Thanks for the patch.  That's indeed a problem, but I guess a simpler
approach is just to return if sysfs didn't exist.  If the sysfs
entries aren't present at the second call with sysfs=true, it implies
that the codec object will be exposed anyway later, and the sysfs will
be created there.  So, something like below would work instead?


thanks,

Takashi

--- a/sound/hda/hdac_sysfs.c
+++ b/sound/hda/hdac_sysfs.c
@@ -428,7 +428,7 @@ int hda_widget_sysfs_reinit(struct hdac_device *codec,
 	int i;
 
 	if (!codec->widgets)
-		return hda_widget_sysfs_init(codec);
+		return 0;
 
 	tree = kmemdup(codec->widgets, sizeof(*tree), GFP_KERNEL);
 	if (!tree)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ