From nobody Mon Sep 28 23:55:40 2026 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B1C5481FA5 for ; Fri, 14 Aug 2026 15:16:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786720614; cv=none; b=uXPliIyxFj7NrKilrVg7Zz7fQmOKvPHHf3CGI3DzkuG44GrfcLVOB872D8R2RLmQ3rvDMrH4SkBwNWestpGUIZTZVIaMehQ9pOHcJxPu6OIyE6krtZ5y7ComQIRV/FjH8B22O+mt+Ya1Dc1eNQARykvf5EskKdf66fmre9lcxHA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786720614; c=relaxed/simple; bh=6dgBdo0kz8D0VhXyVT7VOnoNHF/p9ue86NPOyUvtC7c=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=AfzfeTEGJWII5259IjWg/rz1/qLWoRIa0WOa52VmDZBE86Ug2D31xCcTaVlIvYS1SL/fDnBNV+xWPLp7yUo22B67/6/dhpSr1UEp3DWGZy67yUTvRO9/3O2YZt6r/oA4T+y6Wi1xQ4YanEypnehV2VJ/pmeIh/7Xq71kg8BRkvU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linbit.com; spf=pass smtp.mailfrom=linbit.com; dkim=pass (2048-bit key) header.d=linbit-com.20251104.gappssmtp.com header.i=@linbit-com.20251104.gappssmtp.com header.b=E828Ctgn; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linbit.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linbit-com.20251104.gappssmtp.com header.i=@linbit-com.20251104.gappssmtp.com header.b="E828Ctgn" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-4815b8781c7so524961f8f.0 for ; Fri, 14 Aug 2026 08:16:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linbit-com.20251104.gappssmtp.com; s=20251104; t=1786720609; x=1787325409; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=IRB4JuBVbvsbT/EXF82Pi+P9sAHp5M7GCKevXhSfrjU=; b=E828Ctgn2560U8y9tUZMK/kvTH7LoYmylKBd1MOwWk/84rhLT4B+MBybWFZHMUD3Y5 /ElN8tBMQCVypJTA+KYGYcKffjnaiwLltspDkdpnqzQb4MSjun7BKvEwIjIcr0obaR32 wtoC3cfNKdo14HR4cE1Dz1+zErweKHKjP/a1zm8N/bb5AlDURWTJZavmPzCzQhHGIcSa UHL/t2AhhHfT8ERXAF4t4cAC9cGou6IfCkjWeOZgaKb6R9D/Kaf8PefDL04n5s4qV09Y BI18PUiIMni0OwM62rExn7xI9Lm6XXwNNrw7p+SR4esKxRr5hcdpJN9Ai8DxaU11af/d MiAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786720609; x=1787325409; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=IRB4JuBVbvsbT/EXF82Pi+P9sAHp5M7GCKevXhSfrjU=; b=Yqk9Xzd7gN6O9Jb0TnbBw7AZYBDCg8PocSDHnd1S5NA5yI3VDaoEy8DjC4iEvETK+k spVt4UV+gEKdpVAtZFhGGRlqlnxD58FhenE+ZYioaNnM94uG0hmdYfS8Kx2coPA1In1D LE0wZtOFgRaI14/WYHpzHjQxhLBGfebPnozW4Ib1Z0lViwQPBXn0++rMdQdDPsJdCcrR FP1cxZNVImjcVhBOvP27E58ogPmN+fJ6cRxXYmocWMBABC/zSPWxDU1ngzkvPtQzB/P0 /4zKf/ELIALTiTFZJ+w62MZ8upTb2RQPPRw5vV0vVwRhohgcTuKFFs2Vd3T24tQ62x6F IZRA== X-Forwarded-Encrypted: i=1; AHgh+RqUe/B+xS4BYZOKRTDypaoP7DQGrms1qiVwZ3/s/arLMEyI8MwYDc3aEWe+yACQMcUU+0xX0punwN6TRO0=@vger.kernel.org X-Gm-Message-State: AOJu0Ywd1ZdmOcUoAV8Vr62zRySurdux5Cf9YcxNK7I+1Cyhyr3BnemV q6nJ6SwC2UpGdBQEQO1gHkrE+bBv98uvvJJ3kUo7sIgqlyikrvLeDk/wxdeHSLHwwIA= X-Gm-Gg: AR+sD100XyzivKYe1MZupQtMeA+R6eWMgy/raZMiAZIIldArxWVhW1WOSkS+9sPKZlW zJiZHcHflI8lT4YZplUJeLk3y1TKEUwmHlIlTSJvMYNEt5blrF3ZcSm9oQxC3+vAJTpU6KuebTy y4wfThJ5CFySfM5Ta50LghpP0vAHBU12NvuspbLxbuThdxkpvN3xbxLT5QbOB91+2SB5v9+Liia zr1xwfpBqV8g/OKuVhVFSsTl6kP6tnNLEAnolh7L3BoYseXga+DBKDqffmn1UwQUdAYtLijelOs 4WnDGVM0WPUQJCn9MV+Kzf05X5pMrKAEFCqvb6S4F4mOL578ucf48Jk72i+Zus1Q8M+yNemYzbg z75wB1n03Eh11nc0iWBHqNmcrcAq+3BH5SukJUeFklX0uu159s3tBfr3wMWcoEfn1Ah8oTuclpL WABm+PK2kp5jQAhXycM/k/HpndQA+07w2c+J9jKy74tt8oJjBnMYi0qtGnOkF+Cgdw1kvM+1ESW zF9Yv94DfQbtMCrWun/oGRZfUxirVsZ/yVzUgvg2VQg4g== X-Received: by 2002:a05:6000:2c01:b0:47f:86af:8fe7 with SMTP id ffacd0b85a97d-48160760c23mr9039764f8f.22.1786720609341; Fri, 14 Aug 2026 08:16:49 -0700 (PDT) Received: from linbit.com (h082218129081.host.wavenet.at. [82.218.129.81]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4815f219f7bsm8742381f8f.13.2026.08.14.08.16.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2026 08:16:48 -0700 (PDT) From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= To: Jens Axboe Cc: drbd-dev@lists.linux.dev, linux-kernel@vger.kernel.org, Lars Ellenberg , Philipp Reisner , linux-block@vger.kernel.org, =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= , Vivek Parikh Subject: [PATCH] drbd: don't leak the shared secret to unprivileged netlink dumps Date: Fri, 14 Aug 2026 17:16:17 +0200 Message-ID: <20260814151617.73752-1-christoph.boehmwalder@linbit.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 serial= ization") Reported-by: Vivek Parikh Signed-off-by: Christoph B=C3=B6hmwalder --- 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; } =20 +/* + * net_conf_to_skb() serializes the shared secret verbatim. Any path that = can + * answer a request from an unprivileged process must pass exclude_sensiti= ve, + * 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 =3D *nc; + memset(nc_clean.shared_secret, 0, sizeof(nc_clean.shared_secret)); + nc_clean.shared_secret_len =3D 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 *sk= b, struct netlink_callback goto out; net_conf =3D rcu_dereference(connection->net_conf); if (net_conf) { - err =3D net_conf_to_skb(skb, net_conf); + err =3D 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; =20 nc =3D rcu_dereference(first_peer_device(device)->connection->net_conf); - if (nc) { - if (exclude_sensitive) { - struct net_conf nc_clean =3D *nc; - - memset(nc_clean.shared_secret, 0, - sizeof(nc_clean.shared_secret)); - nc_clean.shared_secret_len =3D 0; - err =3D net_conf_to_skb(skb, &nc_clean); - } else { - err =3D net_conf_to_skb(skb, nc); - } - } + if (nc) + err =3D 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; =20 nc =3D rcu_dereference(connection->net_conf); - if (nc && net_conf_to_skb(skb, nc) !=3D 0) + if (nc && net_conf_to_skb_sanitized(skb, nc, true) !=3D 0) goto cancel; } goto done; base-commit: c7c76f9232bd34835d821f14abdc5fafc17bc938 --=20 2.55.0