From nobody Fri Jun 19 07:19:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4119C433F5 for ; Wed, 6 Apr 2022 20:48:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230223AbiDFUur (ORCPT ); Wed, 6 Apr 2022 16:50:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232608AbiDFUtv (ORCPT ); Wed, 6 Apr 2022 16:49:51 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BB623C15BA for ; Wed, 6 Apr 2022 12:05:18 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id p15so6218072ejc.7 for ; Wed, 06 Apr 2022 12:05:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linbit-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qfxFWJFZ6uw2agXHgOvG4u2eDOtbo0NRWmwVpn4uFPA=; b=Fx6Uzt6LOot/haJHKSHSwXct2yt9GFO4Y+pzzAVJq+RpsGqBTpxSYkyR9QFt7Y0cLD kQxZ1vVDQ7f3QAoHSIG9u5Q3r6tBdOc3EbnYSkMLTr4QM1jbq3UZDKVGAiMfH7bG5YXE jJYEf4EuB+iDCS6kGeOsokexim4cusMplStRE1+lq5+0ObBGJhyqoNcoGBjcfYPwJV42 RK6bnZFLhHVqtvgSyb88PiE6n42DbDIAVYOUqhZ3ULxnGeH6EWbxxq6LQF+saZUMu4XA FQKPMrrX9xfisuqVFIcAoplgPEjFtJln0yzkQ6jyBu4WMniucMTHvmEKbFkesaCYihMy p3kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qfxFWJFZ6uw2agXHgOvG4u2eDOtbo0NRWmwVpn4uFPA=; b=MvInvxjynzPZq9GqgFAtVlwGy/wz36tZsqgmH1jXGLeReS7/cnhHhBXSkmWkMP6pnS S3eBWWEMNVmuRIwsUofMn4uDMZ3D0tKBRC+99TXWEopJvRSMdb2Dshjt4uSi3WK1r58p UjwpiPjaWgi5bk75dEpjkn137VKuNtBKRH+q1KE2n0EpVJs403bXod0ocXs7s8ATIjOe hgxLvprVwbMGYDGNFZqfUXonZeT58GSptQysyVy/s+Z+in6g6iaya04NxzQfzCwcpNjy UHS/fsJLt8cVym+Hdgg0AsT1vfHPLVp6feEkri3ExjiYGSlNPbgQZUL/atqJ9+MXm3a9 PXSg== X-Gm-Message-State: AOAM533C3IoAhhEF3K8qC3iJSr8ckAsiKwQbzAwn20nRjAkI83H7ObBw U3Dh74RemDIy9q8cwB1LsFdjCA== X-Google-Smtp-Source: ABdhPJzNa8Nk7IZLK4W0O/SXUB4IqOz2lnsHa91HVJ6qB8thGBlO43hlkjSUFd9q3q4sAFC1DvyuoA== X-Received: by 2002:a17:906:6841:b0:6cf:9c02:8965 with SMTP id a1-20020a170906684100b006cf9c028965mr9570039ejs.440.1649271916774; Wed, 06 Apr 2022 12:05:16 -0700 (PDT) Received: from localhost (85-127-190-169.dsl.dynamic.surfer.at. [85.127.190.169]) by smtp.gmail.com with ESMTPSA id hq39-20020a1709073f2700b006dfc58efab9sm6897892ejc.73.2022.04.06.12.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 12:05:16 -0700 (PDT) From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= To: Jens Axboe Cc: drbd-dev@lists.linbit.com, linux-kernel@vger.kernel.org, Lars Ellenberg , Philipp Reisner , linux-block@vger.kernel.org, Lv Yunlong , =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= Subject: [PATCH 1/3] drbd: Fix five use after free bugs in get_initial_state Date: Wed, 6 Apr 2022 21:04:43 +0200 Message-Id: <20220406190445.1937206-2-christoph.boehmwalder@linbit.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406190445.1937206-1-christoph.boehmwalder@linbit.com> References: <20220406190445.1937206-1-christoph.boehmwalder@linbit.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lv Yunlong In get_initial_state, it calls notify_initial_state_done(skb,..) if cb->args[5]=3D=3D1. If genlmsg_put() failed in notify_initial_state_done(), the skb will be freed by nlmsg_free(skb). Then get_initial_state will goto out and the freed skb will be used by return value skb->len, which is a uaf bug. What's worse, the same problem goes even further: skb can also be freed in the notify_*_state_change -> notify_*_state calls below. Thus 4 additional uaf bugs happened. My patch lets the problem callee functions: notify_initial_state_done and notify_*_state_change return an error code if errors happen. So that the error codes could be propagated and the uaf bugs can be avoid. v2 reports a compilation warning. This v3 fixed this warning and built successfully in my local environment with no additional warnings. v2: https://lore.kernel.org/patchwork/patch/1435218/ Fixes: a29728463b254 ("drbd: Backport the "events2" command") Signed-off-by: Lv Yunlong Reviewed-by: Christoph B=C3=B6hmwalder --- drivers/block/drbd/drbd_int.h | 8 ++--- drivers/block/drbd/drbd_nl.c | 41 ++++++++++++++++---------- drivers/block/drbd/drbd_state.c | 18 +++++------ drivers/block/drbd/drbd_state_change.h | 8 ++--- 4 files changed, 42 insertions(+), 33 deletions(-) diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index 4b55e864a0a3..4d3efaa20b7b 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h @@ -1638,22 +1638,22 @@ struct sib_info { }; void drbd_bcast_event(struct drbd_device *device, const struct sib_info *s= ib); =20 -extern void notify_resource_state(struct sk_buff *, +extern int notify_resource_state(struct sk_buff *, unsigned int, struct drbd_resource *, struct resource_info *, enum drbd_notification_type); -extern void notify_device_state(struct sk_buff *, +extern int notify_device_state(struct sk_buff *, unsigned int, struct drbd_device *, struct device_info *, enum drbd_notification_type); -extern void notify_connection_state(struct sk_buff *, +extern int notify_connection_state(struct sk_buff *, unsigned int, struct drbd_connection *, struct connection_info *, enum drbd_notification_type); -extern void notify_peer_device_state(struct sk_buff *, +extern int notify_peer_device_state(struct sk_buff *, unsigned int, struct drbd_peer_device *, struct peer_device_info *, diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 02030c9c4d3b..b7216c186ba4 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c @@ -4549,7 +4549,7 @@ static int nla_put_notification_header(struct sk_buff= *msg, return drbd_notification_header_to_skb(msg, &nh, true); } =20 -void notify_resource_state(struct sk_buff *skb, +int notify_resource_state(struct sk_buff *skb, unsigned int seq, struct drbd_resource *resource, struct resource_info *resource_info, @@ -4591,16 +4591,17 @@ void notify_resource_state(struct sk_buff *skb, if (err && err !=3D -ESRCH) goto failed; } - return; + return 0; =20 nla_put_failure: nlmsg_free(skb); failed: drbd_err(resource, "Error %d while broadcasting event. Event seq:%u\n", err, seq); + return err; } =20 -void notify_device_state(struct sk_buff *skb, +int notify_device_state(struct sk_buff *skb, unsigned int seq, struct drbd_device *device, struct device_info *device_info, @@ -4640,16 +4641,17 @@ void notify_device_state(struct sk_buff *skb, if (err && err !=3D -ESRCH) goto failed; } - return; + return 0; =20 nla_put_failure: nlmsg_free(skb); failed: drbd_err(device, "Error %d while broadcasting event. Event seq:%u\n", err, seq); + return err; } =20 -void notify_connection_state(struct sk_buff *skb, +int notify_connection_state(struct sk_buff *skb, unsigned int seq, struct drbd_connection *connection, struct connection_info *connection_info, @@ -4689,16 +4691,17 @@ void notify_connection_state(struct sk_buff *skb, if (err && err !=3D -ESRCH) goto failed; } - return; + return 0; =20 nla_put_failure: nlmsg_free(skb); failed: drbd_err(connection, "Error %d while broadcasting event. Event seq:%u\n", err, seq); + return err; } =20 -void notify_peer_device_state(struct sk_buff *skb, +int notify_peer_device_state(struct sk_buff *skb, unsigned int seq, struct drbd_peer_device *peer_device, struct peer_device_info *peer_device_info, @@ -4739,13 +4742,14 @@ void notify_peer_device_state(struct sk_buff *skb, if (err && err !=3D -ESRCH) goto failed; } - return; + return 0; =20 nla_put_failure: nlmsg_free(skb); failed: drbd_err(peer_device, "Error %d while broadcasting event. Event seq:%u\n", err, seq); + return err; } =20 void notify_helper(enum drbd_notification_type type, @@ -4796,7 +4800,7 @@ void notify_helper(enum drbd_notification_type type, err, seq); } =20 -static void notify_initial_state_done(struct sk_buff *skb, unsigned int se= q) +static int notify_initial_state_done(struct sk_buff *skb, unsigned int seq) { struct drbd_genlmsghdr *dh; int err; @@ -4810,11 +4814,12 @@ static void notify_initial_state_done(struct sk_buf= f *skb, unsigned int seq) if (nla_put_notification_header(skb, NOTIFY_EXISTS)) goto nla_put_failure; genlmsg_end(skb, dh); - return; + return 0; =20 nla_put_failure: nlmsg_free(skb); pr_err("Error %d sending event. Event seq:%u\n", err, seq); + return err; } =20 static void free_state_changes(struct list_head *list) @@ -4841,6 +4846,7 @@ static int get_initial_state(struct sk_buff *skb, str= uct netlink_callback *cb) unsigned int seq =3D cb->args[2]; unsigned int n; enum drbd_notification_type flags =3D 0; + int err =3D 0; =20 /* There is no need for taking notification_mutex here: it doesn't matter if the initial state events mix with later state chage @@ -4849,32 +4855,32 @@ static int get_initial_state(struct sk_buff *skb, s= truct netlink_callback *cb) =20 cb->args[5]--; if (cb->args[5] =3D=3D 1) { - notify_initial_state_done(skb, seq); + err =3D notify_initial_state_done(skb, seq); goto out; } n =3D cb->args[4]++; if (cb->args[4] < cb->args[3]) flags |=3D NOTIFY_CONTINUES; if (n < 1) { - notify_resource_state_change(skb, seq, state_change->resource, + err =3D notify_resource_state_change(skb, seq, state_change->resource, NOTIFY_EXISTS | flags); goto next; } n--; if (n < state_change->n_connections) { - notify_connection_state_change(skb, seq, &state_change->connections[n], + err =3D notify_connection_state_change(skb, seq, &state_change->connecti= ons[n], NOTIFY_EXISTS | flags); goto next; } n -=3D state_change->n_connections; if (n < state_change->n_devices) { - notify_device_state_change(skb, seq, &state_change->devices[n], + err =3D notify_device_state_change(skb, seq, &state_change->devices[n], NOTIFY_EXISTS | flags); goto next; } n -=3D state_change->n_devices; if (n < state_change->n_devices * state_change->n_connections) { - notify_peer_device_state_change(skb, seq, &state_change->peer_devices[n], + err =3D notify_peer_device_state_change(skb, seq, &state_change->peer_de= vices[n], NOTIFY_EXISTS | flags); goto next; } @@ -4889,7 +4895,10 @@ static int get_initial_state(struct sk_buff *skb, st= ruct netlink_callback *cb) cb->args[4] =3D 0; } out: - return skb->len; + if (err) + return err; + else + return skb->len; } =20 int drbd_adm_get_initial_state(struct sk_buff *skb, struct netlink_callbac= k *cb) diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_stat= e.c index b8a27818ab3f..4ee11aef6672 100644 --- a/drivers/block/drbd/drbd_state.c +++ b/drivers/block/drbd/drbd_state.c @@ -1537,7 +1537,7 @@ int drbd_bitmap_io_from_worker(struct drbd_device *de= vice, return rv; } =20 -void notify_resource_state_change(struct sk_buff *skb, +int notify_resource_state_change(struct sk_buff *skb, unsigned int seq, struct drbd_resource_state_change *resource_state_change, enum drbd_notification_type type) @@ -1550,10 +1550,10 @@ void notify_resource_state_change(struct sk_buff *s= kb, .res_susp_fen =3D resource_state_change->susp_fen[NEW], }; =20 - notify_resource_state(skb, seq, resource, &resource_info, type); + return notify_resource_state(skb, seq, resource, &resource_info, type); } =20 -void notify_connection_state_change(struct sk_buff *skb, +int notify_connection_state_change(struct sk_buff *skb, unsigned int seq, struct drbd_connection_state_change *connection_state_change, enum drbd_notification_type type) @@ -1564,10 +1564,10 @@ void notify_connection_state_change(struct sk_buff = *skb, .conn_role =3D connection_state_change->peer_role[NEW], }; =20 - notify_connection_state(skb, seq, connection, &connection_info, type); + return notify_connection_state(skb, seq, connection, &connection_info, ty= pe); } =20 -void notify_device_state_change(struct sk_buff *skb, +int notify_device_state_change(struct sk_buff *skb, unsigned int seq, struct drbd_device_state_change *device_state_change, enum drbd_notification_type type) @@ -1577,10 +1577,10 @@ void notify_device_state_change(struct sk_buff *skb, .dev_disk_state =3D device_state_change->disk_state[NEW], }; =20 - notify_device_state(skb, seq, device, &device_info, type); + return notify_device_state(skb, seq, device, &device_info, type); } =20 -void notify_peer_device_state_change(struct sk_buff *skb, +int notify_peer_device_state_change(struct sk_buff *skb, unsigned int seq, struct drbd_peer_device_state_change *p, enum drbd_notification_type type) @@ -1594,7 +1594,7 @@ void notify_peer_device_state_change(struct sk_buff *= skb, .peer_resync_susp_dependency =3D p->resync_susp_dependency[NEW], }; =20 - notify_peer_device_state(skb, seq, peer_device, &peer_device_info, type); + return notify_peer_device_state(skb, seq, peer_device, &peer_device_info,= type); } =20 static void broadcast_state_change(struct drbd_state_change *state_change) @@ -1602,7 +1602,7 @@ static void broadcast_state_change(struct drbd_state_= change *state_change) struct drbd_resource_state_change *resource_state_change =3D &state_chang= e->resource[0]; bool resource_state_has_changed; unsigned int n_device, n_connection, n_peer_device, n_peer_devices; - void (*last_func)(struct sk_buff *, unsigned int, void *, + int (*last_func)(struct sk_buff *, unsigned int, void *, enum drbd_notification_type) =3D NULL; void *last_arg =3D NULL; =20 diff --git a/drivers/block/drbd/drbd_state_change.h b/drivers/block/drbd/dr= bd_state_change.h index ba80f612d6ab..d5b0479bc9a6 100644 --- a/drivers/block/drbd/drbd_state_change.h +++ b/drivers/block/drbd/drbd_state_change.h @@ -44,19 +44,19 @@ extern struct drbd_state_change *remember_old_state(str= uct drbd_resource *, gfp_ extern void copy_old_to_new_state_change(struct drbd_state_change *); extern void forget_state_change(struct drbd_state_change *); =20 -extern void notify_resource_state_change(struct sk_buff *, +extern int notify_resource_state_change(struct sk_buff *, unsigned int, struct drbd_resource_state_change *, enum drbd_notification_type type); -extern void notify_connection_state_change(struct sk_buff *, +extern int notify_connection_state_change(struct sk_buff *, unsigned int, struct drbd_connection_state_change *, enum drbd_notification_type type); -extern void notify_device_state_change(struct sk_buff *, +extern int notify_device_state_change(struct sk_buff *, unsigned int, struct drbd_device_state_change *, enum drbd_notification_type type); -extern void notify_peer_device_state_change(struct sk_buff *, +extern int notify_peer_device_state_change(struct sk_buff *, unsigned int, struct drbd_peer_device_state_change *, enum drbd_notification_type type); --=20 2.35.1 From nobody Fri Jun 19 07:19:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 518A7C433F5 for ; Wed, 6 Apr 2022 20:48:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232937AbiDFUu0 (ORCPT ); Wed, 6 Apr 2022 16:50:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231468AbiDFUuH (ORCPT ); Wed, 6 Apr 2022 16:50:07 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB0013C3DD3 for ; Wed, 6 Apr 2022 12:05:28 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id n6so6158708ejc.13 for ; Wed, 06 Apr 2022 12:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linbit-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CYx1gEnJeFhX0hcBMvC6AbJqvsenlxSyXFJsv+MoaHE=; b=kUkwYXgtmkDRKIJ/rtwUxe+JUh+m7l723YKS7NVAlM4StAuUXqmH8xc+3BCN0MHlEz ojUrzjlZiFQQfaOPd7p38msq28KtcXjTX2T0LDE+zuKmbsIV6oiasyOfB92H7rflKIhP FtXo2rFXLOuuuqU/qujPVFyIjJfqmql0/7CkgL+Sx+7g2k6kN06saRQS2fvCF0CBeQLL BQP4oIlfAOTN069s/oiVibATpiZ6X9l85PUOlK61LmXbnx+vxR3ktqtGotc28uLJOSwH U5red2z2ZKWt2Ob2iwMGMDdsUBvYSUwuiPJHwjkIyo9HdpdVIbfguhVU7uGPxqLTKBRh yrKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CYx1gEnJeFhX0hcBMvC6AbJqvsenlxSyXFJsv+MoaHE=; b=0dtiFOGzxDF754eeyILe1Ckpi91MN5Nemc3W+ZUc8EiNwT4RhDJXob4w60mh52AFeq fFUdOrdIsBhju7m4KP1VuAIBB101B5DWl7HK7qXZt0NUTRYN2aumbN7MeTDhJvcGf0Bs GRUIDU30BWvtzqgG65KECZC+hnMhL2gBTFzdXir5Zode34aMyrePNmANwJIlLuCV/qLK UXYB/xbTMmDMWToymcxR41wQXZ1eWMun2AqZjrBkYeZl4m4pRvuZ8P6wb1XE0a6dPTlw 96hxw4G6szwPerb01okAaBKdH7t+bWi7IGbFoxEY/d2ty3mkGkf1QIwARaqKvrAcMcAA i7/A== X-Gm-Message-State: AOAM531BF1Jaxss7YDvcieYoEiCiIcgDfCsX2oRlbU+kWMRDVmTQtYrL bS+xyss8xG9nZPK4uICdS3E0Ug== X-Google-Smtp-Source: ABdhPJx2iJvY96w2dmyQ/WbuQP4igjP3LilGuDdSc+3WWSR6MKk809HJ8Ox4pZZZnwIVh0jaGqwoNA== X-Received: by 2002:a17:907:8a09:b0:6df:f1c6:bfc4 with SMTP id sc9-20020a1709078a0900b006dff1c6bfc4mr9926952ejc.550.1649271926937; Wed, 06 Apr 2022 12:05:26 -0700 (PDT) Received: from localhost (85-127-190-169.dsl.dynamic.surfer.at. [85.127.190.169]) by smtp.gmail.com with ESMTPSA id n27-20020a1709062bdb00b006da975173bfsm6973025ejg.170.2022.04.06.12.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 12:05:26 -0700 (PDT) From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= To: Jens Axboe Cc: drbd-dev@lists.linbit.com, linux-kernel@vger.kernel.org, Lars Ellenberg , Philipp Reisner , linux-block@vger.kernel.org, Xiaomeng Tong , stable@vger.kernel.org, =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= Subject: [PATCH 2/3] drbd: fix an invalid memory access caused by incorrect use of list iterator Date: Wed, 6 Apr 2022 21:04:44 +0200 Message-Id: <20220406190445.1937206-3-christoph.boehmwalder@linbit.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406190445.1937206-1-christoph.boehmwalder@linbit.com> References: <20220406190445.1937206-1-christoph.boehmwalder@linbit.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaomeng Tong The bug is here: idr_remove(&connection->peer_devices, vnr); If the previous for_each_connection() don't exit early (no goto hit inside the loop), the iterator 'connection' after the loop will be a bogus pointer to an invalid structure object containing the HEAD (&resource->connections). As a result, the use of 'connection' above will lead to a invalid memory access (including a possible invalid free as idr_remove could call free_layer). The original intention should have been to remove all peer_devices, but the following lines have already done the work. So just remove this line and the unneeded label, to fix this bug. Cc: stable@vger.kernel.org Fixes: c06ece6ba6f1b ("drbd: Turn connection->volumes into connection->peer= _devices") Signed-off-by: Xiaomeng Tong Reviewed-by: Christoph B=C3=B6hmwalder Reviewed-by: Lars Ellenberg --- drivers/block/drbd/drbd_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 9676a1d214bc..d6dfa286ddb3 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2773,12 +2773,12 @@ enum drbd_ret_code drbd_create_device(struct drbd_c= onfig_context *adm_ctx, unsig =20 if (init_submitter(device)) { err =3D ERR_NOMEM; - goto out_idr_remove_vol; + goto out_idr_remove_from_resource; } =20 err =3D add_disk(disk); if (err) - goto out_idr_remove_vol; + goto out_idr_remove_from_resource; =20 /* inherit the connection state */ device->state.conn =3D first_connection(resource)->cstate; @@ -2792,8 +2792,6 @@ enum drbd_ret_code drbd_create_device(struct drbd_con= fig_context *adm_ctx, unsig drbd_debugfs_device_add(device); return NO_ERROR; =20 -out_idr_remove_vol: - idr_remove(&connection->peer_devices, vnr); out_idr_remove_from_resource: for_each_connection(connection, resource) { peer_device =3D idr_remove(&connection->peer_devices, vnr); --=20 2.35.1 From nobody Fri Jun 19 07:19:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06138C433F5 for ; Wed, 6 Apr 2022 20:48:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbiDFUul (ORCPT ); Wed, 6 Apr 2022 16:50:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232223AbiDFUuL (ORCPT ); Wed, 6 Apr 2022 16:50:11 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 970983C43A9 for ; Wed, 6 Apr 2022 12:05:35 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id qh7so6167790ejb.11 for ; Wed, 06 Apr 2022 12:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linbit-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WBo84nT6kplZvgHB/vdnS5/ZWvTiH4Rb4kDlRvn9tbE=; b=dCGktYBy5F1Zx0GypibmKeIOPcSKF5c1cY/Ymuk0WBP7hPMGCDgjNRpbJMaQmdUOcr gYSZr4Xhd5VbpijEI6kF2oECiMU2X6ZhLOtNRD8gJAwspNro6z6CEGPcE2dgt9XRiIkC wc/rLKlbEyJFdPr5AQHhwjk5wu39+KKg9427rtjmOLKqwEvjkX7pMAL6+nV2iEtorSWX QFP2g5iOxpD+6UCmitRVP30PgKOdhyq37ownMQEIANHhWgmGXh4+02nZFUFFjYzZhkm0 +qi0Vs00ytlIggtFPN3+Qo5e9UzGuCw2MtSPOYYY3lYKpQwCtfO6cInsqiDo+9v+dmy3 MWcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WBo84nT6kplZvgHB/vdnS5/ZWvTiH4Rb4kDlRvn9tbE=; b=shKWP3ar7J3y5hLgYb+lS1LYh7aqX8BsCsekaLgTNdQfItSv+6xLZnc1YlcLtUbi9S ppC3ZA15FfecnbXkEnPkiInVNEaG+vcaSPcKlJQ9X9kNprzmrM7ORQDAMGHKp33jvXjT 5FHdFGeMvAByvD+GXN314k62bJa8jOEy/VFO31Gf8+0DU+ee17JZPCJOQZnmJIyUhIah 9t6Y+98DtMHNCWwSMM14NIMNX8AeCbonOAFyhAKH568rr2Z9DRMLZczk7oZLnr2L3bKl x901cuqGHFH9Oy4JHHh1HZa5fo1BnEuRBzM1mWRclLgDk+VFGj23HtvKWRc3mTLqJNqe TE+w== X-Gm-Message-State: AOAM532a5oxWniGgM2YSDzhq1JC6OJ/+wtBcMVl+uUoLVDdfHzvakP4w JR/DHkETrc5eeTOJY7u/jZ/auQ== X-Google-Smtp-Source: ABdhPJyTsMFP8wBllOYfilYBbOCNHenhYc+BnrBSgdiicw0iXsw0UvHmIIMoOuvBBoLpOu2XvVZrfg== X-Received: by 2002:a17:907:6ea7:b0:6df:c5a2:89ca with SMTP id sh39-20020a1709076ea700b006dfc5a289camr9769965ejc.18.1649271934152; Wed, 06 Apr 2022 12:05:34 -0700 (PDT) Received: from localhost (85-127-190-169.dsl.dynamic.surfer.at. [85.127.190.169]) by smtp.gmail.com with ESMTPSA id hr38-20020a1709073fa600b006e0280f3bbdsm6914682ejc.110.2022.04.06.12.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 12:05:33 -0700 (PDT) From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= To: Jens Axboe Cc: drbd-dev@lists.linbit.com, linux-kernel@vger.kernel.org, Lars Ellenberg , Philipp Reisner , linux-block@vger.kernel.org, =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= , =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= Subject: [PATCH 3/3] drbd: set QUEUE_FLAG_STABLE_WRITES Date: Wed, 6 Apr 2022 21:04:45 +0200 Message-Id: <20220406190445.1937206-4-christoph.boehmwalder@linbit.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406190445.1937206-1-christoph.boehmwalder@linbit.com> References: <20220406190445.1937206-1-christoph.boehmwalder@linbit.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph B=C3=B6hmwalder We want our pages not to change while they are being written. Signed-off-by: Christoph B=C3=B6hmwalder --- drivers/block/drbd/drbd_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index d6dfa286ddb3..4b0b25cc916e 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2719,6 +2719,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_con= fig_context *adm_ctx, unsig sprintf(disk->disk_name, "drbd%d", minor); disk->private_data =3D device; =20 + blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, disk->queue); blk_queue_write_cache(disk->queue, true, true); /* Setting the max_hw_sectors to an odd value of 8kibyte here This triggers a max_bio_size message upon first attach or connect */ --=20 2.35.1