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] [day] [month] [year] [list]
Message-ID: <9b05914d-34f0-4149-b715-b4af6bba6701@perex.cz>
Date: Tue, 28 Oct 2025 12:39:38 +0100
From: Jaroslav Kysela <perex@...ex.cz>
To: Maciej Strozek <mstrozek@...nsource.cirrus.com>,
 Takashi Iwai <tiwai@...e.de>
Cc: ALSA development <alsa-devel@...a-project.org>,
 patches@...nsource.cirrus.com,
 "linux-sound@...r.kernel.org" <linux-sound@...r.kernel.org>,
 Kernel development <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] ALSA: sound: Increase max size of components field

On 10/27/25 12:50, Maciej Strozek wrote:
> W dniu pon, 27.10.2025 o godzinie 10∶04 +0100, użytkownik Takashi Iwai
> napisał:
>> On Thu, 23 Oct 2025 13:56:26 +0200,
>> Jaroslav Kysela wrote:
>>>
>>> Or, we may introduce a separate ioctl for the components string.
>>> The
>>> stripped components string in struct snd_ctl_card_info may have a
>>> special ASCII mark like '>' at the end of string specifying the
>>> availability of the complete string through another ioctl. I would
>>> prefer this solution.
>>>
>>> Also, the components string may be dynamic in the kernel structure
>>> (pointer) to save some space. 256 bytes is not small number.
>>
>> As Jaroslav suggested, we need a different solution to keep the
>> compatibility.
>>
>> My gut feeling is for the option to provide a new ioctl as it can be
>> most straightforward, but we can discuss further which is the good
>> choice.
>>
> 
> Thank you for the advice! Not sure if I understand Jaroslav's new ioctl
> approach properly, can you have a look at the quick draft below and say
> if this is (more or less) what you would expect? If it is OK then I
> will prepare a proper V2 patch here with a corresponding change for
> alsa-lib repo too.
> 
> 
> diff --git a/include/sound/core.h b/include/sound/core.h
> index 0eb2e3ee0dd5..c4e52fb1704b 100644
> --- a/include/sound/core.h
> +++ b/include/sound/core.h
> @@ -88,7 +88,9 @@ struct snd_card {
>          char irq_descr[32];             /* Interrupt description */
>          char mixername[80];             /* mixer name */
>          char components[256];           /* card components delimited
> with
> -                                                               space
> */
> +                                                       space */
> +       char *components_pointer;       /* full components string */

Keep only this, remove the array and don't use the length member (null 
terminated string).

> +       size_t components_pointer_len;  /* length of full components
> string */
>          struct module *module;          /* top-level module */
>   
>          void *private_data;             /* private data for soundcard
> */
> @@ -297,6 +299,7 @@ int snd_card_info_init(void);
>   int snd_card_add_dev_attr(struct snd_card *card,
>                            const struct attribute_group *group);
>   int snd_component_add(struct snd_card *card, const char *component);
> +int snd_card_add_components(struct snd_card *card, const char
> *component);
>   int snd_card_file_add(struct snd_card *card, struct file *file);
>   int snd_card_file_remove(struct snd_card *card, struct file *file);
>   
> diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
> index c302698fb685..7d53f6da59e2 100644
> --- a/include/uapi/sound/asound.h
> +++ b/include/uapi/sound/asound.h

...

> +struct snd_ctl_card_components {
> +       int len;
> +       unsigned char *components;
>   };

Use array here. It makes things simpler. Perhaps, we can use 512 bytes / 
characters here to avoid future problems.

>   int snd_component_add(struct snd_card *card, const char *component)
>   {
>          char *ptr;
>          int len = strlen(component);
> +       int new_len;
> +       char *buffer;
>   
>          ptr = strstr(card->components, component);
>          if (ptr != NULL) {
> @@ -1035,8 +1040,28 @@ int snd_component_add(struct snd_card *card,
> const char *component)
>                          return 1;
>          }
>          if (strlen(card->components) + 1 + len + 1 > sizeof(card-
>> components)) {

I don't think that it's the right place to do the striping here. Just keep the 
full string in snd_card structure and handle the split/trim in 
snd_ctl_card_info().

The new ioctl should return the full components string.

					Jaroslav

-- 
Jaroslav Kysela <perex@...ex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ