Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3474721imm; Mon, 4 Jun 2018 04:19:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI1SnhgnI7njYaJZIAlcgFhp8blX0mlbBzJ+PiHGA6Znafwav30JfUftTcF9kXXOu+GYQAP X-Received: by 2002:a63:7247:: with SMTP id c7-v6mr16964811pgn.68.1528111190446; Mon, 04 Jun 2018 04:19:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528111190; cv=none; d=google.com; s=arc-20160816; b=XeCEkQC4m9h8ClZgyt6Yufu2c5hOuJgbQ6lIREmzIOuJK0tHOynwYaPAG6Vi/HZtZ2 b3Pt4Wq0944pI31cUOdHWsftDnSkfM5zlo0iLqqWzVmL4wKQixWqIokMvGbVv7EK4iA1 MzPXHRbCGDXrwGMagcC5s/ry6o100bUnMpjZfY2g+IAc3msynjj3uAUcG9B1KaXfxALP 7WrfUf8dNogLfTmOVS4qTkknRE04DfxSfpm8lQSS0vZhFDdH7EzW8fpNqwyBXXUIgd21 h0eIj5d/rZORG53NQMvudoVjIB7Ku307uH85ZQFPzq2+tmCzxPIEfyosDvzs25pgDQ4k mpUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=pU1iIU2LuVB9+T9LWpsBxqTxqr7yJPcrQSga8UzQkC4=; b=b+4yBHTGWAOFjgu//lGSZi6jlkN5rXkO3dhJaYVHDq2lGFrsX4k3rE5u7b8sd0AIi9 RHalEYZ3B5JLjUHEp3t5g+lgL3JqNJ/f3EkltUhSP2Ed8wzMaMT2GQsb4zRA2x7mQgNe NAQJPGvnWCQtoHJaut+jJQfD+CBlyAbaa1Bv/3jsH4YBGccUcInAtK17FGhcwvPJF/LU 1LqeRU9v05WSUuK7s3keEZZZMMnHrIfiYISyZ747r53CDLwbr6R4/2JoNQbdItVLu7pM Ij0fjOFBmnKMy8YlBp5gajaPnbavd8z18FBZIM4Q7cjFOPciCNyxr+L3Qkiyqt/Y+c2P /T0g== ARC-Authentication-Results: i=1; mx.google.com; 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 e88-v6si6244964pfk.198.2018.06.04.04.19.35; Mon, 04 Jun 2018 04:19:50 -0700 (PDT) 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; 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 S1751989AbeFDLTM (ORCPT + 99 others); Mon, 4 Jun 2018 07:19:12 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:60046 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751473AbeFDLTK (ORCPT ); Mon, 4 Jun 2018 07:19:10 -0400 Received: from fsav402.sakura.ne.jp (fsav402.sakura.ne.jp [133.242.250.101]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w54BJ4gu069877; Mon, 4 Jun 2018 20:19:04 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav402.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav402.sakura.ne.jp); Mon, 04 Jun 2018 20:19:04 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav402.sakura.ne.jp) Received: from [192.168.1.8] (softbank126074194044.bbtec.net [126.74.194.44]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w54BJ3L7069858 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 4 Jun 2018 20:19:04 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Subject: Re: [PATCH v3] block/loop: Serialize ioctl operations. To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot , syzbot References: <1527297408-4428-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> From: Tetsuo Handa Message-ID: Date: Mon, 4 Jun 2018 20:19:02 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1527297408-4428-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This problem was already ignored for 8 months. Unless we boost priority, this problem will be ignored for years. Jens, can we test this patch? On 2018/05/26 10:16, Tetsuo Handa wrote: > syzbot is reporting NULL pointer dereference [1] which is caused by > race condition between ioctl(loop_fd, LOOP_CLR_FD, 0) versus > ioctl(other_loop_fd, LOOP_SET_FD, loop_fd) due to traversing other > loop devices without holding corresponding locks. > > syzbot is also reporting circular locking dependency between bdev->bd_mutex > and lo->lo_ctl_mutex [2] which is caused by calling blkdev_reread_part() > with lock held. > > Since ioctl() request on loop devices is not frequent operation, we don't > need fine grained locking. Let's use global lock and simplify the locking > order. > > Strategy is that the global lock is held upon entry of ioctl() request, > and release it before either starting operations which might deadlock or > leaving ioctl() request. After the global lock is released, current thread > no longer uses "struct loop_device" memory because it might be modified > by next ioctl() request which was waiting for current ioctl() request. > > In order to enforce this strategy, this patch inversed > loop_reread_partitions() and loop_unprepare_queue() in loop_clr_fd(). > I don't know whether it breaks something, but I don't have testcases. > > Since this patch serializes using global lock, race bugs should no longer > exist. Thus, it will be easy to test whether this patch broke something. > > [1] https://syzkaller.appspot.com/bug?id=f3cfe26e785d85f9ee259f385515291d21bd80a3 > [2] https://syzkaller.appspot.com/bug?id=bf154052f0eea4bc7712499e4569505907d15889 > > Signed-off-by: Tetsuo Handa > Reported-by: syzbot > Reported-by: syzbot > Cc: Jens Axboe > --- > drivers/block/loop.c | 231 ++++++++++++++++++++++++++++----------------------- > drivers/block/loop.h | 1 - > 2 files changed, 128 insertions(+), 104 deletions(-)