Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1737242

Re: [RFC PATCH 7/7] sound: core: Avoid using timespec for struct snd_timer_tread

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject Re: [RFC PATCH 7/7] sound: core: Avoid using timespec for struct snd_timer_tread
Date 2017-09-22 10:00 +0200
Message-ID <usr2p-3rE-17@gated-at.bofh.it> (permalink)
References <us305-5ww-3@gated-at.bofh.it> <us305-5ww-7@gated-at.bofh.it> <us9oR-1pB-7@gated-at.bofh.it> <usmvM-Xq-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Sep 22, 2017 at 5:00 AM, Baolin Wang <baolin.wang@linaro.org> wrote:
> On 21 September 2017 at 21:09, Arnd Bergmann <arnd@arndb.de> wrote:
>> On Thu, Sep 21, 2017 at 8:18 AM, Baolin Wang <baolin.wang@linaro.org> wrote:
>>
>>> +static int snd_timer_user_tread(void __user *argp, struct snd_timer_user *tu,
>>> +                               unsigned int cmd)
>>> +{
>>> +       int __user *p = argp;
>>> +       int xarg, old_tread;
>>> +
>>> +       if (tu->timeri) /* too late */
>>> +               return -EBUSY;
>>> +       if (get_user(xarg, p))
>>> +               return -EFAULT;
>>> +
>>> +       old_tread = tu->tread;
>>> +#if __BITS_PER_LONG == 64
>>> +       tu->tread = xarg ? 2 : 0;
>>> +#ifdef IA32_EMULATION
>>> +       tu->tread = xarg ? 3 : 0;
>>> +#endif
>>> +#else
>>> +       if (cmd == SNDRV_TIMER_IOCTL_TREAD64)
>>> +               tu->tread = xarg ? 2 : 0;
>>> +       else
>>> +               tu->tread = xarg ? 1 : 0;
>>> +#endif
>>
>> The 64-bit case looks broken here:
>>
>> - The tread flag is different for compat and native mode, so you
>>    must pass a flag to identify whether you are called from
>>    __snd_timer_user_ioctl or from snd_timer_user_ioctl_compat().
>
> I have some confusion here. For 64-bit, we will set tu->tread = 2 no
> matter it is native mode or compat mode, only we will set tu->tread =
> 3 for x86_32 in compat mode, right?
> So I think we do not need to identify whether called from native mode
> or compat mode.

When we have a user space program with 32-bit time_t in compat mode
(i.e. cmd==SNDRV_TIMER_IOCTL_TREAD) on a 64-bit kernel, we want
to set tread=1, and that is different from the native mode that wants to
set tread=2.

For determining whether to use tread=2 or tread=3, we have to check
both compat mode and x32 mode. This could be done by checking for
"if (IS_ENABLED(CONFIG_IA32_EMULATION) && in_compat_syscall() &&
is_x32_task())", but the in_compat_syscall() check can be skipped when
you know that you were called from .compat_ioct().

       Arnd

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH 7/7] sound: core: Avoid using timespec for struct snd_timer_tread Baolin Wang <baolin.wang@linaro.org> - 2017-09-21 08:20 +0200
  Re: [RFC PATCH 7/7] sound: core: Avoid using timespec for struct snd_timer_tread Arnd Bergmann <arnd@arndb.de> - 2017-09-21 15:10 +0200
    Re: [RFC PATCH 7/7] sound: core: Avoid using timespec for struct snd_timer_tread Baolin Wang <baolin.wang@linaro.org> - 2017-09-22 05:10 +0200
      Re: [RFC PATCH 7/7] sound: core: Avoid using timespec for struct snd_timer_tread Arnd Bergmann <arnd@arndb.de> - 2017-09-22 10:00 +0200
        Re: [RFC PATCH 7/7] sound: core: Avoid using timespec for struct snd_timer_tread Baolin Wang <baolin.wang@linaro.org> - 2017-09-22 10:40 +0200

csiph-web