linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: jaegeuk@kernel.org, linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH v3] f2fs: move ioctl interface definitions to separated file
Date: Mon, 2 Nov 2020 19:22:34 -0800	[thread overview]
Message-ID: <20201103032234.GB2875@sol.localdomain> (raw)
In-Reply-To: <20201102062131.14205-1-yuchao0@huawei.com>

On Mon, Nov 02, 2020 at 02:21:31PM +0800, Chao Yu wrote:
> +#define F2FS_IOC_MOVE_RANGE		_IOWR(F2FS_IOCTL_MAGIC, 9,	\
> +						struct f2fs_move_range)
[...]
> +#define F2FS_IOC_GARBAGE_COLLECT_RANGE	_IOW(F2FS_IOCTL_MAGIC, 11,	\
> +						struct f2fs_gc_range)
[...]
> +
> +struct f2fs_gc_range {
> +	__u32 sync;
> +	__u64 start;
> +	__u64 len;
> +};
[...]
> +struct f2fs_move_range {
> +	__u32 dst_fd;		/* destination fd */
> +	__u64 pos_in;		/* start position in src_fd */
> +	__u64 pos_out;		/* start position in dst_fd */
> +	__u64 len;		/* size to move */
> +};

These two structs are weird because there is implicit padding between the __u32
field and the following __u64 field on some 32-bit architectures (e.g. x86_32)
but not others (e.g. arm32).

But f2fs_compat_ioctl() doesn't handle these two ioctls specially, but rather
just calls through to f2fs_ioctl().  That's wrong, and it means that
F2FS_IOC_MOVE_RANGE and F2FS_IOC_GARBAGE_COLLECT_RANGE won't work when called
from an x86_32 binary on an x86_64 kernel.

So something needs to be fixed.  I wonder if it's safe to just explicitly add
the padding field after the fact.  If no one is actually using these two ioctls
in a case where both userspace and the kernel lack the implicit padding (e.g.,
x86_32 userspace with x86_32 kernel), it should be fine...

- Eric


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2020-11-03  3:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-02  6:21 Chao Yu
2020-11-03  3:22 ` Eric Biggers [this message]
2020-11-03  8:17   ` Chao Yu
2020-11-03 18:38     ` Jaegeuk Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201103032234.GB2875@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yuchao0@huawei.com \
    --subject='Re: [f2fs-dev] [PATCH v3] f2fs: move ioctl interface definitions to separated file' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).