compat_ioctl: handle PPPIOCGIDLE for 64-bit time_t
The ppp_idle structure is defined in terms of __kernel_time_t, which is defined as 'long' on all architectures, and this usage is not affected by the y2038 problem since it transports a time interval rather than an absolute time. However, the ppp user space defines the same structure as time_t, which may be 64-bit wide on new libc versions even on 32-bit architectures. It's easy enough to just handle both possible structure layouts on all architectures, to deal with the possibility that a user space ppp implementation comes with its own ppp_idle structure definition, as well as to document the fact that the driver is y2038-safe. Doing this also avoids the need for a special compat mode translation, since 32-bit and 64-bit kernels now support the same interfaces. The old 32-bit structure is also available on native 64-bit architectures now, but this is harmless. Cc: netdev@vger.kernel.org Cc: linux-ppp@vger.kernel.org Cc: Paul Mackerras <paulus@samba.org> Cc: "David S. Miller" <davem@davemloft.net> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
@@ -612,7 +612,8 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
struct ppp_file *pf;
|
||||
struct ppp *ppp;
|
||||
int err = -EFAULT, val, val2, i;
|
||||
struct ppp_idle idle;
|
||||
struct ppp_idle32 idle32;
|
||||
struct ppp_idle64 idle64;
|
||||
struct npioctl npi;
|
||||
int unit, cflags;
|
||||
struct slcompress *vj;
|
||||
@@ -735,10 +736,18 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
err = 0;
|
||||
break;
|
||||
|
||||
case PPPIOCGIDLE:
|
||||
idle.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
|
||||
idle.recv_idle = (jiffies - ppp->last_recv) / HZ;
|
||||
if (copy_to_user(argp, &idle, sizeof(idle)))
|
||||
case PPPIOCGIDLE32:
|
||||
idle32.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
|
||||
idle32.recv_idle = (jiffies - ppp->last_recv) / HZ;
|
||||
if (copy_to_user(argp, &idle32, sizeof(idle32)))
|
||||
break;
|
||||
err = 0;
|
||||
break;
|
||||
|
||||
case PPPIOCGIDLE64:
|
||||
idle64.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
|
||||
idle64.recv_idle = (jiffies - ppp->last_recv) / HZ;
|
||||
if (copy_to_user(argp, &idle64, sizeof(idle64)))
|
||||
break;
|
||||
err = 0;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user