From: "Thomas Schmitt" <scdbackup@gmx.net>
To: grub-devel@gnu.org
Cc: lidong.chen@oracle.com, fengtao40@huawei.com, yanan@huawei.com,
daniel.kiper@oracle.com, lichenca2005@gmail.com
Subject: Re: [PATCH v3 5/5] fs/iso9660: Prevent skipping CE or ST at start of continuation area
Date: Sat, 21 Jan 2023 13:59:48 +0100 [thread overview]
Message-ID: <28932393136888755131@scdbackup.webframe.org> (raw)
In-Reply-To: <68684a82e50c77eebe7f0e6e5460cb08f8b06889.1674238184.git.lidong.chen@oracle.com>
Hi,
On Fri, 20 Jan 2023 19:39:42 +0000 Lidong Chen <lidong.chen@oracle.com> wrote:
> If processing of a SUSP CE entry leads to a continuation area which
> begins by entry CE or ST, then these entries were skipped without
> interpretation. In case of CE this would lead to premature end of
> processing the SUSP entries of the file. In case of ST this could
> cause following non-SUSP bytes to be interpreted as SUSP entries.
>
> Signed-off-by: Thomas Schmitt <scdbackup@gmx.net>
> Tested-by: Lidong Chen <lidong.chen@oracle.com>
> ---
> grub-core/fs/iso9660.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c
> index ca45b3424..3ddb06ed4 100644
> --- a/grub-core/fs/iso9660.c
> +++ b/grub-core/fs/iso9660.c
> @@ -50,6 +50,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
> #define GRUB_ISO9660_VOLDESC_END 255
>
> #define GRUB_ISO9660_SUSP_HEADER_SZ 4
> +#define GRUB_ISO9660_MAX_CE_HOPS 100000
>
> /* The head of a volume descriptor. */
> struct grub_iso9660_voldesc
> @@ -270,6 +271,7 @@ grub_iso9660_susp_iterate (grub_fshelp_node_t node, grub_off_t off,
> char *sua;
> struct grub_iso9660_susp_entry *entry;
> grub_err_t err;
> + int ce_counter = 0;
>
> if (sua_size <= 0)
> return GRUB_ERR_NONE;
> @@ -304,6 +306,13 @@ grub_iso9660_susp_iterate (grub_fshelp_node_t node, grub_off_t off,
> struct grub_iso9660_susp_ce *ce;
> grub_disk_addr_t ce_block;
>
> + if (++ce_counter > GRUB_ISO9660_MAX_CE_HOPS)
> + {
> + grub_free (sua);
> + return grub_error (GRUB_ERR_BAD_FS,
> + "suspecting endless CE loop");
> + }
> +
> ce = (struct grub_iso9660_susp_ce *) entry;
> sua_size = grub_le_to_cpu32 (ce->len);
> off = grub_le_to_cpu32 (ce->off);
> @@ -331,6 +340,13 @@ grub_iso9660_susp_iterate (grub_fshelp_node_t node, grub_off_t off,
> return err;
>
> entry = (struct grub_iso9660_susp_entry *) sua;
> + /*
> + * The hook function will not process CE or ST.
> + * Advancing to the next entry would skip them.
> + */
> + if (grub_strncmp ((char *) entry->sig, "CE", 2) == 0
> + || grub_strncmp ((char *) entry->sig, "ST", 2) == 0)
> + continue;
> }
>
> if (hook (entry, hook_arg))
> --
> 2.35.1
Reviewed-by: Thomas Schmitt <scdbackup@gmx.net>
Have a nice day :)
Thomas
next prev parent reply other threads:[~2023-01-21 13:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-20 19:39 [PATCH v3 0/5] fs/iso9660: Fix out-of-bounds read Lidong Chen
2023-01-20 19:39 ` [PATCH v3 1/5] fs/iso9660: Add check to prevent infinite loop Lidong Chen
2023-02-02 19:35 ` Daniel Kiper
2023-02-02 23:27 ` Lidong Chen
2023-01-20 19:39 ` [PATCH v3 2/5] fs/iso9660: Prevent read past the end of system use area Lidong Chen
2023-01-20 19:39 ` [PATCH v3 3/5] fs/iso9660: Avoid reading past the entry boundary Lidong Chen
2023-01-20 19:39 ` [PATCH v3 4/5] fs/iso9660: Incorrect check for " Lidong Chen
2023-01-20 19:39 ` [PATCH v3 5/5] fs/iso9660: Prevent skipping CE or ST at start of continuation area Lidong Chen
2023-01-21 12:59 ` Thomas Schmitt [this message]
2023-01-25 17:09 ` [PATCH v3 0/5] fs/iso9660: Fix out-of-bounds read Daniel Kiper
2023-01-25 20:24 ` Thomas Schmitt
2023-01-26 22:05 ` Glenn Washburn
2023-01-27 10:56 ` Thomas Schmitt
2023-01-27 21:24 ` Glenn Washburn
2023-01-28 8:19 ` Thomas Schmitt
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=28932393136888755131@scdbackup.webframe.org \
--to=scdbackup@gmx.net \
--cc=daniel.kiper@oracle.com \
--cc=fengtao40@huawei.com \
--cc=grub-devel@gnu.org \
--cc=lichenca2005@gmail.com \
--cc=lidong.chen@oracle.com \
--cc=yanan@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.