Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp722134pxb; Tue, 3 Nov 2020 10:40:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2thsMctMEydgW9rzLcVwqHvkz02HynU754W0FFA7vQztPIk6RKc4wh/04ZVp6Muj/Otu0 X-Received: by 2002:a17:906:5a97:: with SMTP id l23mr3900958ejq.232.1604428839144; Tue, 03 Nov 2020 10:40:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604428839; cv=none; d=google.com; s=arc-20160816; b=bIn9atoMKGCAtGFljHO8C8eFwELCLC9DfYs6ASRTgx4zARfTYxE0uUVOjSoxb3XN1o MuYnIg8Rdz7ZhehomFa+ZmaKJSdlXWi3na24xY4XLXrU9LUREeNa5LkdeJf0tuu0oaOz SGl+PKuo4UR49ij88pc+UXY5QMm5pdDac++Jv2fywSq1mnzokw4ssFoUu78qhv3/0pdQ zzYcuu19yDahhEcLGzI7f1B60obEf3rYh7Mt2bft0RzIa+ze6MWdSFKjYLI9Wce65VdR cbBfjvU41k44ZpEK5DFmXUI6oUadD5JqAqLKM9+R2+CjBD0thUXjnJ2ZCzQ4EllYzcJx 6mMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=t47ZHoH/WiZrIOdyBf9JhmIWRdujT7t1PgwImejEP48=; b=qUEagze76H+ybXsgK15/mtahGRTUyertjLzKvO6U46nL3u9q43gC7UKRoPPm6VEeXN bXRmBvzWT4CMnELWcKlRQAKzu74+NTZmOMBQj9BBQYmHah1p79PGdD4HyJTc/MkXyzmw YsDOzFFs7x9yU6iv7t69T9ACDCVAAsz6fwOzjIMXN98Rg0aTQpujtN5fDmKZIVCgOKE0 VSWYmeBqjSE06l7UGVtTSbX9S94TwnDqXneXItmuASnXLTlgvOElfhBschmURHnuihr2 e+zp4NuXIC1C/QSzVdBzM0UWUm7iiYupbaxLJvTBupnGCNv3CaJgha19q6PPMI269Ws2 AyNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ke2jgXQE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c93si13711744edf.452.2020.11.03.10.40.15; Tue, 03 Nov 2020 10:40:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ke2jgXQE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729295AbgKCSim (ORCPT + 99 others); Tue, 3 Nov 2020 13:38:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:48950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729285AbgKCSil (ORCPT ); Tue, 3 Nov 2020 13:38:41 -0500 Received: from google.com (unknown [104.132.1.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3299B2074B; Tue, 3 Nov 2020 18:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604428721; bh=YUU7O0xdkH9I0WPyXBZOk+F4aYmRrcXzu3VCC7u62jY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ke2jgXQEiYikomRounWe5La8GXGy6aMYfzYjBicVKTz0+2z3ePhwj2okspsy3x1Sj pR9Pi8/c5eQQnno2G9Cv+LNNr0OD0bmFRDuvSb3ZJlb7zJr8cqbpJbCx1RgT+O2n1u eVzeZ0z3pW60GVRwYuYpQu2lxvWaFAAVyBYadbAU= Date: Tue, 3 Nov 2020 10:38:39 -0800 From: Jaegeuk Kim To: Chao Yu Cc: Eric Biggers , 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 Message-ID: <20201103183839.GA1273166@google.com> References: <20201102062131.14205-1-yuchao0@huawei.com> <20201103032234.GB2875@sol.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/03, Chao Yu wrote: > On 2020/11/3 11:22, Eric Biggers wrote: > > 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. > > Nice catch! > > > > > 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... > > IIRC, Jaegeuk added those interfaces, I hope it's not the requirement from other > f2fs userspace developers...if it is, there may be users. > > I found one patch in ext4 which fixes the similar issue, I guess we can fix this > with the same way, thoughts? Agreed. Please fix along with f2fs-tools/f2fs_io. > > commit 4d92dc0f00a775dc2e1267b0e00befb783902fe7 > Author: Ben Hutchings > Date: Mon May 17 06:00:00 2010 -0400 > > ext4: Fix compat EXT4_IOC_ADD_GROUP > > struct ext4_new_group_input needs to be converted because u64 has > only 32-bit alignment on some 32-bit architectures, notably i386. > > Thanks, > > > > > - Eric > > . > >