From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759087AbbGHV2Y (ORCPT ); Wed, 8 Jul 2015 17:28:24 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:49620 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755418AbbGHV2P (ORCPT ); Wed, 8 Jul 2015 17:28:15 -0400 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: John Stultz , Bamvor Zhang Jian , Thomas Gleixner , lkml Subject: Re: [Y2038] [RFC PATCH v2 3/4] ppdev: add compat ioctl Date: Wed, 08 Jul 2015 23:28:04 +0200 Message-ID: <26603653.9xWxRUDZUD@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: References: <1435587807-10008-1-git-send-email-bamvor.zhangjian@linaro.org> <1435587807-10008-4-git-send-email-bamvor.zhangjian@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:oMFNg58nBo4xvgxiVOhET7QZBZTJJLilo2E2Lw7wz070X+LYVXj Hw5XNqiCW0DLa1lhmyqsjMG1RK67hezlQ3C0Dx2yMalZGjHVccq/uTQcSNmG7cb75Y+8clg qd0//dsLnsoe+ZTrZFjazBXfpW0fTys9c2GZiABQdQp5D1JEkLdHYqCNnX9QaM74jtdcspG +aAdg5NqF+M5BeHUN0Lyg== X-UI-Out-Filterresults: notjunk:1;V01:K0:fjfPH5KfD1w=:jYTvDrSvrNccJNdgU+iQwj JuaX0cIiz3UTxt961kKLpprR3OjCaAl+CY4PX9hZp/ysKcVOek+X69w/hUEumWlF5rpJCnlHe 7Lv+m++/iDz3k65+8qOt4rOolAQjhqahu+AeZ64hxWkJGLomPGjzfJf8A7K178XKRrHEx3971 4U0D+PC2ZF+wDcZ1P9oGnkGl/oq98Xb0U1b+0kBLNsJNBJa8Ey0tD6y8Gio52BnSbvuPJVH/U J11vp76kMTkvAXa0gymPyQPqKO11Wd9j4l35OHxyjjXocXxASSXIKJPHdc+36NRq0+oUuN9k2 i2xm3O1y/eAeXd7QsX5UWNwSIpkfYjgVE251EQpK3aIKVC9Xy0CNZv1Q3SE+1vb33u03xu+GF fgkg6p7uMN4yvkNuX6GeRNPt9uRejHyYGHeS0urL6UKDxbY5Ezf35NQcQPwpuV9f4NzCp+bio SA9s2gkJOWEYHG/1vz0ByglrAtnqjjQaPpaXgpLttLOzbDEfBwWhaebFdWLJ/yFt5fafYTu9y Bq9GrbxsYGrqGPFwtSthq7As4YgY3Dtn39mMz8m+CKXSTWg4xi/96JC8AYtTUDr1IV9q32q7K nnEOxLEz3299bUw7yRW1lJZ33zXW+E91YhMCFF7HzYZX2DzgRVUulEGojFhsGAp9rS+D+lXuD EPwVzWMZI0DciropbIlez7SEl43KWZLn/TNpR/rQ1EbGY+w== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 08 July 2015 13:17:18 John Stultz wrote: > On Mon, Jun 29, 2015 at 7:23 AM, Bamvor Zhang Jian > wrote: > > Add compat ioctl in ppdev in order to solve the y2038 issue in > > later patch. > > This patch simply add pp_do_ioctl to compat_ioctl, because I found > > that all the ioctl access the arg as a pointer. > > > > Signed-off-by: Bamvor Zhang Jian I just saw this mail fly by when you replied, but I guess it would have been better to reply when the original mail came. The description above makes no sense: The problem for compat ioctl is not whether the argument is a pointer or not, but rather what data structure it points to. In this case, we already know that it is /not/ compatible between 32-bit and 64-bit user space, because at least two commands need special handling for the timespec argument, which gets added in patch 4 of the series. This means patches 3 and 4 have to be swapped in order to allow bisection and not introduce a bug when only this one gets applied but patch 4 is missing. Moreover, all other ioctl commands that are handled in pp_ioctl need to be checked regarding what their arguments are, including data structures pointed to by the arguments (recursively, if there are again pointers in those structures). > > unsigned int minor = iminor(inode); > > @@ -744,6 +750,9 @@ static const struct file_operations pp_fops = { > > .write = pp_write, > > .poll = pp_poll, > > .unlocked_ioctl = pp_ioctl, > > +#ifdef CONFIG_COMPAT > > + .compat_ioctl = pp_compat_ioctl, > > +#endif The #ifdef here is not necessary, but will cause a warning on kernels that do not define CONFIG_COMPAT, in particular all 32-bit ones. > Does adding this patch w/o the following patch break 32bit apps using > this on 64bit kernels? Without the patch, those apps will all get -EINVAL from the ioctl handler. With the patch, the kernel actually performs the ioctl that was requested, but that may use the wrong data structure. Arnd