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]
Message-ID: <4f2f8e14-22d2-44f1-82cd-5f2a3b5117b1@csgroup.eu>
Date: Fri, 13 Jun 2025 14:46:46 +0200
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: Takashi Iwai <tiwai@...e.de>
Cc: Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
 linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
 linux-sound@...r.kernel.org, Herve Codina <herve.codina@...tlin.com>,
 Mark Brown <broonie@...nel.org>
Subject: Re: [RFC PATCH 3/3] ALSA: pcm: Convert snd_pcm_sync_ptr() to
 user_access_begin/user_access_end()



Le 13/06/2025 à 14:37, Takashi Iwai a écrit :
> On Fri, 13 Jun 2025 13:03:04 +0200,
> Christophe Leroy wrote:
>>
>>
>>
>> Le 13/06/2025 à 11:29, Takashi Iwai a écrit :
>>> On Thu, 12 Jun 2025 12:51:05 +0200,
>>> Christophe Leroy wrote:
>>>>
>>>> Now that snd_pcm_sync_ptr_get_user() and snd_pcm_sync_ptr_put_user()
>>>> are converted to user_access_begin/user_access_end(),
>>>> snd_pcm_sync_ptr_get_user() is more efficient than a raw get_user()
>>>> followed by a copy_from_user(). And because copy_{to/from}_user() are
>>>> generic functions focussed on transfer of big data blocks to/from user,
>>>> snd_pcm_sync_ptr_put_user() is also more efficient for small amont of
>>>> data.
>>>>
>>>> So use snd_pcm_sync_ptr_get_user() and snd_pcm_sync_ptr_put_user() in
>>>> snd_pcm_sync_ptr() too.
>>>>
>>>> In order to have snd_pcm_mmap_status32 similar to snd_pcm_mmap_status,
>>>> replace to tsamp_{sec/nsec} and audio_tstamp_{sec/nsec} by equivalent
>>>> struct __snd_timespec.
>>>>
>>>> snd_pcm_ioctl_sync_ptr_buggy() is left as it is because the conversion
>>>> wouldn't be straigh-forward do to the workaround it provides.
>>>>
>>>> Signed-off-by: Christophe Leroy <christophe.leroy@...roup.eu>
>>>
>>> Through a quick glance, all patches look almost fine, but one favor to
>>> ask: this patch contains the convert from s32/s32 pair to struct
>>> __snd_timespec.  It should be factored out to a prerequisite patch
>>> instead of burying in a big change.
>>
>> Shall I understand you prefer this series over the more simple "ALSA:
>> pcm: Convert snd_pcm_ioctl_sync_ptr_{compat/x32} to
>> user_access_begin/user_access_end()" patch ?
> 
> Err, no, sorry for ambiguity.

Then I'm lost.

I sent two alternative proposals:
A/ Single patch, simple, handling only two fonctions 
snd_pcm_ioctl_sync_ptr_{compat/x32} , without refactoring. [1]
B/ This RFC series, more elaborate, refactoring and putting user copy 
into helper macros. [2]

So the question was to be sure you prefer alternative B over alternative 
A. I guess the answer is YES as you asking me improve it.

[1] 
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/8df11af98033e4cb4d9b0f16d6e9d5b69110b036.1749724057.git.christophe.leroy@csgroup.eu/
[2] 
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?state=*&series=460665


> I wanted to move the replacement of tstamp_sec/nsec with struct
> __snd_timespec as a small preliminary patch from patch#3.
> That is,

Yes that's what I understood.

Thanks
Christophe


> --- a/sound/core/pcm_native.c
> +++ b/sound/core/pcm_native.c
> @@ -3103,11 +3103,9 @@ struct snd_pcm_mmap_status32 {
>   	snd_pcm_state_t state;
>   	s32 pad1;
>   	u32 hw_ptr;
> -	s32 tstamp_sec;
> -	s32 tstamp_nsec;
> +	struct __snd_timespec tstamp;
>   	snd_pcm_state_t suspended_state;
> -	s32 audio_tstamp_sec;
> -	s32 audio_tstamp_nsec;
> +	struct __snd_timespec audio_tstamp;
>   } __packed;
> etc.  By factoring this out, it becomes clear that the timespec
> compatibility is fully cared.
> 
> __snd_timespec may be defined in different ways on user-space, but in
> the kernel code, it's a single definition of s32/s32 pair.  This needs
> to be emphasized.
> 
> 
> thanks,
> 
> Takashi


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ