Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21747232ybl; Mon, 6 Jan 2020 10:23:11 -0800 (PST) X-Google-Smtp-Source: APXvYqwGi5FEZyxtSGoL3/4AKKF8+qDEOOiab2KJJClSzhsLp5xsFTUHquyuy3h/qz8X5zzoXX3P X-Received: by 2002:a9d:24ea:: with SMTP id z97mr120003101ota.345.1578334990993; Mon, 06 Jan 2020 10:23:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578334990; cv=none; d=google.com; s=arc-20160816; b=UJQZ4RvtscZa+2VOyvrcwMekIC5GcKjl/q4Z0x0p8WEjGz9ZPv7gK6GYGfYta68dPm vr8a0GLevM/HD5l0ZqNXA8tDKEh6qA+9IKY5n6Kg4+nzpPVBLdwRINJwR9eAvEXOhwgJ sBfNy8dE9Zw9e9g+WxK9/41uqqrdy+YaMuUBMPaDSu3b9D+EbJqDAN9FIGBiohtS7Tua fvgJ3LzBN8NgmAFjdOwzW1J46q6B3QGEAExoy8m4p1HIlGW1IUzgfiIxAzTmrEakUTnj tpP6s72twSHAxOEadlEryELkUE/VwqtAlE+d4bdmQJumisM2iQFDUs+j0xdP+2gIgkpp GgMg== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=WBGMjPijPmiyMt/LvriU5HH36qGZ3geiwIbw5s0fB9E=; b=rO+NN2QczOETkZW5JYA0wiAYHT+YxUazxcGKdYOrLKJj0/tVDFDJ9ywbJJYAt7d9VB tHB9G+RQq8zXikmkWZ9lzC5iKfakUqVEL/Fc+eeghceinE1U0UbQC8KBSqyCM4Y2y0Lx JjX41Xnsc/RqtTF+ChK/BWgdrrhgHXiCmIGtc5pyLZdsaydk4c0tLYWp05WD4tag1J7B ctGHoY5CfvNF5SVhsBWNPQudTjXDNrIVXwh31AjLOliqXz0WBNw8VWvSydliU7EvDKcb eRyrSdTSE9qW1MVXgRsrUIhXfXKp619TkO63U19AQ6Md5RbsgaogQtkShn8et3gEc2ex goKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=epfUivBN; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q127si31409202oic.99.2020.01.06.10.22.59; Mon, 06 Jan 2020 10:23:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=epfUivBN; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726640AbgAFSW5 (ORCPT + 99 others); Mon, 6 Jan 2020 13:22:57 -0500 Received: from mail-yb1-f193.google.com ([209.85.219.193]:37501 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726622AbgAFSW5 (ORCPT ); Mon, 6 Jan 2020 13:22:57 -0500 Received: by mail-yb1-f193.google.com with SMTP id x14so22442362ybr.4 for ; Mon, 06 Jan 2020 10:22:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WBGMjPijPmiyMt/LvriU5HH36qGZ3geiwIbw5s0fB9E=; b=epfUivBNeGiYNXRucyYAlWdc6QQ5q8/MUs6z0tqWqIJbnQQVIpHDTs4pSo6El3wF9i 8lHpRmc5PE4I+PE+Fhrpa5dAOChmlAL00vkv2/31MwPFLtptwLHz175upM+PyxkdcvjQ 5jvRdgni/rXYaNEMr1PQLgSGuO8AjUYfgV9IZ1s1At/et8CcsTih2hAs3jX875BhJP9o YdNwRcI0qb0ZbA76EtjNhiZSwApjFNLCyvQHsLoInRj6+2ztkL6wJ00xSRRIofUtrQwi +vpThzy+1OTDwfHV8KGh8XfE5iEkdg5V4O372TSSmSpkr5bytpi2cNCY/nNCf6LhHLyu lX7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WBGMjPijPmiyMt/LvriU5HH36qGZ3geiwIbw5s0fB9E=; b=TeDWp8RiFMVc4Zm1m7b3F787uEFAiyXX+O2cbrX18LDmsqwi1rM7Ki+oIUJQ1DzK7z /wuEqa2yQxmxGizcT7/BnbkOC/pTYJNE40fuzj4PG+oRAoPkPRyCNrE1ER2pQgJvyIb1 +Wr69+RDJ54nz93OGkVZ6ZY640UQaDPn3cyP+z9ffkZDHqeGxMQayMU6YJsUz9SMEHEs ApiY+jdotkYk6dZfrnlY2Ay0TZ7maNVQLnNxrEGgdP3x+wZ4+XdzdlIstfFWdfFVz0L0 jKORniNUYZ1sTjv3TrJVCuLOYIi12GXKuMoryurmJ+2Ocv92JJY1vKkamQEXEOWAJGrm 42tA== X-Gm-Message-State: APjAAAU6vUlJbqIjLllg6RV02kQuBOwyannnDFsqSQHrdi/K9nk5Ve+6 6Vh5PPPfGprHy5NELawqBw== X-Received: by 2002:a25:8009:: with SMTP id m9mr46039341ybk.208.1578334976513; Mon, 06 Jan 2020 10:22:56 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id a23sm27940630ywa.32.2020.01.06.10.22.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 10:22:55 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: "J. Bruce Fields" Cc: linux-nfs@vger.kernel.org Subject: [PATCH] nfsd: Fix a soft lockup race in nfsd_file_mark_find_or_create() Date: Mon, 6 Jan 2020 13:20:47 -0500 Message-Id: <20200106182047.563178-1-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If nfsd_file_mark_find_or_create() keeps winning the race for the nfsd_file_fsnotify_group->mark_mutex against nfsd_file_mark_put() then it can soft lock up, since fsnotify_add_inode_mark() ends up always finding an existing entry. Signed-off-by: Trond Myklebust --- fs/nfsd/filecache.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index 9c2b29e07975..f275c11c4e28 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -132,9 +132,13 @@ nfsd_file_mark_find_or_create(struct nfsd_file *nf) struct nfsd_file_mark, nfm_mark)); mutex_unlock(&nfsd_file_fsnotify_group->mark_mutex); - fsnotify_put_mark(mark); - if (likely(nfm)) + if (nfm) { + fsnotify_put_mark(mark); break; + } + /* Avoid soft lockup race with nfsd_file_mark_put() */ + fsnotify_destroy_mark(mark, nfsd_file_fsnotify_group); + fsnotify_put_mark(mark); } else mutex_unlock(&nfsd_file_fsnotify_group->mark_mutex); -- 2.24.1