Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11255548rwd; Thu, 22 Jun 2023 10:40:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6PG4EbfnPZ+wWb+FXFOnzLn5nTaqWw6LIaQXcVX9vMbkqEqyoGbIOhONiJcU5E5tLoHyHb X-Received: by 2002:a05:6871:6b97:b0:1ac:e6a8:9d5e with SMTP id zh23-20020a0568716b9700b001ace6a89d5emr7568150oab.20.1687455647044; Thu, 22 Jun 2023 10:40:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687455647; cv=none; d=google.com; s=arc-20160816; b=L5cY2isgbBHGpnZeQ2aOcTTEpF/pumPqHkUKhdGoZ+lH1+ZWZMrQF/4KJOEKUEtWlL QJh24xsEpD7M035FWP166nraT6VAAhBzEUvpHUu8+z+24DrY/4GLWV47eBtSyvKvBfIm mI5usKgA9sV5rH4xqxwJahmgVT8Sn1VpCBl4cxhHjKUYGLOObVQkROIugyoosh63il2O 6oFr1h+kRG4WUvQLx2PKO9hFAnyk+arFbmnVqzREQbUMmIx+C1a2BRZauGiTQzYwdP9L eim7659kAvVv3SWOIfAbEx7pJnj3POXoeb5aI9giEiK08nvfV+SWhbf82MktLiTAuHcV exPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=1APpD2vCMiT5KNJq2ZJ0gxW8qYfJ/rnhipLtpA4m9ns=; b=kudK/h3aYB9F9Z2halDNgWHhsvyPt/Kc5Wd8hfl6sehALnZrIZpO6EmPw1hqsNvGi4 CEHSRQCRf2CNtqvG4AJAB1UAEs1mDbc/TcHf2jHOVXfMEo/JbczmL5OOBYRECyDvqlVg 58WA1AV5IL/0vsc9sNmK3RVwK4D69Zya6xpYx3c4qn9ozWSXWN9XbQRHc9nKlsAwWeY4 ryGyVHMhTYwcaBh0Y0FGU0g33UY81QctO6q06ENN0O0HhjLQMuqn9nH5PFHDFkVzZR9t ma0zgSNTbkauXfE6etSyZDi/wSrfStHhGMFF5nPzDIJpO+mhLjAgNDUFfjzQyFxE4X8W vyXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eeppBWTC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l64-20020a638843000000b005533db5fbacsi6758381pgd.451.2023.06.22.10.40.25; Thu, 22 Jun 2023 10:40:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eeppBWTC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230009AbjFVRan (ORCPT + 99 others); Thu, 22 Jun 2023 13:30:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbjFVRal (ORCPT ); Thu, 22 Jun 2023 13:30:41 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57BD4195 for ; Thu, 22 Jun 2023 10:29:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687454998; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1APpD2vCMiT5KNJq2ZJ0gxW8qYfJ/rnhipLtpA4m9ns=; b=eeppBWTCp4e0D+e19WvjZE9d80BaXZ2fgQJtFaHjbNqIwEPa9Q5FC4Vudi7U0KlOp0vrof ykzcfb67g2P6u+bLUDkh5lcscufLhWXgt0pdBunYprLd6SDTdXVArjn0CYAY8sojn9Vjh2 wU8fl123Rmd9DtqCH24uKtW426bcvXM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-MhddANRwMcuqvJ5zSiXJnA-1; Thu, 22 Jun 2023 13:29:55 -0400 X-MC-Unique: MhddANRwMcuqvJ5zSiXJnA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2017B80123E; Thu, 22 Jun 2023 17:29:53 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F4F240C2063; Thu, 22 Jun 2023 17:29:53 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id EEEB630C0457; Thu, 22 Jun 2023 17:29:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id EB4353F7CF; Thu, 22 Jun 2023 19:29:52 +0200 (CEST) Date: Thu, 22 Jun 2023 19:29:52 +0200 (CEST) From: Mikulas Patocka To: Demi Marie Obenour cc: Alasdair Kergon , Mike Snitzer , 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 In-Reply-To: <20230603145244.1538-2-demi@invisiblethingslab.com> Message-ID: <7d56d190-b97c-f515-ebd0-c3790f11954@redhat.com> References: <20230601212456.1533-1-demi@invisiblethingslab.com> <20230603145244.1538-1-demi@invisiblethingslab.com> <20230603145244.1538-2-demi@invisiblethingslab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > 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)". 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. Mikulas