From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 2/4] Add safe functions for io_uring to LTP library
Date: Fri, 5 Feb 2021 16:56:58 +0100 [thread overview]
Message-ID: <YB1qyucNa+aN3p2V@pevik> (raw)
In-Reply-To: <20210204110342.11821-2-mdoucha@suse.cz>
Hi Martin,
Reviewed-by: Petr Vorel <pvorel@suse.cz>
> +++ b/include/tst_safe_io_uring.h
> @@ -0,0 +1,63 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (c) Linux Test Project, 2021
> + */
> +
> +#ifndef TST_IO_URING_H__
> +#define TST_IO_URING_H__
> +
> +#include "config.h"
> +#include "lapi/io_uring.h"
> +
> +struct tst_io_uring {
> + int fd;
> + void *sqr_base, *cqr_base;
> + /* buffer sizes in bytes for unmapping */
> + size_t sqr_mapsize, cqr_mapsize;
> +
> + /* Number of entries in the ring buffers */
> + uint32_t sqr_size, cqr_size;
> +
> + /* Submission queue pointers */
> + struct io_uring_sqe *sqr_entries;
> + const uint32_t *sqr_head, *sqr_mask, *sqr_flags, *sqr_dropped;
> + uint32_t *sqr_tail, *sqr_array;
> +
> + /* Completion queue pointers */
> + const struct io_uring_cqe *cqr_entries;
> + const uint32_t *cqr_tail, *cqr_mask, *cqr_overflow;
> + uint32_t *cqr_head;
> +
nit: blank line.
> +};
...
> +++ b/lib/tst_safe_io_uring.c
...
> + uring->sqr_base = safe_mmap(file, lineno, NULL, uring->sqr_mapsize,
> + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, uring->fd,
> + IORING_OFF_SQ_RING);
> +
> + if (uring->sqr_base == MAP_FAILED)
> + return -1;
IMHO this is not needed, safe_mmap() breaks on rval == MAP_FAILED.
> +
> + uring->sqr_entries = safe_mmap(file, lineno, NULL,
> + params->sq_entries * sizeof(struct io_uring_sqe),
> + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, uring->fd,
> + IORING_OFF_SQES);
> +
> + if (uring->sqr_entries == MAP_FAILED)
> + return -1;
And here.
> +
> + uring->cqr_base = safe_mmap(file, lineno, NULL, uring->cqr_mapsize,
> + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, uring->fd,
> + IORING_OFF_CQ_RING);
> +
> + if (uring->cqr_base == MAP_FAILED)
> + return -1;
And here.
No need to repost, these two can be removed before merge.
The rest LGTM.
Kind regards,
Petr
next prev parent reply other threads:[~2021-02-05 15:56 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 [this message]
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
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=YB1qyucNa+aN3p2V@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 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.