Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2686783imj; Mon, 11 Feb 2019 07:02:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IbWlNKSki67U2rNUpTkro/DMdWPBS+HthVEBmo6j2Sg1uHWC4PxRV+lBsdixlDOTK/8VaWG X-Received: by 2002:a62:1049:: with SMTP id y70mr10762590pfi.220.1549897353519; Mon, 11 Feb 2019 07:02:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897353; cv=none; d=google.com; s=arc-20160816; b=X2+v9WRPmaQ4vgzZh/t/4PuXfr2sETgEE4mfAOz2JMPOwnmonALFimEXxBxsOnJN5N XlhMgCms0/uY2huK5xEo7kreoqVhYhRnSulm2ryqfrVPf4NWWqo8Wb6MY2gXC8GKgOc5 TE1wEet4fSSONrJ0Pqz2Llhwocl4gJKFDdjcfi58eicNmWsxbHz+lSfKMMnpEoRB2URI hRvWOmE5QYp1Po7bsTBNdJDlju/a/amzl+UN7tiP8BqYSPGW+/V+aOQdADqnKEcSGvI5 v9jCLvCPqzRHvpTn2EdqdKEi6VnCN7+8z+Z5Iem54IU5U/MqKwp3B1fAaY/t42raLSwb b72g== 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=aCjqJHEzti1pKtT38SOEXR0W8cHphVlUmcWmz5IQOAA=; b=oieEgJrCxiZ9kqwdwtSirGzPiwgT7z7d5r6K8gNOgxWWDY0QniKv5ivU73XWQj0kUY zsZFuuJjL+1Hs/176KyhA61Y9tNcA13QImXP2ua7/s7YJiLeMI1sl5cLsFuKyElDURaT u8VAZ4dVHSdse8TuGvvptWZCqcxPdKjeqpIU6RleEreXE/qWsOJU6mQ+Um1WYW4tETKX VmOM3HX3SqqvF3nDkfpX+DiAUyjysZrs4tgFd+c9rTr4Jj76/GzKgHpz5rCrFHtxCafs LRQl1yHTlQpGf8WYGrYP18hk7t3USQxiLtyH30IGzisEnhz7wfsD0kf07WGIXx2oxVbt RwrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GA86R6Zd; 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 n13si10897596pfh.66.2019.02.11.07.02.06; Mon, 11 Feb 2019 07:02:33 -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=GA86R6Zd; 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 S2390136AbfBKPBJ (ORCPT + 99 others); Mon, 11 Feb 2019 10:01:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:49122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389387AbfBKPBJ (ORCPT ); Mon, 11 Feb 2019 10:01:09 -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 6BE05206BA; Mon, 11 Feb 2019 15:01:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897267; bh=OEhczWgsMqfOquunYQ0JZhgnOh2JWUOtu0B2Os/rNr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GA86R6ZdRQSfJxVDAwQc5iOI9esyV77xA63rqj8iV/7/VWY75QQNjIo+PTpY3DpRk mcGJOsb0hH4bR+amYKo89d7PfD9oPJIGhOA5/ZfM6jyJuxJ6pLUKxQfROBTfveACjK UPaYWNvcKaKsRB06iPSsAJo34zUg8Zd+NdbvSVBw= 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.14 118/205] drbd: narrow rcu_read_lock in drbd_sync_handshake Date: Mon, 11 Feb 2019 15:18:36 +0100 Message-Id: <20190211141836.177413883@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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 796eaf347dc0..143c5a666e25 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -3361,7 +3361,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) @@ -3412,8 +3412,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); @@ -3452,9 +3456,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