From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758165Ab0EUG0L (ORCPT ); Fri, 21 May 2010 02:26:11 -0400 Received: from moutng.kundenserver.de ([212.227.126.187]:64255 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752213Ab0EUG0J (ORCPT ); Fri, 21 May 2010 02:26:09 -0400 From: Arnd Bergmann To: Tyler Hicks Subject: Re: [PATCH] vfs/eCryptfs: Handle ioctl calls with unlocked and compat functions Date: Fri, 21 May 2010 08:25:32 +0200 User-Agent: KMail/1.12.2 (Linux/2.6.31-19-generic; KDE/4.3.2; x86_64; ; ) Cc: Frederic Weisbecker , Ingo Molnar , LKML , Dustin Kirkland , Ecryptfs , Thomas Gleixner , John Kacur , Alexander Viro References: <1274289855-10001-1-git-send-regression-fweisbec@gmail.com> <20100520233942.GA1086@ecryptfs> <20100520234223.GA1133@ecryptfs> In-Reply-To: <20100520234223.GA1133@ecryptfs> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201005210825.32819.arnd@arndb.de> X-Provags-ID: V01U2FsdGVkX1+FIUwTDdDpQpjyguYJpKeR8ZpB4SX07iTA0cF +3Fw1XXbci24JE87XnlXbldzSpk8Gn8zGxrKKK1Y3FN5M3GbbF hidj+aDpw6L4T27giWlKw== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday 21 May 2010, Tyler Hicks wrote: > Lower filesystems that only implement unlocked_ioctl aren't being > passed ioctl calls because eCryptfs only checked for > lower_file->f_op->ioctl and returned -ENOTTY if it was NULL. > > eCryptfs shouldn't implement ioctl(), since it doesn't require the BKL. > Instead, unlocked_ioctl() should be used and vfs_ioctl() can be called > on the lower file since it handles locking, if necessary. This requires > vfs_ioctl() to be exported. Calling vfs_ioctl doesn't help you at all here, you could simply call the ->unlocked_ioctl function of the lower fs directly to do the same, because ->ioctl will be gone soon. You are howevers still missing a few calls that are done through do_vfs_ioctl or file_ioctl. To implement these, you need to add the file and super operations that these call and forward the functions to the lower fs. > +#ifdef CONFIG_COMPAT > +static long > +ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > +{ > + long rc = -ENOTTY; > + struct file *lower_file = NULL; > + > + if (ecryptfs_file_to_private(file)) > + lower_file = ecryptfs_file_to_lower(file); > + if (lower_file && lower_file->f_op && lower_file->f_op->compat_ioctl) > + rc = lower_file->f_op->compat_ioctl(lower_file, cmd, arg); > + return rc; > +} > +#endif You need to return -ENOIOCTLCMD here, not ENOTTY to cover the case where the lower file system does not have a ->compat_ioctl function but has its calls listed in fs/compat_ioctl.c. Arnd