Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2115448rwb; Thu, 15 Dec 2022 20:04:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf5S9pdB5Zm5oH+rL/2D0uPlxDDmPus5AgdxWzDofiCZmz+DoHHJ2BbLgFCGK22Xs19ZYprA X-Received: by 2002:a17:906:34c5:b0:7ae:e886:8ccb with SMTP id h5-20020a17090634c500b007aee8868ccbmr38111853ejb.14.1671163449587; Thu, 15 Dec 2022 20:04:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671163449; cv=none; d=google.com; s=arc-20160816; b=f+90LATLOvwXJmeUiPSHKfXZAZ0wuhng3WTnEPdqO6BxvHwjjP1xM/W7LvO1eDg4o2 977YBrm4EdMXLDVNj5w7gzF0n87KXsKangBuZGIbXplFS0+YsQtMhzlWuV3kuZf+YANa c25m8VYZwqM4RK5v5qpV2vTqKs037a5KFam2GtfKATLEgL5aPR+0FnCEC2xVg6+jwUSa yAyu3P9bJx4NPczkor62AfHHSS5nAaAhBwApzU4ST4NRYVGyWeNxvCjFLn+SsRUG066W BSeSm3WN/zAClTrZnrYMnQobMI/irFgol9YrLafPrnD1BNILj63XsUOF3gP5L0r6Au4Y daMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=uFjXacM4V95MITfaVTbj36apFcWXHC9KNgQ5sG+WTEI=; b=dGO8vYqloLkJuCuq0ZCyVhcLwgeJ6TzKJjH0AujPBZeAMplEW6WrbTbkdr2y/gF1Mr Dq6hWogNUsGRuzNuFGMpUPXMzUXHfrK4emsbTpJfIdLYNvADIshoaXw8UYubNAob5YsR scCJqaClLve3OmtfY2D4AgfKz2KygyXn1iRiuuZf6heZqA0qHakMFf45TNGXyn/ey1bs RwIadjlpWsbH5R/nbekd981Jdno03p5cWD2eHtfa87L3DdyCFrjC0bOzGE95Ug7lq5yj tCdmnYdyq1O9oMkKy6iiEJ8/5zolRnuLPM2apnyl9sb9EnenVtMffrm41lIOOfkm2Pbk Z/PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=G0kCpgSZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw13-20020a1709066a0d00b007804b5a2c48si1394944ejc.521.2022.12.15.20.03.52; Thu, 15 Dec 2022 20:04:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=G0kCpgSZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbiLPDlT (ORCPT + 69 others); Thu, 15 Dec 2022 22:41:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbiLPDlR (ORCPT ); Thu, 15 Dec 2022 22:41:17 -0500 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39C454045A; Thu, 15 Dec 2022 19:41:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=uFjXacM4V95MITfaVTbj36apFcWXHC9KNgQ5sG+WTEI=; b=G0kCpgSZN1EUotUaOgsFdEeJKi nvprcIE7kGY++o1ePwPpDikIET9h5IfUZv5fKlyM9T+MTa1WtL7BcWlQIPJ1qncj5D+3zA5RSHenM uuyFF3ICu5NIzeaP0IqVitYV1v16gVRNvoLEa0jQfnaD1i0TEBXhJgRZw8l1Ci4W394x7vfLSaZh+ 6/Krg8qkikKZ4XSbLyCPUHUEHNUNIbxFpj60CINFzQvZ9z22cE+LhEfajKhJruE+eTK0LWmHdw57d AKjOOLtlDJvasjaHWIMZUF9PavT5KPIWZU8a2Isujw/v7ohpSBnpKB9dreiKRAvkb6tt6IQnpuBrH j2FDVTNw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1p61at-00CAKK-2V; Fri, 16 Dec 2022 03:41:07 +0000 Date: Fri, 16 Dec 2022 03:41:07 +0000 From: Al Viro To: Damien Le Moal Cc: Wei Chen , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, syzbot , linux-fsdevel , Chuck Lever , Jeff Layton , Peter Zijlstra , Linus Torvalds Subject: Re: possible deadlock in __ata_sff_interrupt Message-ID: References: <5eff70b8-04fc-ee87-973a-2099a65f6e29@opensource.wdc.com> <80dc24c5-2c4c-b8da-5017-31aae65a4dfa@opensource.wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <80dc24c5-2c4c-b8da-5017-31aae65a4dfa@opensource.wdc.com> Sender: Al Viro X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 16, 2022 at 10:44:06AM +0900, Damien Le Moal wrote: > The original & complete lockdep splat is in the report email here: > > https://marc.info/?l=linux-ide&m=167094379710177&w=2 > > It looks like a spinlock is taken for the fasync stuff without irq > disabled and that same spinlock is needed in kill_fasync() which is > itself called (potentially) with IRQ disabled. Hence the splat. In any > case, that is how I understand the issue. But as mentioned above, given > that I can see many drivers calling kill_fasync() with irq disabled, I > wonder if this is a genuine potential problem or a false negative. OK, I'm about to fall asleep, so I might very well be missing something obvious, but... CPU1: ptrace(2) ptrace_check_attach() read_lock(&tasklist_lock); CPU2: setpgid(2) write_lock_irq(&tasklist_lock); spins CPU1: takes an interrupt that would call kill_fasync(). grep and the first instance of kill_fasync() is in hpet_interrupt() - it's not something exotic. IRQs disabled on CPU2 won't stop it. kill_fasync(..., SIGIO, ...) kill_fasync_rcu() read_lock_irqsave(&fa->fa_lock, flags); send_sigio() read_lock_irqsave(&fown->lock, flags); read_lock(&tasklist_lock); ... and CPU1 spins as well. It's not a matter of kill_fasync() called with IRQs disabled; the problem is kill_fasync() called from interrupt taken while holding tasklist_lock at least shared. Somebody trying to grab it on another CPU exclusive before we get to send_sigio() from kill_fasync() will end up spinning and will make us spin as well. I really hope that's just me not seeing something obvious - we had kill_fasync() called in IRQ handlers since way back and we had tasklist_lock taken shared without disabling IRQs for just as long.