From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 4/4] Add test for CVE 2020-29373
Date: Mon, 8 Feb 2021 10:48:15 +0100 [thread overview]
Message-ID: <YCEI39Xxo80VkIE9@pevik> (raw)
In-Reply-To: <9a49f90c-7467-ae65-84be-2f559a8771dd@suse.cz>
Hi Martin,
> >> + /* Add spam requests to force async processing of the real test */
> >> + for (i = 0, tail = *uring.sqr_tail; i < 255; i++, tail++, sqe_ptr++) {
> >> + memset(sqe_ptr, 0, sizeof(*sqe_ptr));
> >> + sqe_ptr->opcode = IORING_OP_SENDMSG;
> >> + sqe_ptr->flags = IOSQE_IO_DRAIN;
> >> + sqe_ptr->fd = sockpair[0];
> >> + sqe_ptr->addr = (__u64)&spam_header;
> >> + sqe_ptr->user_data = SPAM_MARK;
> > Interesting, original reproducer uses here i
> >> + uring.sqr_array[tail & *uring.sqr_mask] = i;
> >> + }
> >> +
> >> + /* Add the real test to queue */
> >> + memset(sqe_ptr, 0, sizeof(*sqe_ptr));
> >> + sqe_ptr->opcode = IORING_OP_SENDMSG;
> >> + sqe_ptr->flags = IOSQE_IO_DRAIN;
> >> + sqe_ptr->fd = sendsock;
> >> + sqe_ptr->addr = (__u64)&beef_header;
> >> + sqe_ptr->user_data = BEEF_MARK;
> > and here also 255, you use much higher 0xbeef.
> > You probably have a good reason to use here 0xfa7 (higher value). But maybe
> > explaining why?
> The good reason is that I like puns. sqe_ptr->user_data is not processed
> by the kernel in any way except for copying the value into the
> completion queue when the I/O request finishes. And we don't care
> whether we can tell apart the spam request results from one another so
> giving them all the same marker is good enough.
Thanks for an explanation!
> >> + uring.sqr_array[tail & *uring.sqr_mask] = i;
> >> + count = ++i;
> >> + tail++;
> >> +
> >> + __atomic_store(uring.sqr_tail, &tail, __ATOMIC_RELEASE);
> >> + SAFE_IO_URING_ENTER(1, uring.fd, count, count, IORING_ENTER_GETEVENTS,
> >> + NULL);
> >> +
> >> + /* Check test results */
> >> + __atomic_load(uring.cqr_tail, &tail, __ATOMIC_ACQUIRE);
> >> +
> >> + for (i = *uring.cqr_head; i != tail; i++, count--) {
> >> + cqe_ptr = uring.cqr_entries + (i & *uring.cqr_mask);
> >> + TST_ERR = -cqe_ptr->res;
> >> +
> >> + if (cqe_ptr->user_data == SPAM_MARK) {
> >> + if (cqe_ptr->res >= 0 || cqe_ptr->res == -EAGAIN)
> >> + continue;
> >> +
> >> + tst_res(TFAIL | TTERRNO,
> >> + "Spam request failed unexpectedly");
> > I'm sorry, I'm lost to which TEST*() call this TTERRNO refers (there are mostly
> > SAFE_*() macros.
> I'm setting TST_ERR manually 6 lines above the tst_res() call. The errno
> value is in cqe_ptr->res.
Thank you, I'm blind :).
Anyway, merged. Thanks for your work!
BTW: test fails on my openSUSE kernel 5.11.0-rc6, which should have both kernel
fixes.
Kind regards,
Petr
next prev parent reply other threads:[~2021-02-08 9:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-04 11:03 [LTP] [PATCH v2 1/4] Prevent linker issues in lapi/io_uring.h Martin Doucha
2021-02-04 11:03 ` [LTP] [PATCH v2 2/4] Add safe functions for io_uring to LTP library Martin Doucha
2021-02-05 15:56 ` Petr Vorel
2021-02-05 16:03 ` Martin Doucha
2021-02-05 17:06 ` Petr Vorel
2021-02-04 11:03 ` [LTP] [PATCH v2 3/4] Add CAP_SYS_CHROOT to lapi/capability.h Martin Doucha
2021-02-04 11:03 ` [LTP] [PATCH v2 4/4] Add test for CVE 2020-29373 Martin Doucha
2021-02-05 16:49 ` Petr Vorel
2021-02-08 9:37 ` Martin Doucha
2021-02-08 9:48 ` Petr Vorel [this message]
2021-02-05 16:09 ` [LTP] [PATCH v2 1/4] Prevent linker issues in lapi/io_uring.h Petr Vorel
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=YCEI39Xxo80VkIE9@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
/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