Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2537237imj; Mon, 11 Feb 2019 04:38:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IaS9ZsB1sjXDq1LukcBMcbk470dcEbf6K1tG+vxyD4ZBWMLiVUtRsuefBZMJQyoFZGqxOsP X-Received: by 2002:a62:3241:: with SMTP id y62mr36400084pfy.178.1549888724957; Mon, 11 Feb 2019 04:38:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549888724; cv=none; d=google.com; s=arc-20160816; b=G8uZ154cBYJ2AUvIIf4dRDNvbIT2UDxYmLWK2/h/+HBcnNGfmKGH7AVayq646us9kt 2z1DF/BhCOPnS+BT5S+CZAkT7FJkuByCXn1ObTdEUfRFmc7j2mbU/Xgq/8gBrcoK8RpI FonZRzt6MPIqOVZ9sZSv7cf5Q6MICK83QeH70oR1HrP99A4Wog2xfZfekjANX4WQWhx4 XBhWWAIdp+8922SCdJIya0bsYVLPireJDYO5vx1ZNIhogZNMybSCl91dOdBz4eQa9u/X IEqi1tfzuE1QB8qiWy+YhpFGvPmUi58W8ZSxzh04Lx67gY2fcUAk/4CssZOUQQmVd5Rh Sb5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=uNFH6w4Gy4uKEZhuZeiRBbvSCjujATtfuhBq8C9Cazs=; b=CQpYRNxf6X/6T4mhEiFSZ7K2GYdgMmdoGDY3s1PwnGAspYM06+dhTD7QnYiGoiHwnd sd8ZXhXg+13Gh4EFXLA2Zq6ZTPHDnZP8bQuG57YS+m15J8Wc+9ZIWu2VNHHtYljVNIHn b0LPBQN6wFnEAkTGA4aRYNkiOtwO3hDgavrt2OeTi6aWGk/6uD8qNHcG3HqWFxaZo0Xw ZfXs2Pbgqf+/e0T1FNzZzpy6zIulLmfGuX3sXy03V7wY3zjKvre24vyoGOnB6a0fMKnA JT/wfQBeOCfdOvxcJaRWaBOWCt0WPJF26VlePiPno1tP5EdAEwmDXOmhoVp0+JWEBI/u yu1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b="n/TlEoQ8"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc12si9903143plb.111.2019.02.11.04.38.28; Mon, 11 Feb 2019 04:38:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b="n/TlEoQ8"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727426AbfBKMh4 (ORCPT + 99 others); Mon, 11 Feb 2019 07:37:56 -0500 Received: from mail-it1-f196.google.com ([209.85.166.196]:54926 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727090AbfBKMh4 (ORCPT ); Mon, 11 Feb 2019 07:37:56 -0500 Received: by mail-it1-f196.google.com with SMTP id i145so25836589ita.4 for ; Mon, 11 Feb 2019 04:37:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uNFH6w4Gy4uKEZhuZeiRBbvSCjujATtfuhBq8C9Cazs=; b=n/TlEoQ8bZb5eihGCfmnVh9pL0fX8MsMYeXoJ/NgIdo1ypegyOCVv2ox2G4oa1dg7m SL+lj6om4336eSDGaTnp7eOqeVOw1m/IKFjs3UP4scTZCRTF5Ko7kEflckxhpJXzWAYi 0l2LgVOymq8jhNvXvGZB/3JjlxdYmIJv3iVe8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uNFH6w4Gy4uKEZhuZeiRBbvSCjujATtfuhBq8C9Cazs=; b=LOYAPzI521vUEM3DAFJtaqD3I/qWGHBlvl0UfJN5gYJHZy2WoIlb3hqzqF3vkHcU+P fhf9d8rpDQXsidpYdp7ApIgIN8TAWHPKnNxNpAYiOfryBw3HPTrcbQQgwuYoH8sNeKtd afXfxRQokCjRtXvlwBBEjr2Sqc7OgmuJcKhixWwJwE6Y/j2mxlFm8KnmCrRvlEeLuHja hktgpMqx1gnDRpDMkyK8YLKLc6xhRnXlIErC1WCybYHNp+Imuh58roWuW8wtIkbaKtPK jZORyGzrMaPbQJh/fMLpo8ZtNL7NB71aXucnBnb5NEX93ohdCrOBbL7tfRpIcIieT/eN ixrQ== X-Gm-Message-State: AHQUAuYTUup23Ha3kdW8JWj/Z08tC9hyqKhCkVXQBcSeYYrJgc4GSQTk 5K5WxgNYLagxxNUoFM2jZcbJUiI7X5qX6g74c2NCXA== X-Received: by 2002:a5e:d803:: with SMTP id l3mr13331687iok.144.1549888674884; Mon, 11 Feb 2019 04:37:54 -0800 (PST) MIME-Version: 1.0 References: <000000000000701c3305818e4814@google.com> In-Reply-To: From: Miklos Szeredi Date: Mon, 11 Feb 2019 13:37:43 +0100 Message-ID: Subject: Re: possible deadlock in pipe_lock (2) To: Amir Goldstein , Jan Kara Cc: linux-fsdevel , linux-kernel , syzkaller-bugs@googlegroups.com, Al Viro , syzbot , overlayfs Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 11, 2019 at 1:06 PM Miklos Szeredi wrote: > > On Mon, Feb 11, 2019 at 8:38 AM Amir Goldstein wrote: > > > > On Sun, Feb 10, 2019 at 8:23 PM syzbot > > wrote: > > > > -> #1 (&ovl_i_mutex_key[depth]){+.+.}: > > > down_write+0x38/0x90 kernel/locking/rwsem.c:70 > > > inode_lock include/linux/fs.h:757 [inline] > > > ovl_write_iter+0x148/0xc20 fs/overlayfs/file.c:231 > > > call_write_iter include/linux/fs.h:1863 [inline] > > > new_sync_write fs/read_write.c:474 [inline] > > > __vfs_write+0x613/0x8e0 fs/read_write.c:487 > > > kobject: 'loop4' (000000009e2b886d): kobject_uevent_env > > > __kernel_write+0x110/0x3b0 fs/read_write.c:506 > > > write_pipe_buf+0x15d/0x1f0 fs/splice.c:797 > > > splice_from_pipe_feed fs/splice.c:503 [inline] > > > __splice_from_pipe+0x39a/0x7e0 fs/splice.c:627 > > > splice_from_pipe+0x108/0x170 fs/splice.c:662 > > > default_file_splice_write+0x3c/0x90 fs/splice.c:809 > > Irrelevant to the lockdep splat, but why isn't there an > ovl_splice_write() that just recurses into realfile->splice_write()? > Sounds like a much more efficient way to handle splice read and > write... > > [...] > > > Miklos, > > > > Its good that this report popped up again, because I went to > > look back at my notes from previous report [1]. > > If I was right in my previous analysis then we must have a real > > deadlock in current "lazy copy up" WIP patches. Right? > > Hmm, AFAICS this circular dependency translated into layman's terms: > > pipe lock -> ovl inode lock (splice to ovl file) > > ovl inode lock -> upper freeze lock (truncate of ovl file) > > upper freeze lock -> pipe lock (splice to upper file) So what can we do with this? The "freeze lock -> inode lock" dependency is fixed. This is reversed in overlay to "ovl inode lock -> upper freeze lock", which is okay, because this is a nesting that cannot be reversed. But in splice the pipe locks comes in between: "freeze lock -> pipe lock -> inode lock" which breaks this nesting direction and creates a true reverse dependency between ovl inode lock and upper freeze lock. The only way I see this could be fixed is to move the freeze lock inside the pipe lock. But that would mean splice/sendfile/etc could be frozen with the pipe lock held. It doesn't look nice. Any other ideas? Thanks, Miklos