linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fuse: Add ioctl flag for compat ioctl with 64-bit time_t
@ 2019-03-01 17:08 Ian Abbott
  2019-04-23 12:55 ` Miklos Szeredi
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Abbott @ 2019-03-01 17:08 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Miklos Szeredi, linux-kernel, Ian Abbott

Currently, a CUSE server running on a 64-bit kernel can tell when an
ioctl request comes from a process running a 32-bit ABI, but cannot tell
whether the requesting process is using legacy IA32 emulation or x32
ABI, for example.  In particular, the server does not know the size of
the client process's `time_t` type.

For 64-bit kernels, the `FUSE_IOCTL_COMPAT` and `FUSE_IOCTL_32BIT` flags
are currently set in the ioctl input request (`struct fuse_ioctl_in`
member `flags`) for a 32-bit requesting process.  This patch defines a
new flag `FUSE_IOCTL_COMPAT_64TIME` and sets it if the 32-bit requesting
process (running on a 64-bit kernel) uses a 64-bit `time_t` type.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
 fs/fuse/file.c            | 5 ++++-
 include/uapi/linux/fuse.h | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 06096b60f1df..9777e7a19889 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2576,8 +2576,11 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
 #if BITS_PER_LONG == 32
 	inarg.flags |= FUSE_IOCTL_32BIT;
 #else
-	if (flags & FUSE_IOCTL_COMPAT)
+	if (flags & FUSE_IOCTL_COMPAT) {
 		inarg.flags |= FUSE_IOCTL_32BIT;
+		if (COMPAT_USE_64BIT_TIME)
+			inarg.flags |= FUSE_IOCTL_COMPAT_64TIME;
+	}
 #endif
 
 	/* assume all the iovs returned by client always fits in a page */
diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index 2ac598614a8f..1f4a71486601 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -335,6 +335,7 @@ struct fuse_file_lock {
  * FUSE_IOCTL_RETRY: retry with new iovecs
  * FUSE_IOCTL_32BIT: 32bit ioctl
  * FUSE_IOCTL_DIR: is a directory
+ * FUSE_IOCTL_COMPAT_64TIME: 32bit compat ioctl with 64bit time_t
  *
  * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs
  */
@@ -343,6 +344,7 @@ struct fuse_file_lock {
 #define FUSE_IOCTL_RETRY	(1 << 2)
 #define FUSE_IOCTL_32BIT	(1 << 3)
 #define FUSE_IOCTL_DIR		(1 << 4)
+#define FUSE_IOCTL_COMPAT_64TIME (1 << 5)
 
 #define FUSE_IOCTL_MAX_IOV	256
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] fuse: Add ioctl flag for compat ioctl with 64-bit time_t
  2019-03-01 17:08 [PATCH] fuse: Add ioctl flag for compat ioctl with 64-bit time_t Ian Abbott
@ 2019-04-23 12:55 ` Miklos Szeredi
  2019-04-23 15:14   ` Ian Abbott
  0 siblings, 1 reply; 5+ messages in thread
From: Miklos Szeredi @ 2019-04-23 12:55 UTC (permalink / raw)
  To: Ian Abbott; +Cc: linux-fsdevel, linux-kernel

On Fri, Mar 1, 2019 at 6:08 PM Ian Abbott <abbotti@mev.co.uk> wrote:
>
> Currently, a CUSE server running on a 64-bit kernel can tell when an
> ioctl request comes from a process running a 32-bit ABI, but cannot tell
> whether the requesting process is using legacy IA32 emulation or x32
> ABI, for example.  In particular, the server does not know the size of
> the client process's `time_t` type.
>
> For 64-bit kernels, the `FUSE_IOCTL_COMPAT` and `FUSE_IOCTL_32BIT` flags
> are currently set in the ioctl input request (`struct fuse_ioctl_in`
> member `flags`) for a 32-bit requesting process.  This patch defines a
> new flag `FUSE_IOCTL_COMPAT_64TIME` and sets it if the 32-bit requesting
> process (running on a 64-bit kernel) uses a 64-bit `time_t` type.

Hi,

Thanks for the patch.

I think it should rather use in_x32_syscall() helper and follow that
naming because there's apparently at least one example in xfs of a
non-time_t related ioctl that varies between the x32 vs ia32.

Thanks,
Miklos

>
> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> ---
>  fs/fuse/file.c            | 5 ++++-
>  include/uapi/linux/fuse.h | 2 ++
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 06096b60f1df..9777e7a19889 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -2576,8 +2576,11 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
>  #if BITS_PER_LONG == 32
>         inarg.flags |= FUSE_IOCTL_32BIT;
>  #else
> -       if (flags & FUSE_IOCTL_COMPAT)
> +       if (flags & FUSE_IOCTL_COMPAT) {
>                 inarg.flags |= FUSE_IOCTL_32BIT;
> +               if (COMPAT_USE_64BIT_TIME)
> +                       inarg.flags |= FUSE_IOCTL_COMPAT_64TIME;
> +       }
>  #endif
>
>         /* assume all the iovs returned by client always fits in a page */
> diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
> index 2ac598614a8f..1f4a71486601 100644
> --- a/include/uapi/linux/fuse.h
> +++ b/include/uapi/linux/fuse.h
> @@ -335,6 +335,7 @@ struct fuse_file_lock {
>   * FUSE_IOCTL_RETRY: retry with new iovecs
>   * FUSE_IOCTL_32BIT: 32bit ioctl
>   * FUSE_IOCTL_DIR: is a directory
> + * FUSE_IOCTL_COMPAT_64TIME: 32bit compat ioctl with 64bit time_t
>   *
>   * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs
>   */
> @@ -343,6 +344,7 @@ struct fuse_file_lock {
>  #define FUSE_IOCTL_RETRY       (1 << 2)
>  #define FUSE_IOCTL_32BIT       (1 << 3)
>  #define FUSE_IOCTL_DIR         (1 << 4)
> +#define FUSE_IOCTL_COMPAT_64TIME (1 << 5)
>
>  #define FUSE_IOCTL_MAX_IOV     256
>
> --
> 2.20.1
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fuse: Add ioctl flag for compat ioctl with 64-bit time_t
  2019-04-23 12:55 ` Miklos Szeredi
@ 2019-04-23 15:14   ` Ian Abbott
  2019-04-24 10:52     ` Miklos Szeredi
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Abbott @ 2019-04-23 15:14 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: linux-fsdevel, linux-kernel

On 23/04/2019 13:55, Miklos Szeredi wrote:
> On Fri, Mar 1, 2019 at 6:08 PM Ian Abbott <abbotti@mev.co.uk> wrote:
>>
>> Currently, a CUSE server running on a 64-bit kernel can tell when an
>> ioctl request comes from a process running a 32-bit ABI, but cannot tell
>> whether the requesting process is using legacy IA32 emulation or x32
>> ABI, for example.  In particular, the server does not know the size of
>> the client process's `time_t` type.
>>
>> For 64-bit kernels, the `FUSE_IOCTL_COMPAT` and `FUSE_IOCTL_32BIT` flags
>> are currently set in the ioctl input request (`struct fuse_ioctl_in`
>> member `flags`) for a 32-bit requesting process.  This patch defines a
>> new flag `FUSE_IOCTL_COMPAT_64TIME` and sets it if the 32-bit requesting
>> process (running on a 64-bit kernel) uses a 64-bit `time_t` type.
> 
> Hi,
> 
> Thanks for the patch.
> 
> I think it should rather use in_x32_syscall() helper and follow that
> naming because there's apparently at least one example in xfs of a
> non-time_t related ioctl that varies between the x32 vs ia32.

Hi Miklos,

It is conceivable that COMPAT_USE_64BIT_TIME could be true for some 
other arch/ABI (although currently it is only ever set for x86/x32). 
Should it have separate flags for "compat 64-bit time" and "compat x32" 
(even though that is currently redundant)?

Kind regards,
Ian.

> 
> Thanks,
> Miklos
> 
>>
>> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
>> ---
>>   fs/fuse/file.c            | 5 ++++-
>>   include/uapi/linux/fuse.h | 2 ++
>>   2 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
>> index 06096b60f1df..9777e7a19889 100644
>> --- a/fs/fuse/file.c
>> +++ b/fs/fuse/file.c
>> @@ -2576,8 +2576,11 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
>>   #if BITS_PER_LONG == 32
>>          inarg.flags |= FUSE_IOCTL_32BIT;
>>   #else
>> -       if (flags & FUSE_IOCTL_COMPAT)
>> +       if (flags & FUSE_IOCTL_COMPAT) {
>>                  inarg.flags |= FUSE_IOCTL_32BIT;
>> +               if (COMPAT_USE_64BIT_TIME)
>> +                       inarg.flags |= FUSE_IOCTL_COMPAT_64TIME;
>> +       }
>>   #endif
>>
>>          /* assume all the iovs returned by client always fits in a page */
>> diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
>> index 2ac598614a8f..1f4a71486601 100644
>> --- a/include/uapi/linux/fuse.h
>> +++ b/include/uapi/linux/fuse.h
>> @@ -335,6 +335,7 @@ struct fuse_file_lock {
>>    * FUSE_IOCTL_RETRY: retry with new iovecs
>>    * FUSE_IOCTL_32BIT: 32bit ioctl
>>    * FUSE_IOCTL_DIR: is a directory
>> + * FUSE_IOCTL_COMPAT_64TIME: 32bit compat ioctl with 64bit time_t
>>    *
>>    * FUSE_IOCTL_MAX_IOV: maximum of in_iovecs + out_iovecs
>>    */
>> @@ -343,6 +344,7 @@ struct fuse_file_lock {
>>   #define FUSE_IOCTL_RETRY       (1 << 2)
>>   #define FUSE_IOCTL_32BIT       (1 << 3)
>>   #define FUSE_IOCTL_DIR         (1 << 4)
>> +#define FUSE_IOCTL_COMPAT_64TIME (1 << 5)
>>
>>   #define FUSE_IOCTL_MAX_IOV     256
>>
>> --
>> 2.20.1
>>


-- 
-=( Ian Abbott <abbotti@mev.co.uk> || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268.  Registered address:    )=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fuse: Add ioctl flag for compat ioctl with 64-bit time_t
  2019-04-23 15:14   ` Ian Abbott
@ 2019-04-24 10:52     ` Miklos Szeredi
  2019-04-24 12:33       ` Ian Abbott
  0 siblings, 1 reply; 5+ messages in thread
From: Miklos Szeredi @ 2019-04-24 10:52 UTC (permalink / raw)
  To: Ian Abbott; +Cc: linux-fsdevel, linux-kernel

On Tue, Apr 23, 2019 at 5:14 PM Ian Abbott <abbotti@mev.co.uk> wrote:
>
> On 23/04/2019 13:55, Miklos Szeredi wrote:
> > On Fri, Mar 1, 2019 at 6:08 PM Ian Abbott <abbotti@mev.co.uk> wrote:
> >>
> >> Currently, a CUSE server running on a 64-bit kernel can tell when an
> >> ioctl request comes from a process running a 32-bit ABI, but cannot tell
> >> whether the requesting process is using legacy IA32 emulation or x32
> >> ABI, for example.  In particular, the server does not know the size of
> >> the client process's `time_t` type.
> >>
> >> For 64-bit kernels, the `FUSE_IOCTL_COMPAT` and `FUSE_IOCTL_32BIT` flags
> >> are currently set in the ioctl input request (`struct fuse_ioctl_in`
> >> member `flags`) for a 32-bit requesting process.  This patch defines a
> >> new flag `FUSE_IOCTL_COMPAT_64TIME` and sets it if the 32-bit requesting
> >> process (running on a 64-bit kernel) uses a 64-bit `time_t` type.
> >
> > Hi,
> >
> > Thanks for the patch.
> >
> > I think it should rather use in_x32_syscall() helper and follow that
> > naming because there's apparently at least one example in xfs of a
> > non-time_t related ioctl that varies between the x32 vs ia32.
>
> Hi Miklos,
>
> It is conceivable that COMPAT_USE_64BIT_TIME could be true for some
> other arch/ABI (although currently it is only ever set for x86/x32).
> Should it have separate flags for "compat 64-bit time" and "compat x32"
> (even though that is currently redundant)?

No, it should just be a single flag, something like
FUSE_IOCTL_COMPAT_X32 and the documentation should say that it implies
64bit time values.

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fuse: Add ioctl flag for compat ioctl with 64-bit time_t
  2019-04-24 10:52     ` Miklos Szeredi
@ 2019-04-24 12:33       ` Ian Abbott
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Abbott @ 2019-04-24 12:33 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: linux-fsdevel, linux-kernel

On 24/04/2019 11:52, Miklos Szeredi wrote:
> On Tue, Apr 23, 2019 at 5:14 PM Ian Abbott <abbotti@mev.co.uk> wrote:
>>
>> On 23/04/2019 13:55, Miklos Szeredi wrote:
>>> On Fri, Mar 1, 2019 at 6:08 PM Ian Abbott <abbotti@mev.co.uk> wrote:
>>>>
>>>> Currently, a CUSE server running on a 64-bit kernel can tell when an
>>>> ioctl request comes from a process running a 32-bit ABI, but cannot tell
>>>> whether the requesting process is using legacy IA32 emulation or x32
>>>> ABI, for example.  In particular, the server does not know the size of
>>>> the client process's `time_t` type.
>>>>
>>>> For 64-bit kernels, the `FUSE_IOCTL_COMPAT` and `FUSE_IOCTL_32BIT` flags
>>>> are currently set in the ioctl input request (`struct fuse_ioctl_in`
>>>> member `flags`) for a 32-bit requesting process.  This patch defines a
>>>> new flag `FUSE_IOCTL_COMPAT_64TIME` and sets it if the 32-bit requesting
>>>> process (running on a 64-bit kernel) uses a 64-bit `time_t` type.
>>>
>>> Hi,
>>>
>>> Thanks for the patch.
>>>
>>> I think it should rather use in_x32_syscall() helper and follow that
>>> naming because there's apparently at least one example in xfs of a
>>> non-time_t related ioctl that varies between the x32 vs ia32.
>>
>> Hi Miklos,
>>
>> It is conceivable that COMPAT_USE_64BIT_TIME could be true for some
>> other arch/ABI (although currently it is only ever set for x86/x32).
>> Should it have separate flags for "compat 64-bit time" and "compat x32"
>> (even though that is currently redundant)?
> 
> No, it should just be a single flag, something like
> FUSE_IOCTL_COMPAT_X32 and the documentation should say that it implies
> 64bit time values.

Okay, since the subject line, description and code will change, I'll 
submit the new patch as a new patch, rather than a "v2".  (I'll mention 
its history below the scissors line.)  Please drop this patch.

-- 
-=( Ian Abbott <abbotti@mev.co.uk> || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268.  Registered address:    )=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-04-24 12:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-01 17:08 [PATCH] fuse: Add ioctl flag for compat ioctl with 64-bit time_t Ian Abbott
2019-04-23 12:55 ` Miklos Szeredi
2019-04-23 15:14   ` Ian Abbott
2019-04-24 10:52     ` Miklos Szeredi
2019-04-24 12:33       ` Ian Abbott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).