public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Demi Marie Obenour <demi@invisiblethingslab.com>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>,
	dm-devel@redhat.com, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [dm-devel] [PATCH v2 1/6] device-mapper: Check that target specs are sufficiently aligned
Date: Thu, 22 Jun 2023 16:27:40 -0400	[thread overview]
Message-ID: <ZJSuv0cdqGR1BEbS@itl-email> (raw)
In-Reply-To: <7d56d190-b97c-f515-ebd0-c3790f11954@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2343 bytes --]

On Thu, Jun 22, 2023 at 07:29:52PM +0200, Mikulas Patocka wrote:
> 
> 
> On Sat, 3 Jun 2023, Demi Marie Obenour wrote:
> 
> > Otherwise subsequent code will dereference a misaligned
> > `struct dm_target_spec *`, which is undefined behavior.
> > 
> > Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
> > 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..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
> 
> Hi
> 
> Some architectures (such as 32-bit x86) specify that the alignment of 
> 64-bit integers is only 4-byte. This could in theory break old userspace 
> code that only uses 4-byte alignment. I would change "next % 8" to "next % 
> __alignof__(struct dm_target_spec)".

That’s fine, provided that the rest of the code is okay with 4-byte
alignment.

> I think that there is no need to backport this patch series to the stable 
> kernels because the bugs that it fixes may only be exploited by the user 
> with CAP_SYS_ADMIN privilege. So, there is no security or reliability 
> problem being fixed.

I agree that there is no reliability problem, but with kernel lockdown
root → kernel is a security boundary, so fixes for memory unsafety
problems should still be backported IMO.
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-06-22 20:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01 21:24 [PATCH 0/6] Several device-mapper fixes Demi Marie Obenour
2023-06-01 21:24 ` [PATCH 1/6] device-mapper: Check that target specs are sufficiently aligned Demi Marie Obenour
2023-06-01 21:24 ` [PATCH 2/6] device-mapper: Avoid pointer arithmetic overflow Demi Marie Obenour
2023-06-01 21:24 ` [PATCH 3/6] device-mapper: structs and parameter strings must not overlap Demi Marie Obenour
2023-06-01 21:24 ` [PATCH 4/6] device-mapper: Avoid double-fetch of version Demi Marie Obenour
2023-06-03  7:40   ` kernel test robot
2023-06-03 14:21     ` Demi Marie Obenour
2023-06-01 21:24 ` [PATCH 5/6] device-mapper: Refuse to create device named "control" Demi Marie Obenour
2023-06-01 21:24 ` [PATCH 6/6] device-mapper: "." and ".." are not valid symlink names Demi Marie Obenour
2023-06-03 14:52 ` [PATCH v2 0/6] Several device-mapper fixes Demi Marie Obenour
2023-06-03 14:52   ` [PATCH v2 1/6] device-mapper: Check that target specs are sufficiently aligned Demi Marie Obenour
2023-06-22 16:28     ` Mike Snitzer
2023-06-22 19:51       ` Demi Marie Obenour
2023-06-22 22:54         ` Mike Snitzer
2023-06-22 17:29     ` [dm-devel] " Mikulas Patocka
2023-06-22 20:27       ` Demi Marie Obenour [this message]
2023-06-03 14:52   ` [PATCH v2 2/6] device-mapper: Avoid pointer arithmetic overflow Demi Marie Obenour
2023-06-22 17:30     ` [dm-devel] " Mikulas Patocka
2023-06-22 22:50     ` Mike Snitzer
2023-06-03 14:52   ` [PATCH v2 3/6] device-mapper: structs and parameter strings must not overlap Demi Marie Obenour
2023-06-22 17:31     ` [dm-devel] " Mikulas Patocka
2023-06-03 14:52   ` [PATCH v2 4/6] device-mapper: Avoid double-fetch of version Demi Marie Obenour
2023-06-22 16:20     ` Mike Snitzer
2023-06-22 18:43       ` Demi Marie Obenour
2023-06-03 14:52   ` [PATCH v2 5/6] device-mapper: Refuse to create device named "control" Demi Marie Obenour
2023-06-03 14:52   ` [PATCH v2 6/6] device-mapper: "." and ".." are not valid symlink names Demi Marie Obenour

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=ZJSuv0cdqGR1BEbS@itl-email \
    --to=demi@invisiblethingslab.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    --cc=stable@vger.kernel.org \
    /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