From nobody Sat Feb 7 17:19:47 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 75BEFC7EE31 for ; Thu, 1 Jun 2023 21:25:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231669AbjFAVZX (ORCPT ); Thu, 1 Jun 2023 17:25:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229554AbjFAVZR (ORCPT ); Thu, 1 Jun 2023 17:25:17 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B933F196; Thu, 1 Jun 2023 14:25:16 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 308695C01D5; Thu, 1 Jun 2023 17:25:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 01 Jun 2023 17:25:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1685654716; x=1685741116; bh=YCzACzClxG a/ktYTHwJaaNWjaN7phPISbw1cPfpWZUo=; b=Yow1RwdfcCR7QVK1I2IfI5kT+G 6A5aRNuZHN+dx4ifLPyv2d3v2R0GduuZCBSdHKmgS/m+GhNW3BvaPzbZ+U6WnM/f rgBbrybs0D3VMAgqza08vUvDmQRkOgum/90REHRP1dTaJ2f+coP+CpST89r8ENe9 FWA3JMY0ulvPqmSox62Rg0n84Ng0zFb1yOJoiiJI3/FI9E9U5zCLkYhS+pWqq4fu 28mNw6y5S4dLK4kWJv2tBEH50CQM8nbwdufZX9uZbYj2XwtHTE40Yzfmyy+tNYCP Lph5PXpNR/nDbxYefx4fZrm+Or/Ae6z5vsZktOoq5opqjvMX/7NiCceZetkA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1685654716; x= 1685741116; bh=YCzACzClxGa/ktYTHwJaaNWjaN7phPISbw1cPfpWZUo=; b=N yUnBK+5umNQE4gkH8ZRIQSupXiK6IgaOEfWtGj5fBmK3MdhlCcEOz3J1FS2ifIXy aXv25JePjIbEF7CTwIvZBwOU+VzGN9/p2LvRtd/kD5PrKXguZh6tVgYSAv4VEMN0 XQV3HTD/WCQZKmcBKZVMgHKX3wb3gCZXs4x/9sdd5GaMoV7n0xSGbUJw5is7571K 9ne1u78HwBavBlV9xVL+eiPPb7hu7B9kqCe28WUsgewk43aXnUknaTAW8kF6qOvF 9KjF+9CTOr9SpyNqOoVBJ8nIlBRcKRk9zDzrCa34We8N9Siz7EmAn9mDa+EHmu3y gMrMryjCv+dB7UCvFoKIw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeluddgudeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffvghm ihcuofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinh hgshhlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeejffejgffgueegudevvdejkefg hefghffhffejteekleeufeffteffhfdtudehteenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpeguvghmihesihhnvhhishhisghlvghthhhinhhg shhlrggsrdgtohhm X-ME-Proxy: Feedback-ID: iac594737:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Jun 2023 17:25:15 -0400 (EDT) From: Demi Marie Obenour To: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com Cc: Demi Marie Obenour , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/6] device-mapper: Check that target specs are sufficiently aligned Date: Thu, 1 Jun 2023 17:24:50 -0400 Message-Id: <20230601212456.1533-2-demi@invisiblethingslab.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601212456.1533-1-demi@invisiblethingslab.com> References: <20230601212456.1533-1-demi@invisiblethingslab.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Otherwise subsequent code will dereference a misaligned `struct dm_target_spec *`, which is undefined behavior. Signed-off-by: Demi Marie Obenour Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org --- drivers/md/dm-ioctl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index cc77cf3d410921432eb0c62cdede7d55b9aa674a..34fa74c6a70db8aa67aaba3f6a2= fc4f38ef736bc 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1394,6 +1394,13 @@ static inline fmode_t get_mode(struct dm_ioctl *para= m) static int next_target(struct dm_target_spec *last, uint32_t next, void *e= nd, struct dm_target_spec **spec, char **target_params) { + static_assert(_Alignof(struct dm_target_spec) <=3D 8, + "struct dm_target_spec has excessive alignment requirements"); + if (next % 8) { + DMERR("Next target spec (offset %u) is not 8-byte aligned", next); + return -EINVAL; + } + *spec =3D (struct dm_target_spec *) ((unsigned char *) last + next); *target_params =3D (char *) (*spec + 1); =20 --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab From nobody Sat Feb 7 17:19:47 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 113AFC7EE23 for ; Thu, 1 Jun 2023 21:25:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231718AbjFAVZZ (ORCPT ); Thu, 1 Jun 2023 17:25:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231346AbjFAVZT (ORCPT ); Thu, 1 Jun 2023 17:25:19 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19B3B184; Thu, 1 Jun 2023 14:25:18 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 85EE95C01DB; Thu, 1 Jun 2023 17:25:17 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 01 Jun 2023 17:25:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1685654717; x=1685741117; bh=aSjkzE25S8 BxmyJfHmxx2kjK812O0BGlmJS9UYp63Y4=; b=l1QRMld4HT61hs5D/NwPdFVT8i oLYi6LDHCqiBkgvcqQXsObJksonX1R1o0vJzWl5xO8LQpP66ixDBpNT+xKcYinHa 5gEutmzEBfhG9wbnq7gIuhJx7/m06WFwH9VKZyMZQl75wNr6tWNxZvRrBPuJ3WBU tSTOetyK7AML5Bdtm/k6YR3rL3V5pPxAsuisQtEuD0NikrdzPvQ31rh4icqmuKNe 1tnlcwk89P3puxhb4vgTQlSpzjWMsp4aPWAijOfbdNkPq8sNWTqz8kavYLZKdqEc TFNNV3U69HP9aKyik46iO8LpjGMN9t6bhM232FzLpsIRzD7qA+MSfFnMkkpA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1685654717; x= 1685741117; bh=aSjkzE25S8BxmyJfHmxx2kjK812O0BGlmJS9UYp63Y4=; b=d F7DfCZGlFoFRWdE4a0L4fK8mg1yy7Xj2devYGeeWHz12mMNDZcdG2gVhM2uLpa8o 87MPBdZW18Tj0BNrvZZaSQzUlzJp+VZwGw5crlSVzU1OZuKsSrieNijJG4JVIlEJ Ca9zONBGWxs35RtWYiG59IK5iE3jyRes2HUj4slcJoASX+q9uqreiUIy/bdtSNYO CvIE3Bc6Q3mIJZn4sieEGmsOEVfRlUtXTQxRfbsFbuFi0eEKWlyIP1+qQr85dD1i rPLvLy5JlrJqOPGLTT2uYATtLjqMScRR83owCkU5o56gAGpUqLPskVs2IEj+gkJy tCyy0acVlqNfyPM0nMYXw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeluddgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffvghm ihcuofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinh hgshhlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeejffejgffgueegudevvdejkefg hefghffhffejteekleeufeffteffhfdtudehteenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpeguvghmihesihhnvhhishhisghlvghthhhinhhg shhlrggsrdgtohhm X-ME-Proxy: Feedback-ID: iac594737:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Jun 2023 17:25:16 -0400 (EDT) From: Demi Marie Obenour To: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com Cc: Demi Marie Obenour , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 2/6] device-mapper: Avoid pointer arithmetic overflow Date: Thu, 1 Jun 2023 17:24:51 -0400 Message-Id: <20230601212456.1533-3-demi@invisiblethingslab.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601212456.1533-1-demi@invisiblethingslab.com> References: <20230601212456.1533-1-demi@invisiblethingslab.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Especially on 32-bit systems, it is possible for the pointer arithmetic to overflow and cause a userspace pointer to be dereferenced in the kernel. Signed-off-by: Demi Marie Obenour Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org --- drivers/md/dm-ioctl.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 34fa74c6a70db8aa67aaba3f6a2fc4f38ef736bc..64e8f16d344c47057de5e2d29e3= d63202197dca0 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1396,6 +1396,25 @@ static int next_target(struct dm_target_spec *last, = uint32_t next, void *end, { static_assert(_Alignof(struct dm_target_spec) <=3D 8, "struct dm_target_spec has excessive alignment requirements"); + static_assert(offsetof(struct dm_ioctl, data) >=3D sizeof(struct dm_targe= t_spec), + "struct dm_target_spec too big"); + + /* + * Number of bytes remaining, starting with last. This is always + * sizeof(struct dm_target_spec) or more, as otherwise *last was + * out of bounds already. + */ + size_t remaining =3D (char *)end - (char *)last; + + /* + * There must be room for both the next target spec and the + * NUL-terminator of the target itself. + */ + if (remaining - sizeof(struct dm_target_spec) <=3D next) { + DMERR("Target spec extends beyond end of parameters"); + return -EINVAL; + } + if (next % 8) { DMERR("Next target spec (offset %u) is not 8-byte aligned", next); return -EINVAL; --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab From nobody Sat Feb 7 17:19:47 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 9390CC7EE23 for ; Thu, 1 Jun 2023 21:25:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231942AbjFAVZa (ORCPT ); Thu, 1 Jun 2023 17:25:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231499AbjFAVZU (ORCPT ); Thu, 1 Jun 2023 17:25:20 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B7B6196; Thu, 1 Jun 2023 14:25:19 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id ED3F95C01D0; Thu, 1 Jun 2023 17:25:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 01 Jun 2023 17:25:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1685654718; x=1685741118; bh=YZHd7YYjlD K6sv+mkKSJgYpLNyemRttpNw5QnchM4bE=; b=kS5wGTshap2i++C5h1+TcSncc2 FyNT5Ls4NghWOFzLklCX4jfQm1SrfiXo66GC2isWcdxhTthn0WyMAHJaWEIeAz+d BeX9M9RDPL9Y32OquGNX3RVXOvnLAhrGYDV+GrhQoe7w6g3Bo4YXRwDHWmbrjnY0 WNNLkrPKPXI5Q74v546DBQ2iNrddhKnRHV9xPTCveDoRefQPpBU4KmQqdG48oJ/6 G/W62z6gUVGPcamLkxaQUnvUXev+4NevkSbPwuH+6MD7sjFaBPbCTNg13yhHJ2EZ 7tdxmXFToLqpFMwqVK6xCQjEK7EwvWniq9DdGBOQLTmBrufHLPxrPaSi6FAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1685654718; x= 1685741118; bh=YZHd7YYjlDK6sv+mkKSJgYpLNyemRttpNw5QnchM4bE=; b=B jqUds5OJLEiOrCvY8DDYia28d8+AGuiTY0nV6LPPKaTx+2zjEBJoQsS49+hlmZjI CCTkhS56YM2FuYbq7EQm58qze9jCa9ZEs/C13ZOvxaTI9Tl8pbvJ/knc4WZznSHQ MtZATudiq2KU6e7ye3tVGSloyyUNvbAW4ELQtPc0M/qLLs3q2CaW1WRBau8g0Zvz wwGCKiBv9yz6zE7qcgA3i62dbnnrgrNXScb/hXZjeWqxGtz9+SC7jIZY8C9L9uu1 Ydnv/N9NaPZM3jBZJ3mozb75d8Nt6Lv4EhXSHAlAXkNYFIosfaC3dGicb470Oi98 r+T0c9ScG7TQmBXyjXHMQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeluddgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffvghm ihcuofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinh hgshhlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeejffejgffgueegudevvdejkefg hefghffhffejteekleeufeffteffhfdtudehteenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpeguvghmihesihhnvhhishhisghlvghthhhinhhg shhlrggsrdgtohhm X-ME-Proxy: Feedback-ID: iac594737:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Jun 2023 17:25:18 -0400 (EDT) From: Demi Marie Obenour To: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com Cc: Demi Marie Obenour , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 3/6] device-mapper: structs and parameter strings must not overlap Date: Thu, 1 Jun 2023 17:24:52 -0400 Message-Id: <20230601212456.1533-4-demi@invisiblethingslab.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601212456.1533-1-demi@invisiblethingslab.com> References: <20230601212456.1533-1-demi@invisiblethingslab.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The NUL terminator for each target parameter string must precede the following 'struct dm_target_spec'. Otherwise, dm_split_args() might corrupt this struct. Furthermore, the first 'struct dm_target_spec' must come after the 'struct dm_ioctl', as if it overlaps too much dm_split_args() could corrupt the 'struct dm_ioctl'. Signed-off-by: Demi Marie Obenour Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org --- drivers/md/dm-ioctl.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 64e8f16d344c47057de5e2d29e3d63202197dca0..da6ca26b51d0953df380582bb3a= 51c2ec22c27cb 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1391,7 +1391,7 @@ static inline fmode_t get_mode(struct dm_ioctl *param) return mode; } =20 -static int next_target(struct dm_target_spec *last, uint32_t next, void *e= nd, +static int next_target(struct dm_target_spec *last, uint32_t next, const c= har *end, struct dm_target_spec **spec, char **target_params) { static_assert(_Alignof(struct dm_target_spec) <=3D 8, @@ -1404,7 +1404,7 @@ static int next_target(struct dm_target_spec *last, u= int32_t next, void *end, * sizeof(struct dm_target_spec) or more, as otherwise *last was * out of bounds already. */ - size_t remaining =3D (char *)end - (char *)last; + size_t remaining =3D end - (char *)last; =20 /* * There must be room for both the next target spec and the @@ -1423,10 +1423,7 @@ static int next_target(struct dm_target_spec *last, = uint32_t next, void *end, *spec =3D (struct dm_target_spec *) ((unsigned char *) last + next); *target_params =3D (char *) (*spec + 1); =20 - if (*spec < (last + 1)) - return -EINVAL; - - return invalid_str(*target_params, end); + return 0; } =20 static int populate_table(struct dm_table *table, @@ -1436,8 +1433,9 @@ static int populate_table(struct dm_table *table, unsigned int i =3D 0; struct dm_target_spec *spec =3D (struct dm_target_spec *) param; uint32_t next =3D param->data_start; - void *end =3D (void *) param + param_size; + const char *const end =3D (const char *) param + param_size; char *target_params; + size_t min_size =3D sizeof(struct dm_ioctl); =20 if (!param->target_count) { DMERR("%s: no targets specified", __func__); @@ -1445,6 +1443,13 @@ static int populate_table(struct dm_table *table, } =20 for (i =3D 0; i < param->target_count; i++) { + const char *nul_terminator; + + if (next < min_size) { + DMERR("%s: next target spec (offset %u) overlaps %s", + __func__, next, i ? "previous target" : "'struct dm_ioctl'"); + return -EINVAL; + } =20 r =3D next_target(spec, next, end, &spec, &target_params); if (r) { @@ -1452,6 +1457,15 @@ static int populate_table(struct dm_table *table, return r; } =20 + nul_terminator =3D memchr(target_params, 0, (size_t)(end - target_params= )); + if (nul_terminator =3D=3D NULL) { + DMERR("%s: target parameters not NUL-terminated", __func__); + return -EINVAL; + } + + /* Add 1 for NUL terminator */ + min_size =3D (size_t)(nul_terminator - (const char *)spec) + 1; + r =3D dm_table_add_target(table, spec->target_type, (sector_t) spec->sector_start, (sector_t) spec->length, --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab From nobody Sat Feb 7 17:19:47 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 84A5CC77B7E for ; Thu, 1 Jun 2023 21:25:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231992AbjFAVZe (ORCPT ); Thu, 1 Jun 2023 17:25:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231555AbjFAVZV (ORCPT ); Thu, 1 Jun 2023 17:25:21 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7F85184; Thu, 1 Jun 2023 14:25:20 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 51B315C01D4; Thu, 1 Jun 2023 17:25:20 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 01 Jun 2023 17:25:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1685654720; x=1685741120; bh=vjypfpPRoU 7xNHCTk2Gztx5IGWJumVDp62oiO1y8MH4=; b=QS6kbn1lVsQPDjeMFPYE/Nfixp fCec3RGDWj6Zx5E0RTWRDq9aZpHhu181d4dpYWzyYWJkyS68BUpOBwWq9DhhATO8 +ZyBhwwLPCBa+DtOU5kHp2eKiyWC2Oecwar73chh2Mtx+xjBFcKIKA2khgz1rVeV dqolwNaATMsXQ1BpanFenABNHzXkYvKkVtEwHLQvT2qi7i/TzkBlH0Du9gu8Cb6q +xHgEyKWJM55WSAp9bmt3ilgAAwWbrBWRsCW+/NnfyBKVRpzG97LN/nVzPZ3VCBA RmlCK+QFDK/qWevsJMvnWVW5MPgUVXArM3gYHEelsbECGNCROp/bQaBKBN2A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1685654720; x= 1685741120; bh=vjypfpPRoU7xNHCTk2Gztx5IGWJumVDp62oiO1y8MH4=; b=W Tz8zIWLRlgVtvoDLu1mw4rwdnZkCAMXL782bpRiHn9mJ1e/HL6qrZ8PEDx9FODhn 6e3xsfUl+zdXAH57zyhQkqqlEDtqt81pCD/UmXnJ/BWgtQ5vvUn6Voicq3dVGEZG RYReNPna7FeinAC4Tblf1qkgk19vioYsk02MBisIZuqiiPCiTy+Bu6/tBnlnsNym gYgHTt6CYZgEAaSfaRovs3FKiAcrd/My1ThqoCXxRmVszwtuWWhn8Y5YjyoXOhiq OPt8Ix7lDNWHhNv1gwkal4GgI/FBiSG7IauAlSD09+ap6f/XohvCXb5+oHFmBkat zB53v6zhxe+Tb+GWDW7KQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeluddgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffvghm ihcuofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinh hgshhlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeejffejgffgueegudevvdejkefg hefghffhffejteekleeufeffteffhfdtudehteenucevlhhushhtvghrufhiiigvpedune curfgrrhgrmhepmhgrihhlfhhrohhmpeguvghmihesihhnvhhishhisghlvghthhhinhhg shhlrggsrdgtohhm X-ME-Proxy: Feedback-ID: iac594737:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Jun 2023 17:25:19 -0400 (EDT) From: Demi Marie Obenour To: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com Cc: Demi Marie Obenour , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 4/6] device-mapper: Avoid double-fetch of version Date: Thu, 1 Jun 2023 17:24:53 -0400 Message-Id: <20230601212456.1533-5-demi@invisiblethingslab.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601212456.1533-1-demi@invisiblethingslab.com> References: <20230601212456.1533-1-demi@invisiblethingslab.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The version is fetched once in check_version(), which then does some validation and then overwrites the version in userspace with the API version supported by the kernel. copy_params() then fetches the version from userspace *again*, and this time no validation is done. The result is that the kernel's version number is completely controllable by userspace, provided that userspace can win a race condition. Fix this flaw by not copying the version back to the kernel the second time. This is not exploitable as the version is not further used in the kernel. However, it could become a problem if future patches start relying on the version field. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Demi Marie Obenour --- drivers/md/dm-ioctl.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index da6ca26b51d0953df380582bb3a51c2ec22c27cb..fd46b249f6f856c49752063fc49= d720e95df0525 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1873,12 +1873,13 @@ static ioctl_fn lookup_ioctl(unsigned int cmd, int = *ioctl_flags) * As well as checking the version compatibility this always * copies the kernel interface version out. */ -static int check_version(unsigned int cmd, struct dm_ioctl __user *user) +static int check_version(unsigned int cmd, struct dm_ioctl __user *user, + struct dm_ioctl *kernel_params) { - uint32_t version[3]; int r =3D 0; + uint32_t *version =3D kernel_params->version; =20 - if (copy_from_user(version, user->version, sizeof(version))) + if (copy_from_user(version, user->version, sizeof(user->version))) return -EFAULT; =20 if ((version[0] !=3D DM_VERSION_MAJOR) || @@ -1922,7 +1923,10 @@ static int copy_params(struct dm_ioctl __user *user,= struct dm_ioctl *param_kern const size_t minimum_data_size =3D offsetof(struct dm_ioctl, data); unsigned int noio_flag; =20 - if (copy_from_user(param_kernel, user, minimum_data_size)) + /* Version has been copied from userspace already, avoid TOCTOU */ + if (copy_from_user((char *)param_kernel + sizeof(param_kernel->version), + (char __user *)user + sizeof(param_kernel->version), + minimum_data_size - sizeof(param_kernel->version))) return -EFAULT; =20 if (param_kernel->data_size < minimum_data_size) { @@ -2034,7 +2038,7 @@ static int ctl_ioctl(struct file *file, uint command,= struct dm_ioctl __user *us * Check the interface version passed in. This also * writes out the kernel's interface version. */ - r =3D check_version(cmd, user); + r =3D check_version(cmd, user, ¶m_kernel); if (r) return r; =20 --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab From nobody Sat Feb 7 17:19:47 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 A5540C77B7E for ; Thu, 1 Jun 2023 21:25:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231890AbjFAVZh (ORCPT ); Thu, 1 Jun 2023 17:25:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231600AbjFAVZX (ORCPT ); Thu, 1 Jun 2023 17:25:23 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A4D5196 for ; Thu, 1 Jun 2023 14:25:22 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id B76685C01DE; Thu, 1 Jun 2023 17:25:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 01 Jun 2023 17:25:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1685654721; x=1685741121; bh=ffgts7SPxx BHaUW6ToONfIVOqBLR5Qtq9BQQd24YCS0=; b=mFKpWD+bo1BnXnUNmn90TseJTH zB9LGzQOGIh2TdQeK8B4IUEUfDF0SktjtFEtA5ePrda1NpjZR/OWEegZq46Lc2Tx w9risN2HGDpnmYc0FyA5eRbK90QtjwceqjOTzLOBmnS8FnF2zVFRK4DHXMd7ogmG UaDAPC9L6iE5jRk6jbJqkMdISXqJ3p1Z5xQ5QbHrhAfAqK1TKi4xtoNKbY6ZTP/X PlHWYTzzhJmHy30vAlPWfRKK0lR7bPzTNe0v0ySH0lp7LqikNZJjRoqwlICptW75 YuI858CCZgLiAOACOjRT3+WnM1DjUUxW24JwIrEKW4mmcAV+0jsjm3hOxc/Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1685654721; x= 1685741121; bh=ffgts7SPxxBHaUW6ToONfIVOqBLR5Qtq9BQQd24YCS0=; b=D v1sD4nspvJagskYKVDs0ENPh6b8ojw+Ac8rHiSgpnl84ZrmcOX0ABHdxZKeqipFd O3xTLaS0oR9pkOiX+6xywMA19bL4h84r+KiB3I5H/W8KCvoBVl8yKh2+PdtmGUm5 TV5GbSRMChEqlOfoxStcaimCgk0LNFqDezwsrLD+g1J51Si/RONSDMAlvQS/Hqcj XUpUH1EvfgMnjPfkdXU5IIlpfNCarZJyz8DdCK6QmZvnWPodu/KW6i3NWJRD7vlF RhWNHYgOwNDsKkrskbgwLo4+lLypJvSTm0JLYsVxdgQRaR9uJvi0pr+gv7gSurQ/ bDectfKORAJ6kZ+qVuoSw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeluddgudeitdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffvghm ihcuofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinh hgshhlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeejffejgffgueegudevvdejkefg hefghffhffejteekleeufeffteffhfdtudehteenucevlhhushhtvghrufhiiigvpedune curfgrrhgrmhepmhgrihhlfhhrohhmpeguvghmihesihhnvhhishhisghlvghthhhinhhg shhlrggsrdgtohhm X-ME-Proxy: Feedback-ID: iac594737:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Jun 2023 17:25:21 -0400 (EDT) From: Demi Marie Obenour To: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com Cc: Demi Marie Obenour , linux-kernel@vger.kernel.org Subject: [PATCH 5/6] device-mapper: Refuse to create device named "control" Date: Thu, 1 Jun 2023 17:24:54 -0400 Message-Id: <20230601212456.1533-6-demi@invisiblethingslab.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601212456.1533-1-demi@invisiblethingslab.com> References: <20230601212456.1533-1-demi@invisiblethingslab.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Typical userspace setups create a symlink under /dev/mapper with the name of the device, but /dev/mapper/control is reserved for the control device. Therefore, trying to create such a device is almost certain to be a userspace bug. Signed-off-by: Demi Marie Obenour --- drivers/md/dm-ioctl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index fd46b249f6f856c49752063fc49d720e95df0525..b12592bcb4b2b8513f5da6208fb= 545203534d7ff 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -767,7 +767,12 @@ static int get_target_version(struct file *filp, struc= t dm_ioctl *param, size_t static int check_name(const char *name) { if (strchr(name, '/')) { - DMERR("invalid device name"); + DMERR("device name cannot contain '/'"); + return -EINVAL; + } + + if (strcmp(name, DM_CONTROL_NODE) =3D=3D 0) { + DMERR("device name cannot be \"%s\"", DM_CONTROL_NODE); return -EINVAL; } =20 --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab From nobody Sat Feb 7 17:19:47 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 1D61BC77B7E for ; Thu, 1 Jun 2023 21:25:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232084AbjFAVZm (ORCPT ); Thu, 1 Jun 2023 17:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231700AbjFAVZZ (ORCPT ); Thu, 1 Jun 2023 17:25:25 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A08CB195 for ; Thu, 1 Jun 2023 14:25:24 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 1827B5C01D9; Thu, 1 Jun 2023 17:25:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 01 Jun 2023 17:25:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1685654724; x=1685741124; bh=h/1KwQmVaB XUd1H3OHkX9KZBr+WvyoaYktC9lrYuvik=; b=kMK42/eP2QQw4iUjZwnuhTf7+N I8hnwQvpNyGrcpi701r+NYHbQNUNNtEkwodP+KKRX25LcWStIj6vg866vTVQ6t3c bldGK7ptPX1Gw6AspQW46YYt36yXWssA/PptTC7RvTMO784ZrR+uyt+kdQoXNxsM nDBewdaCVISlh5JZ19A4bDdvWKN6/L+L8QT8Q98+tgiKO79IwN6gJfzHNCiCx2cH I5expoAb73sL4DRIUBcdrcF8f0Ha7O7XlAuFfLn3yw2bbGqibn4yTc5gloWJKe7O ajCG3rM4H2NA+xa751J0cyC98iNe9YXFT6yluN7w2Kb8eyM6fdjL3QD7c+fQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1685654724; x= 1685741124; bh=h/1KwQmVaBXUd1H3OHkX9KZBr+WvyoaYktC9lrYuvik=; b=a TkAGIVwq2iFivqFUKv2DA1VXOJJnOlnFEzrgATMUTlhvLHCgMW/qBYE6xJHH68Rc 59UUXKm7wT4hq98cjMhkY+KnWJLS8nH0Sym3gB82X2HAydwujG/4Uz67emSIKOPc dOofJ08BkOCrCY2L0FPK0B9Hi9FE+vNkkyTyGEHJ2cMdtMminLMqWqFVE2zXnChz Fk6WhTpiRuMyhjnDzLtsWQ1y5hgOdhpN+UBzMVauvtZ1jjGKLly1L9fMgzxt32tX mjD9kfCAacfZh4MBl3d8yaJtA5vPfScToCaSNEYieLfPPbbdHQqCBjYzZC3Fp9yw Pwfor2M+KQyJooGa4MvCA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeluddgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffvghm ihcuofgrrhhivgcuqfgsvghnohhurhcuoeguvghmihesihhnvhhishhisghlvghthhhinh hgshhlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeejffejgffgueegudevvdejkefg hefghffhffejteekleeufeffteffhfdtudehteenucevlhhushhtvghrufhiiigvpedune curfgrrhgrmhepmhgrihhlfhhrohhmpeguvghmihesihhnvhhishhisghlvghthhhinhhg shhlrggsrdgtohhm X-ME-Proxy: Feedback-ID: iac594737:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Jun 2023 17:25:23 -0400 (EDT) From: Demi Marie Obenour To: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com Cc: Demi Marie Obenour , linux-kernel@vger.kernel.org Subject: [PATCH 6/6] device-mapper: "." and ".." are not valid symlink names Date: Thu, 1 Jun 2023 17:24:55 -0400 Message-Id: <20230601212456.1533-7-demi@invisiblethingslab.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601212456.1533-1-demi@invisiblethingslab.com> References: <20230601212456.1533-1-demi@invisiblethingslab.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Using either of these is going to greatly confuse userspace, as they are not valid symlink names and so creating the usual /dev/mapper/NAME symlink will not be possible. As creating a device with either of these names is almost certainly a userspace bug, just error out. Signed-off-by: Demi Marie Obenour --- drivers/md/dm-ioctl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index b12592bcb4b2b8513f5da6208fb545203534d7ff..adf0c4becc743e4ad59e1d6b0ef= 108ddd56f207d 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -771,8 +771,10 @@ static int check_name(const char *name) return -EINVAL; } =20 - if (strcmp(name, DM_CONTROL_NODE) =3D=3D 0) { - DMERR("device name cannot be \"%s\"", DM_CONTROL_NODE); + if (strcmp(name, DM_CONTROL_NODE) =3D=3D 0 || + strcmp(name, ".") =3D=3D 0 || + strcmp(name, "..") =3D=3D 0) { + DMERR("device name cannot be \"%s\", \".\", or \"..\"", DM_CONTROL_NODE); return -EINVAL; } =20 --=20 Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab