Message ID | ZRrsYkKIQe8K6F/t@work |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1540243vqb; Mon, 2 Oct 2023 09:24:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyZ8uP+OEaMnn4Wc48WUuRuWYSLJ2FEDC4ufvh6X3KmHb6LEBD3BKqDXflCrIqH8cPnzLb X-Received: by 2002:a17:902:a417:b0:1c4:3294:74ca with SMTP id p23-20020a170902a41700b001c4329474camr8329400plq.17.1696263897839; Mon, 02 Oct 2023 09:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696263897; cv=none; d=google.com; s=arc-20160816; b=ro1WY2YVtfoTt4djSSwSMf9xGgPBMf0Oi5OD0A+YBM3pSc8ZNCtArwWfBqp/IVkuCB 4vnFu556ldA5gqEptzKJBs10jXMGnrYdGAAStylHrUQwNYETL9yqtl/+0Op373/fpeLF 4R7liuA6SiywjivLhvwBVDUq617hLdkj53VyYSBWnjxfYD23JkDvVEzSE5mh60GJYfPT FLV9N7JQpgCadEXWygTjHRitnkW6LzR+qz25mhdwRMWfbUVL1VHG7S67+Gb9vMpU958f waeXdpnH72IxnDe0I8Rwyd42dORou0bnSB9BLYxF+F9+LZbzRq6jXLDytximqyLHDEDz LR0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=b39lp3fCffOmCI5yo3gcT6hS1/f5YdDMWzbh/Ll7HeY=; fh=mZuuzH01ON1Qbm5VKvaRMIh0lEtiT3xrERe4WfTi9iU=; b=Nn9td42rXCFeDZBCteTpFzOIR7+MHBI8i8ejl71S4vAZ2grNT320gMJD8dgnl+Liga 0J438aE/PMgwdPF+zeqjKV4aiCRupAoTyrYe8dueubkrTsdbOKgsV6wdydFkffcJuKHz ZTEzSvmdYk/hiDKrAlXDipx61k9w1GQHMGVcl1d2YARD/6VGLqHEhQhIUkzIQY1cS5CE NmSv8ru1vtk1QRbVsPg7hEhdceZfPOHyoKtBeVe2KaP7E6W/safz3SPPsnYMCOvFRCVL +mNI44ohBfFQITB/khkKCjE6xaIUfBDG7QhOJVEb5muTegF+/WUo99i8gG2a/D7r/qfD Ieww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GbwsDYRm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id b1-20020a1709027e0100b001c746b986e8si7011637plm.461.2023.10.02.09.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:24:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GbwsDYRm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id F286B8098482; Mon, 2 Oct 2023 09:14:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238446AbjJBQOj (ORCPT <rfc822;pusanteemu@gmail.com> + 18 others); Mon, 2 Oct 2023 12:14:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238414AbjJBQOh (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 2 Oct 2023 12:14:37 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73E72B3 for <linux-kernel@vger.kernel.org>; Mon, 2 Oct 2023 09:14:31 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA69BC433C7; Mon, 2 Oct 2023 16:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696263271; bh=z2fk8YtqV+V10VoyiNxtWZBlzYiMUwqKV/e12y8Dpx0=; h=Date:From:To:Cc:Subject:From; b=GbwsDYRm+UDgIYREREAZP0jTTQBCIV4CJJHH7wEetdjC+jxysZa0rBH8QzAwzAFwZ v7lxoCioIVK/r5zbt1IOpNUptgXs7b3khb6v3d7hOAEGjrnJJ4yvcESo7MtDHwXTDP VdkN1SdElzRobMstfIArea3xeRsFkk8p+DIIEkIFGhJ/oqwOipzgGy0oLPoMTcuM8S 3u67P2ISVpF4mDi/QhrtiiQdxlSnVoCP0S6B8GM98iE4Yse5HtdyRDf1Ljk5oPm8N+ 6V8OiI3ER7Dx0VnidTST7wrI//SY7+4gj1/0fHBNLzT2sbyzOLUScUS1vNSaxojfOO bwl94dkd8l2sw== Date: Mon, 2 Oct 2023 18:14:26 +0200 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: Jan Kara <jack@suse.com> Cc: linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] udf: Fix undefined behavior bug in struct udf_fileident_iter Message-ID: <ZRrsYkKIQe8K6F/t@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 02 Oct 2023 09:14:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778661612845599671 X-GMAIL-MSGID: 1778661612845599671 |
Series |
[next] udf: Fix undefined behavior bug in struct udf_fileident_iter
|
|
Commit Message
Gustavo A. R. Silva
Oct. 2, 2023, 4:14 p.m. UTC
`struct fileIdentDesc` is a flexible structure, which means that it
contains a flexible-array member at the bottom. This could potentially
lead to an overwrite of the objects following `fi` in `struct
udf_fileident_iter` at run-time.
Fix this by placing the declaration of object `fi` at the end of
`struct udf_fileident_iter`.
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.
Fixes: d16076d9b684 ("udf: New directory iteration code")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
fs/udf/udfdecl.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Mon, Oct 02, 2023 at 06:14:26PM +0200, Gustavo A. R. Silva wrote: > `struct fileIdentDesc` is a flexible structure, which means that it > contains a flexible-array member at the bottom. This could potentially > lead to an overwrite of the objects following `fi` in `struct > udf_fileident_iter` at run-time. > > Fix this by placing the declaration of object `fi` at the end of > `struct udf_fileident_iter`. > > -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting > ready to enable it globally. > > Fixes: d16076d9b684 ("udf: New directory iteration code") > Cc: stable@vger.kernel.org > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Looks right. Reviewed-by: Kees Cook <keescook@chromium.org>
On Mon 02-10-23 18:14:26, Gustavo A. R. Silva wrote: > `struct fileIdentDesc` is a flexible structure, which means that it > contains a flexible-array member at the bottom. This could potentially > lead to an overwrite of the objects following `fi` in `struct > udf_fileident_iter` at run-time. > > Fix this by placing the declaration of object `fi` at the end of > `struct udf_fileident_iter`. > > -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting > ready to enable it globally. > > Fixes: d16076d9b684 ("udf: New directory iteration code") > Cc: stable@vger.kernel.org > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Thanks for the patch! This is in fact harmless since we never use the impUse field. But I agree it is confusing so I'll merge attached fix instead. Honza
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index 88692512a466..736f591abc89 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h @@ -93,11 +93,11 @@ struct udf_fileident_iter { sector_t loffset; /* Block offset of 'pos' within above * extent */ struct extent_position epos; /* Position after the above extent */ - struct fileIdentDesc fi; /* Copied directory entry */ uint8_t *name; /* Pointer to entry name */ uint8_t *namebuf; /* Storage for entry name in case * the name is split between two blocks */ + struct fileIdentDesc fi; /* Copied directory entry */ }; struct udf_vds_record {