Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2755595imj; Mon, 11 Feb 2019 08:01:39 -0800 (PST) X-Google-Smtp-Source: AHgI3IZyNbtyaox0uoFt0Y4O0x9Eee78oPGiIlS0er9epKC6mR/c8hP3xvuAeATyPldRmQRgIwX2 X-Received: by 2002:a63:4384:: with SMTP id q126mr33778434pga.160.1549900899456; Mon, 11 Feb 2019 08:01:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900899; cv=none; d=google.com; s=arc-20160816; b=a+WJbVk0wTauPAVoFKWSMyC9ncH7P4jmePfwuBSF/HBpSxYfeesZOZX6C1pZmYFHUL yGWMdF6R1KBYIzPHDP2BX+7uWDjEC8gKs8eznk0H+EKHvCdGRFLRht8vINjcl8yB0rHu YS71J3h144mPkk7CAYetgMhXKTDUCQpM9d+unAZ8eTgaPOL73Q/GNw342C9QhGXJJHD/ +IuTRkNAdiqryW3JQ7Jt7nhD4IIROhYUAZRe4Ys/WMBOnuz6dixD3EoPnevdS8bix64R GufTmHBWGusLeIrzhEpkc54qqMOy74+Sr8evhgh29pTK2EpE6ftbu1LADPsedev3toaD 0RJw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zVynKZAkgkszy7fkMXV7qcOlxl1rasD5WVIoyUwR0+4=; b=Y+hQsyXrvKlpeU301MisEpJ370nffCWgGZaKF6L5Xi2fmH9qETgb5QVz9yAwTZdy9h 6WBAPhA2J78mrxdUaaLS0STDlsZGtvhio7WlBW2bc6DgeaEC3EoOFliRZ9aZEZNTCmsO sszog/rc7z5f5qTiMDl++vXjviPI7BYctTFQDp7/lLLhP9M20NIfDCsGAr0m5R1cp3Sf WW7RpkZ4r7GlhUFL+z+HF9g3qHXC/DZebkZl7+H7gU8hcL9fIVsz9Tm4bPDRBjIrJeCv OF1RkxBmYN1OillAWjbZhe7mURQL3F9IOkN5evBw16gWoH4HbDQJlSk9qoxEkhT/Lh/b LzFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZZjXwuOK; 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 r2si3092126pgm.73.2019.02.11.08.01.21; Mon, 11 Feb 2019 08:01:39 -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=pass header.i=@kernel.org header.s=default header.b=ZZjXwuOK; 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 S1729805AbfBKObl (ORCPT + 99 others); Mon, 11 Feb 2019 09:31:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:38644 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729790AbfBKObi (ORCPT ); Mon, 11 Feb 2019 09:31:38 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 221AE20838; Mon, 11 Feb 2019 14:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895497; bh=t2xA8k+Iz+TOT77SQe+fdSud2UUOBls0sLOfivElB5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZZjXwuOKCFIwEUR2JFnx6zGv6nGJ+SF5O14rk/xiyVworS+Nu78T+DsYUm08lmL5e J8T5rvG5Q2GOEZhtmbrqq/UKJ8kCAhxL6aEWBISUZu6H6T62gd8SWdb/yVQ6YILM3J sQNcMDcccZXohkCp5wDqwQJ52odVY1SxsWdNPPQo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , Lars Ellenberg , Roland Kammerer , Jens Axboe , Sasha Levin Subject: [PATCH 4.20 225/352] drbd: narrow rcu_read_lock in drbd_sync_handshake Date: Mon, 11 Feb 2019 15:17:32 +0100 Message-Id: <20190211141901.552835887@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit d29e89e34952a9ad02c77109c71a80043544296e ] So far there was the possibility that we called genlmsg_new(GFP_NOIO)/mutex_lock() while holding an rcu_read_lock(). This included cases like: drbd_sync_handshake (acquire the RCU lock) drbd_asb_recover_1p drbd_khelper drbd_bcast_event genlmsg_new(GFP_NOIO) --> may sleep drbd_sync_handshake (acquire the RCU lock) drbd_asb_recover_1p drbd_khelper notify_helper genlmsg_new(GFP_NOIO) --> may sleep drbd_sync_handshake (acquire the RCU lock) drbd_asb_recover_1p drbd_khelper notify_helper mutex_lock --> may sleep While using GFP_ATOMIC whould have been possible in the first two cases, the real fix is to narrow the rcu_read_lock. Reported-by: Jia-Ju Bai Reviewed-by: Lars Ellenberg Signed-off-by: Roland Kammerer Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/drbd/drbd_receiver.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 61c392752fe4..1b9822f264d2 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -3364,7 +3364,7 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device, enum drbd_conns rv = C_MASK; enum drbd_disk_state mydisk; struct net_conf *nc; - int hg, rule_nr, rr_conflict, tentative; + int hg, rule_nr, rr_conflict, tentative, always_asbp; mydisk = device->state.disk; if (mydisk == D_NEGOTIATING) @@ -3415,8 +3415,12 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device, rcu_read_lock(); nc = rcu_dereference(peer_device->connection->net_conf); + always_asbp = nc->always_asbp; + rr_conflict = nc->rr_conflict; + tentative = nc->tentative; + rcu_read_unlock(); - if (hg == 100 || (hg == -100 && nc->always_asbp)) { + if (hg == 100 || (hg == -100 && always_asbp)) { int pcount = (device->state.role == R_PRIMARY) + (peer_role == R_PRIMARY); int forced = (hg == -100); @@ -3455,9 +3459,6 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device, "Sync from %s node\n", (hg < 0) ? "peer" : "this"); } - rr_conflict = nc->rr_conflict; - tentative = nc->tentative; - rcu_read_unlock(); if (hg == -100) { /* FIXME this log message is not correct if we end up here -- 2.19.1