From patchwork Fri Aug 3 19:31:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10555435 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D51814E2 for ; Fri, 3 Aug 2018 19:31:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BDEA2C936 for ; Fri, 3 Aug 2018 19:31:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 707752C938; Fri, 3 Aug 2018 19:31:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29EF62C90C for ; Fri, 3 Aug 2018 19:31:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731911AbeHCV3J (ORCPT ); Fri, 3 Aug 2018 17:29:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:46850 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728139AbeHCV3J (ORCPT ); Fri, 3 Aug 2018 17:29:09 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w73JTClW179800; Fri, 3 Aug 2018 19:31:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=QrwVVwztwxvoNXNnR1Dp8JaqY+t9NMKyxX7X65QU4vs=; b=aXukgvUSMgR4V+hGkyVf0h1k6MNoOQc+akWGiqiiULTCsgnBEDzmmc6vfY6BI9+0vYOY A7JFzWDxVijr4pZn2p20nj/36CPak0kT7TiTlc9zOF94UqWjHnEP+RNgCY4w6dPdKozO 7oaFVt/JT0BFFnugyc6HKXMA1ibxTcDCpIK1Hafub3AzdaIQrDJIcd/WXe5dOoojaEoP JbzPUFD0lUmNgcxJMkKEYjX0oj8dnpTqhzAHdQ5DUvpH+RS9W72N5ryztVM/jBCuAgI4 23NorAtB0cEHtCmB+Z8pDL/wExRftUOSfBlbR/ELGnVvp4DB5huThR8N0w0ZAN6jTR1N gA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2kma04bn6g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 Aug 2018 19:31:30 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w73JVUgW010018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Aug 2018 19:31:30 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w73JVTCO027725; Fri, 3 Aug 2018 19:31:30 GMT Received: from kili.mountain (/197.232.248.111) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 03 Aug 2018 12:31:10 -0700 Date: Fri, 3 Aug 2018 22:31:01 +0300 From: Dan Carpenter To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] vfs: potential deadlock in insert_inode_locked() Message-ID: <20180803193101.e422aso76vzbo3ko@kili.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170113 (1.7.2) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8974 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=909 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808030211 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We added a new error path to insert_inode_locked() but we need to drop the inode_hash_lock spin_lock before we return. Fixes: 397127e49ff5 ("new primitive: discard_new_inode()") Signed-off-by: Dan Carpenter diff --git a/fs/inode.c b/fs/inode.c index 593d0cfce27c..ed7c18495cd9 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1462,6 +1462,7 @@ int insert_inode_locked(struct inode *inode) } if (unlikely(old->i_state & I_CREATING)) { spin_unlock(&old->i_lock); + spin_unlock(&inode_hash_lock); return -EBUSY; } __iget(old);