From: "Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: drbd-dev@lists.linux.dev, linux-kernel@vger.kernel.org,
"Lars Ellenberg" <lars.ellenberg@linbit.com>,
"Philipp Reisner" <philipp.reisner@linbit.com>,
linux-block@vger.kernel.org,
"Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>,
"Vivek Parikh" <vivek.parikh@breachx.ai>
Subject: [PATCH] drbd: don't leak the shared secret to unprivileged netlink dumps
Date: Fri, 14 Aug 2026 17:16:17 +0200 [thread overview]
Message-ID: <20260814151617.73752-1-christoph.boehmwalder@linbit.com> (raw)
The conversion to explicit netlink serialization dropped the
exclude_sensitive parameter from net_conf_to_skb(), so each caller has
to sanitize by hand. Two dump paths were missed:
drbd_nl_get_connections_dumpit() and the volume-less connection branch
of get_one_status(). Neither op carries GENL_ADMIN_PERM, so any
unprivileged local user could read the CRAM-HMAC secret.
Add a net_conf_to_skb_sanitized() wrapper and route all three callers
through it.
Fixes: 8098eeb693c4 ("drbd: replace genl_magic with explicit netlink serialization")
Reported-by: Vivek Parikh <vivek.parikh@breachx.ai>
Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
---
Intended for 7.2 if at all possible. Sorry for the short notice, we only
learned of this today.
drivers/block/drbd/drbd_nl.c | 39 +++++++++++++++++++++++-------------
1 file changed, 25 insertions(+), 14 deletions(-)
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index f9ffcd67607b..b77f901fc3ef 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -3306,6 +3306,26 @@ static int nla_put_drbd_cfg_context(struct sk_buff *skb,
return -EMSGSIZE;
}
+/*
+ * net_conf_to_skb() serializes the shared secret verbatim. Any path that can
+ * answer a request from an unprivileged process must pass exclude_sensitive,
+ * so the secret is blanked in a private copy before it reaches the skb.
+ */
+static int net_conf_to_skb_sanitized(struct sk_buff *skb, struct net_conf *nc,
+ bool exclude_sensitive)
+{
+ struct net_conf nc_clean;
+
+ if (!exclude_sensitive)
+ return net_conf_to_skb(skb, nc);
+
+ nc_clean = *nc;
+ memset(nc_clean.shared_secret, 0, sizeof(nc_clean.shared_secret));
+ nc_clean.shared_secret_len = 0;
+
+ return net_conf_to_skb(skb, &nc_clean);
+}
+
/*
* The generic netlink dump callbacks are called outside the genl_lock(), so
* they cannot use the simple attribute parsing code which uses global
@@ -3621,7 +3641,8 @@ int drbd_nl_get_connections_dumpit(struct sk_buff *skb, struct netlink_callback
goto out;
net_conf = rcu_dereference(connection->net_conf);
if (net_conf) {
- err = net_conf_to_skb(skb, net_conf);
+ err = net_conf_to_skb_sanitized(skb, net_conf,
+ !capable(CAP_SYS_ADMIN));
if (err)
goto out;
}
@@ -3842,18 +3863,8 @@ static int nla_put_status_info(struct sk_buff *skb, struct drbd_device *device,
struct net_conf *nc;
nc = rcu_dereference(first_peer_device(device)->connection->net_conf);
- if (nc) {
- if (exclude_sensitive) {
- struct net_conf nc_clean = *nc;
-
- memset(nc_clean.shared_secret, 0,
- sizeof(nc_clean.shared_secret));
- nc_clean.shared_secret_len = 0;
- err = net_conf_to_skb(skb, &nc_clean);
- } else {
- err = net_conf_to_skb(skb, nc);
- }
- }
+ if (nc)
+ err = net_conf_to_skb_sanitized(skb, nc, exclude_sensitive);
}
rcu_read_unlock();
if (err)
@@ -4058,7 +4069,7 @@ static int get_one_status(struct sk_buff *skb, struct netlink_callback *cb)
struct net_conf *nc;
nc = rcu_dereference(connection->net_conf);
- if (nc && net_conf_to_skb(skb, nc) != 0)
+ if (nc && net_conf_to_skb_sanitized(skb, nc, true) != 0)
goto cancel;
}
goto done;
base-commit: c7c76f9232bd34835d821f14abdc5fafc17bc938
--
2.55.0
next reply other threads:[~2026-08-14 15:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 15:16 Christoph Böhmwalder [this message]
2026-08-16 2:06 ` [PATCH] drbd: don't leak the shared secret to unprivileged netlink dumps Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260814151617.73752-1-christoph.boehmwalder@linbit.com \
--to=christoph.boehmwalder@linbit.com \
--cc=axboe@kernel.dk \
--cc=drbd-dev@lists.linux.dev \
--cc=lars.ellenberg@linbit.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=philipp.reisner@linbit.com \
--cc=vivek.parikh@breachx.ai \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox