From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754551AbXITT4x (ORCPT ); Thu, 20 Sep 2007 15:56:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751181AbXITTxR (ORCPT ); Thu, 20 Sep 2007 15:53:17 -0400 Received: from e4.ny.us.ibm.com ([32.97.182.144]:60391 "EHLO e4.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750797AbXITTxL (ORCPT ); Thu, 20 Sep 2007 15:53:11 -0400 Subject: [PATCH 15/25] unix_find_other() elevate write count for touch_atime() To: akpm@osdl.org Cc: linux-kernel@vger.kernel.org, hch@infradead.org, Dave Hansen From: Dave Hansen Date: Thu, 20 Sep 2007 12:53:08 -0700 References: <20070920195249.852667D5@kernel> In-Reply-To: <20070920195249.852667D5@kernel> Message-Id: <20070920195308.37801985@kernel> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Dave Hansen Acked-by: Christoph Hellwig --- lxc-dave/net/unix/af_unix.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff -puN net/unix/af_unix.c~unix-find-other-elevate-write-count-for-touch-atime net/unix/af_unix.c --- lxc/net/unix/af_unix.c~unix-find-other-elevate-write-count-for-touch-atime 2007-09-20 12:16:17.000000000 -0700 +++ lxc-dave/net/unix/af_unix.c 2007-09-20 12:16:17.000000000 -0700 @@ -729,21 +729,27 @@ static struct sock *unix_find_other(stru err = path_lookup(sunname->sun_path, LOOKUP_FOLLOW, &nd); if (err) goto fail; + + err = mnt_want_write(nd.mnt); + if (err) + goto put_path_fail; + err = vfs_permission(&nd, MAY_WRITE); if (err) - goto put_fail; + goto mnt_drop_write_fail; err = -ECONNREFUSED; if (!S_ISSOCK(nd.dentry->d_inode->i_mode)) - goto put_fail; + goto mnt_drop_write_fail; u=unix_find_socket_byinode(nd.dentry->d_inode); if (!u) - goto put_fail; + goto mnt_drop_write_fail; if (u->sk_type == type) touch_atime(nd.mnt, nd.dentry); path_release(&nd); + mnt_drop_write(nd.mnt); err=-EPROTOTYPE; if (u->sk_type != type) { @@ -763,7 +769,9 @@ static struct sock *unix_find_other(stru } return u; -put_fail: +mnt_drop_write_fail: + mnt_drop_write(nd.mnt); +put_path_fail: path_release(&nd); fail: *error=err; _