Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933213Ab0GONMA (ORCPT ); Thu, 15 Jul 2010 09:12:00 -0400 Received: from mail.gmx.net ([213.165.64.20]:36355 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S933120Ab0GONL7 (ORCPT ); Thu, 15 Jul 2010 09:11:59 -0400 X-Authenticated: #4630777 X-Provags-ID: V01U2FsdGVkX19vMb5QYOVvzWtbaz9fG8nnVI+QQPg4XkfLncZ9kB WucPK29hK1Du4u Message-ID: <4C3F091B.2020108@gmx.de> Date: Thu, 15 Jul 2010 15:11:55 +0200 From: Lino Sanfilippo User-Agent: Icedove 1.5.0.14eol (X11/20090105) MIME-Version: 1.0 To: sandeen@redhat.com CC: linux-kernel@vger.kernel.org, tyhicks@linux.vnet.ibm.com, kirkland@canonical.com, viro@zeniv.linux.org.uk, ecryptfs-devel@lists.launchpad.net Subject: [PATCH] ecryptfs: dont call lookup_one_len to avoid NULL nameidata Content-Type: multipart/mixed; boundary="------------020109080602050605060808" X-Y-GMX-Trusted: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6592 Lines: 116 This is a multi-part message in MIME format. --------------020109080602050605060808 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, I have encountered the same problem that Eric Sandeen described in this post http://lkml.org/lkml/fancy/2010/4/23/467 while experimenting with stackable filesystems. The reason seems to be that ecryptfs calls lookup_one_len() to get the lower dentry, which in turn calls the lower parent dirs d_revalidate() with a NULL nameidata object. If ecryptfs is the underlaying filesystem, the NULL pointer dereference occurs, since ecryptfs is not prepared to handle a NULL nameidata. I know that this cant happen any more, since it is no longer allowed to mount ecryptfs upon itself. But maybe this patch it useful nevertheless, since the problem would still apply for an underlaying filesystem that implements d_revalidate() and is not prepared to handle a NULL nameidata (I dont know if there actually is such a fs). With this patch (against 2.6.35-rc5) ecryptfs uses the vfs_lookup_path() function instead of lookup_one_len() which ensures that the nameidata passed to the lower filesystems d_revalidate(). Lino Sanfilippo Signed-off-by: Lino Sanfilippo --------------020109080602050605060808 Content-Type: text/plain; name="patch" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="patch" LS0tIGEvZnMvZWNyeXB0ZnMvaW5vZGUuYwkyMDEwLTA3LTEzIDEzOjEyOjIwLjAwMDAwMDAw MCArMDIwMAorKysgYi9mcy9lY3J5cHRmcy9pbm9kZS5jCTIwMTAtMDctMTUgMTQ6MTg6NDQu MDAwMDAwMDAwICswMjAwCkBAIC0zNDcsNiArMzQ3LDc2IEBAIG91dDoKIH0KIAogLyoqCisg KiBlY3J5cHRmc19uZXdfbG93ZXJfZGVudHJ5CisgKiBAZW5hbWU6IFRoZSBuYW1lIG9mIHRo ZSBuZXcgZGVudHJ5LgorICogQGxvd2VyX2Rpcl9kZW50cnk6IFBhcmVudCBkaXJlY3Rvcnkg b2YgdGhlIG5ldyBkZW50cnkuCisgKiBAbmQ6IG5hbWVpZGF0YSBmcm9tIGxhc3QgbG9va3Vw LgorICoKKyAqIENyZWF0ZSBhIG5ldyBkZW50cnkgb3IgZ2V0IGl0IGZyb20gbG93ZXIgcGFy ZW50IGRpci4KKyAqLworc3RhdGljIHN0cnVjdCBkZW50cnkgKgorZWNyeXB0ZnNfbmV3X2xv d2VyX2RlbnRyeShzdHJ1Y3QgcXN0ciAqbmFtZSwgc3RydWN0IGRlbnRyeSAqbG93ZXJfZGly X2RlbnRyeSwKKwkJCSAgc3RydWN0IG5hbWVpZGF0YSAqbmQpCit7CisJc3RydWN0IGRlbnRy eSAqbmV3X2RlbnRyeTsKKwlzdHJ1Y3QgZGVudHJ5ICp0bXA7CisJc3RydWN0IGlub2RlICps b3dlcl9kaXJfaW5vZGU7CisKKwlsb3dlcl9kaXJfaW5vZGUgPSBsb3dlcl9kaXJfZGVudHJ5 LT5kX2lub2RlOworCisJdG1wID0gZF9hbGxvYyhsb3dlcl9kaXJfZ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l9kZW50cnksCi0JCQkJICAg ICAgZW5jcnlwdGVkX2FuZF9lbmNvZGVkX25hbWVfc2l6ZSAtIDEpOwotCW11dGV4X3VubG9j aygmbG93ZXJfZGlyX2RlbnRyeS0+ZF9pbm9kZS0+aV9tdXRleCk7CisJbG93ZXJfZGVudHJ5 ID0gZWNyeXB0ZnNfbG9va3VwX29uZV9sb3dlcihlY3J5cHRmc19kZW50cnksCisJCQkJCQkg bG93ZXJfZGlyX2RlbnRyeSk7CiAJaWYgKElTX0VSUihsb3dlcl9kZW50cnkpKSB7CiAJCXJj ID0gUFRSX0VSUihsb3dlcl9kZW50cnkpOwotCQllY3J5cHRmc19wcmludGsoS0VSTl9ERUJV RywgIiVzOiBsb29rdXBfb25lX2xlbigpIHJldHVybmVkICIKKwkJZWNyeXB0ZnNfcHJpbnRr KEtFUk5fREVCVUcsICIlczogbG9va3VwX29uZV9sb3dlcigpIHJldHVybmVkICIKIAkJCQki WyVkXSBvbiBsb3dlcl9kZW50cnkgPSBbJXNdXG4iLCBfX2Z1bmNfXywgcmMsCiAJCQkJZW5j cnlwdGVkX2FuZF9lbmNvZGVkX25hbWUpOwogCQlnb3RvIG91dF9kX2Ryb3A7Cg== --------------020109080602050605060808-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/