From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s
Date: Wed, 9 Mar 2016 13:59:03 +0100 [thread overview]
Message-ID: <56E01E17.6000508@redhat.com> (raw)
In-Reply-To: <20160309080750.GR2377@pxdev.xzpeter.org>
On 09/03/2016 09:07, Peter Xu wrote:
>>> > > pxdev:bin# gcc -v
>>> > > Using built-in specs.
>>> > > COLLECT_GCC=/bin/gcc
>>> > > COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
>>> > > Target: x86_64-redhat-linux
>>> > > Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
>>> > > Thread model: posix
>>> > > gcc version 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
>>> > >
>>> > > Do you know why "might not be inlinable"? Failed to figure it out
>>> > > myself as mentioned in cover letter..
>> >
>> > It's just a difference in compiler versions. But ARRAY_SIZE should be
>> > enough to fix it.
> It's dynamically allocated in stack, can we still use ARRAY_SIZE in
> this case?
>
> Maybe for this case, best to use both stack and heap? malloc only if
> buffer big enough.
If you look at users, they only write about 20 bytes at most. My
suggestion is to use your patch, and replace
assert(__BUF_SIZE >= n);
with
assert(n < ARRAY_SIZE(tmp));
Then you don't need the #define.
Paolo
next prev parent reply other threads:[~2016-03-09 12:59 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-08 7:00 [Qemu-devel] [PATCH 0/8] Fix several unbounded stack usage Peter Xu
2016-03-08 7:00 ` [Qemu-devel] [PATCH 1/8] qdict: fix unbounded stack for qdict_array_entries Peter Xu
2016-03-08 8:22 ` Markus Armbruster
2016-03-08 10:19 ` Kevin Wolf
2016-03-08 16:21 ` Eric Blake
2016-03-08 16:30 ` Kevin Wolf
2016-03-08 16:50 ` Daniel P. Berrange
2016-03-09 2:57 ` Peter Xu
2016-03-09 3:04 ` Eric Blake
2016-03-09 3:27 ` Peter Xu
2016-03-09 9:48 ` Kevin Wolf
2016-03-09 13:23 ` Markus Armbruster
2016-03-09 13:57 ` Kevin Wolf
2016-03-09 21:03 ` Markus Armbruster
2016-03-10 1:30 ` Peter Xu
2016-03-08 7:00 ` [Qemu-devel] [PATCH 2/8] block: fix unbounded stack for dump_qdict Peter Xu
2016-03-08 8:12 ` Markus Armbruster
2016-03-08 8:53 ` Fam Zheng
2016-03-08 13:47 ` Markus Armbruster
2016-03-09 3:00 ` Peter Xu
2016-03-08 9:31 ` Peter Xu
2016-03-08 13:50 ` Markus Armbruster
2016-03-08 12:17 ` Paolo Bonzini
2016-03-09 3:18 ` Peter Xu
2016-03-08 7:00 ` [Qemu-devel] [PATCH 3/8] usb: fix unbounded stack for ohci_td_pkt Peter Xu
2016-03-08 12:20 ` Paolo Bonzini
2016-03-09 4:59 ` Peter Xu
2016-03-08 7:00 ` [Qemu-devel] [PATCH 4/8] usb: fix unbounded stack for xhci_dma_write_u32s Peter Xu
2016-03-08 7:26 ` Peter Maydell
2016-03-09 5:12 ` Peter Xu
2016-03-08 12:21 ` Paolo Bonzini
2016-03-09 5:08 ` Peter Xu
2016-03-09 7:53 ` Paolo Bonzini
2016-03-09 8:07 ` Peter Xu
2016-03-09 8:34 ` Markus Armbruster
2016-03-09 9:19 ` Peter Xu
2016-03-09 12:52 ` Markus Armbruster
2016-03-09 12:59 ` Paolo Bonzini [this message]
2016-03-10 2:07 ` Peter Xu
2016-03-08 7:00 ` [Qemu-devel] [PATCH 5/8] usb: fix unbounded stack for inotify_watchfn Peter Xu
2016-03-08 7:20 ` Peter Maydell
2016-03-08 12:22 ` Paolo Bonzini
2016-03-09 5:22 ` Peter Xu
2016-03-08 12:22 ` Paolo Bonzini
2016-03-09 5:23 ` Peter Xu
2016-03-08 7:00 ` [Qemu-devel] [PATCH 6/8] usb: fix unbounded stack for usb_mtp_add_str Peter Xu
2016-03-08 8:10 ` Gerd Hoffmann
2016-03-09 5:29 ` Peter Xu
2016-03-08 7:00 ` [Qemu-devel] [PATCH 7/8] migration: fix unbounded stack for source_return_path_thread Peter Xu
2016-03-08 9:48 ` Juan Quintela
2016-03-08 12:27 ` Paolo Bonzini
2016-03-08 12:26 ` Paolo Bonzini
2016-03-09 5:27 ` Peter Xu
2016-03-08 7:00 ` [Qemu-devel] [PATCH 8/8] hw/i386: fix unbounded stack for load_multiboot Peter Xu
2016-03-08 7:17 ` Peter Maydell
2016-03-08 12:29 ` Paolo Bonzini
2016-03-09 5:39 ` Peter Xu
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=56E01E17.6000508@redhat.com \
--to=pbonzini@redhat.com \
--cc=kraxel@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.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 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).