From: OGAWA Hirofumi Subject: Re: [PATCH v5 5/8] fat: restructure export_operations Date: Thu, 06 Dec 2012 18:24:48 +0900 Message-ID: <87mwxrttwf.fsf@devron.myhome.or.jp> References: <1353504277-5947-1-git-send-email-linkinjeon@gmail.com> <87hao35uqz.fsf@devron.myhome.or.jp> <87obia17zr.fsf@devron.myhome.or.jp> <871uf4yizs.fsf@devron.myhome.or.jp> <87pq2owvf9.fsf@devron.myhome.or.jp> Mime-Version: 1.0 Content-Type: text/plain Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Namjae Jeon , Ravishankar N , Amit Sahrawat To: Namjae Jeon Return-path: In-Reply-To: (Namjae Jeon's message of "Thu, 6 Dec 2012 16:37:41 +0900") Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Namjae Jeon writes: >> I know encode_fh(). But NFS is network protocol, and network can input >> any data, and I guess the userland interface (open_by_handle()?) can be >> any too. >> >> And generic_fh_to_dentry()'s input verify choose to check the minimum >> length only. But your logic choose the exact length. >> >> I think the both is sane and correct. But I wonder why did you changed it. > There was no particular reason for us to put those conditions. It is > just we knew what fh lengths we have chosen for the 2 cases > WITH/WITHOUT parent. > i.e., we checked with encoded length. > Now, when I check the export functions of other filesystems(btrfs, > nilfs2, udf). They also adopt the same method of checking the exact > length and type. > If there is any particular reason, we will look into that and can also > updated on that. OK. Then, just cleanup code, and let's use strict checking version. Removing strange fallthrou, something like the following. static struct dentry *fat_fh_to_dentry_nostale(struct super_block *sb, struct fid *fh, int fh_len, int fh_type) { struct inode *inode = NULL; struct fat_fid *fid = (struct fat_fid *)fh; loff_t i_pos; switch (fh_type) { case FILEID_FAT_WITHOUT_PARENT: if (fh_len < FAT_FID_SIZE_WITHOUT_PARENT) return NULL; break; case FILEID_FAT_WITH_PARENT: if (fh_len < FAT_FID_SIZE_WITH_PARENT) return NULL; break; default: return NULL; } i_pos = fid->i_pos_hi; i_pos = (i_pos << 32) | (fid->i_pos_low); inode = __fat_nfs_get_inode(sb, 0, fid->i_gen, i_pos); return d_obtain_alias(inode); } -- OGAWA Hirofumi