Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751958AbdIVDBC (ORCPT ); Thu, 21 Sep 2017 23:01:02 -0400 Received: from mail-io0-f177.google.com ([209.85.223.177]:43279 "EHLO mail-io0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751653AbdIVDA7 (ORCPT ); Thu, 21 Sep 2017 23:00:59 -0400 X-Google-Smtp-Source: AOwi7QDVXM3+hZ4GV60sg2O9q7Pi4KS6xebNMuHGcwzNLfOttj0bkk53OpkTvmDb2xVeJACFBrC8xU6TluviJqRSV3s= MIME-Version: 1.0 In-Reply-To: References: <1091b589bec6317ea686937060c0f9f9db10651a.1505973912.git.baolin.wang@linaro.org> From: Baolin Wang Date: Fri, 22 Sep 2017 11:00:58 +0800 Message-ID: Subject: Re: [RFC PATCH 7/7] sound: core: Avoid using timespec for struct snd_timer_tread To: Arnd Bergmann Cc: Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Ingo Molnar , Takashi Sakamoto , SF Markus Elfring , Dan Carpenter , jeeja.kp@intel.com, Vinod Koul , dharageswari.r@intel.com, guneshwor.o.singh@intel.com, Bhumika Goyal , gudishax.kranthikumar@intel.com, Naveen M , hardik.t.shah@intel.com, Arvind Yadav , Fabian Frederick , Mark Brown , Deepa Dinamani , alsa-devel@alsa-project.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1534 Lines: 48 On 21 September 2017 at 21:09, Arnd Bergmann wrote: > On Thu, Sep 21, 2017 at 8:18 AM, Baolin Wang 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. > > - On x86, you have to check whether calling user space process uses > the i386 or the x32 ABI by checking in_x32_syscall() Make sense. -- Baolin.wang Best Regards