qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Andreas Schwab <schwab@suse.de>, qemu-devel@nongnu.org
Subject: Re: linux-user: array overflow in pselect6 emulation
Date: Mon, 17 Jun 2024 18:28:39 -0700	[thread overview]
Message-ID: <7fd0eca3-cd15-48c8-ac7f-0967bbada7d2@linaro.org> (raw)
In-Reply-To: <mvmfrtbq26o.fsf@suse.de>

On 6/17/24 03:43, Andreas Schwab wrote:
> $ cat select.c
> #include <stdlib.h>
> #include <fcntl.h>
> #include <unistd.h>
> #include <sys/resource.h>
> #include <sys/select.h>
> #include <sys/syscall.h>
> 
> int
> main (int argc, char **argv)
> {
>    int nfds = (argc > 1 ? atoi (argv[1]) : 1031);
>    fd_set *fds = calloc ((nfds + (sizeof (fd_mask) * 8) - 1)
>                          / (sizeof (fd_mask) * 8), sizeof (fd_mask));
>    setrlimit (RLIMIT_NOFILE,
>               &(struct rlimit){ .rlim_cur = nfds, .rlim_max = nfds });
>    dup2 (open ("/dev/null", O_RDONLY), nfds - 1);
>    FD_SET (nfds - 1, fds);
>    syscall (SYS_pselect6, nfds, fds, 0, 0, 0, 0);
> }

Ack.

We use libc fd_set, which is sized for FD_SETSIZE at 1024.

We can either artificially limit RLIMIT_NOFILE (not ideal), or dynamically allocate all 
fd_set within qemu (which will take some time and effort).


r~


      reply	other threads:[~2024-06-18  1:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-17 10:43 linux-user: array overflow in pselect6 emulation Andreas Schwab
2024-06-18  1:28 ` Richard Henderson [this message]

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=7fd0eca3-cd15-48c8-ac7f-0967bbada7d2@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=schwab@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).