All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@altlinux.org>
To: Vitaly Chikunov <vt@altlinux.org>
Cc: qemu-stable@nongnu.org,
	Christian Schoenebeck <qemu_oss@crudebyte.com>,
	qemu-devel@nongnu.org, Greg Kurz <groug@kaod.org>
Subject: Re: [PATCH v2] 9pfs: Fix segfault in do_readdir_many caused by struct dirent overread
Date: Fri, 4 Feb 2022 03:22:38 +0300	[thread overview]
Message-ID: <20220204002237.GD7780@altlinux.org> (raw)
In-Reply-To: <20220204001516.n5ma26x3wxsoixeb@altlinux.org>

On Fri, Feb 04, 2022 at 03:15:16AM +0300, Vitaly Chikunov wrote:
[...]
> Yes but this will cause another abort() call. I am thinking about v3 fix
> like this:
> 
>   struct dirent *
>   qemu_dirent_dup(struct dirent *dent)
>   {
>       size_t sz = 0;
>   #if defined _DIRENT_HAVE_D_RECLEN
>       /* Avoid use of strlen() if there's d_reclen. */
>       sz = dent->d_reclen;
>   #endif
>       if (sz == 0) {
>           /* Fallback to the most portable way. */
>           sz = offsetof(struct dirent, d_name) +
> 			strlen(dent->d_name) + 1;
>       }
>       struct dirent *dst = g_malloc(sz);
>       return memcpy(dst, dent, sz);
>   }
> 
> Thus it will use strlen for simulated dirents and d_reclen for real ones

Makes sense.


-- 
ldv


  reply	other threads:[~2022-02-04  0:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-28 22:33 [PATCH v2] 9pfs: Fix segfault in do_readdir_many caused by struct dirent overread Vitaly Chikunov
2022-01-31 13:45 ` Christian Schoenebeck
2022-02-02 16:55 ` Christian Schoenebeck
2022-02-03  4:55   ` Vitaly Chikunov
2022-02-03  6:20     ` Vitaly Chikunov
2022-02-03 12:31       ` Christian Schoenebeck
2022-02-03 12:42 ` Christian Schoenebeck
2022-02-04  0:15   ` Vitaly Chikunov
2022-02-04  0:22     ` Dmitry V. Levin [this message]
2022-02-04 12:12       ` Christian Schoenebeck

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=20220204002237.GD7780@altlinux.org \
    --to=ldv@altlinux.org \
    --cc=groug@kaod.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    --cc=vt@altlinux.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 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.