From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753967AbaHKOhQ (ORCPT ); Mon, 11 Aug 2014 10:37:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57813 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753465AbaHKOhO (ORCPT ); Mon, 11 Aug 2014 10:37:14 -0400 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells To: Miklos Szeredi cc: dhowells@redhat.com, viro@ZenIV.linux.org.uk, linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Race in ovl_copy_up()? MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <24269.1407767827.1@warthog.procyon.org.uk> Date: Mon, 11 Aug 2014 15:37:07 +0100 Message-ID: <24270.1407767827@warthog.procyon.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Miklos, Looking at the following: int ovl_copy_up(struct dentry *dentry) { int err; err = 0; while (!err) { struct dentry *next; struct dentry *parent; struct path lowerpath; struct kstat stat; enum ovl_path_type type = ovl_path_type(dentry); if (type != OVL_PATH_LOWER) break; next = dget(dentry); /* find the topmost dentry not yet copied up */ for (;;) { parent = dget_parent(next); type = ovl_path_type(parent); if (type != OVL_PATH_LOWER) break; dput(next); next = parent; } ovl_path_lower(next, &lowerpath); err = vfs_getattr(&lowerpath, &stat); if (!err) err = ovl_copy_up_one(parent, next, &lowerpath, &stat); dput(parent); dput(next); } return err; } In the for-loop in the middle, if you ascend any levels at all, how are you protected from racing with copy-ups taking place on those more rootwards dentries? I can see ovl_copy_up_one() using lock_rename() on the workdir and upperdir, but there's no relevant lock on the overlayfs fs. You stepped out of the lock the VFS caller holds when you ascended. David