[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230530203116.2008-2-demi@invisiblethingslab.com>
Date: Tue, 30 May 2023 16:31:01 -0400
From: Demi Marie Obenour <demi@...isiblethingslab.com>
To: Jens Axboe <axboe@...nel.dk>,
Roger Pau Monné <roger.pau@...rix.com>,
Alasdair Kergon <agk@...hat.com>,
Mike Snitzer <snitzer@...nel.org>, dm-devel@...hat.com
Cc: Demi Marie Obenour <demi@...isiblethingslab.com>,
Marek Marczykowski-Górecki
<marmarek@...isiblethingslab.com>, linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org, xen-devel@...ts.xenproject.org,
stable@...r.kernel.org
Subject: [PATCH v2 01/16] device-mapper: Check that target specs are sufficiently aligned
Otherwise subsequent code will dereference a misaligned
`struct dm_target_spec *`, which is undefined behavior.
Signed-off-by: Demi Marie Obenour <demi@...isiblethingslab.com>
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@...r.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..34fa74c6a70db8aa67aaba3f6a2fc4f38ef736bc 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 *param)
static int next_target(struct dm_target_spec *last, uint32_t next, void *end,
struct dm_target_spec **spec, char **target_params)
{
+ static_assert(_Alignof(struct dm_target_spec) <= 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 = (struct dm_target_spec *) ((unsigned char *) last + next);
*target_params = (char *) (*spec + 1);
--
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab
Powered by blists - more mailing lists