public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Govindarajulu Varadarajan <govind.varadar@gmail.com>
Cc: io-uring@vger.kernel.org, axboe@kernel.dk, ming.lei@redhat.com,
	kbusch@kernel.org, hch@lst.de, sagi@grimberg.me,
	miklos@szeredi.hu
Subject: Re: [PATCH 1/2] io_uring: Add size check for sqe->cmd
Date: Fri, 30 Jan 2026 06:11:25 +0100	[thread overview]
Message-ID: <20260130051125.GB32492@lst.de> (raw)
In-Reply-To: <20260129201347.411015-2-govind.varadar@gmail.com>

On Thu, Jan 29, 2026 at 12:13:46PM -0800, Govindarajulu Varadarajan wrote:
> -	const struct ublksrv_io_cmd *ub_src = io_uring_sqe_cmd(cmd->sqe);
> +	const struct ublksrv_io_cmd *ub_src = IO_URING_SQE_CMD(cmd->sqe, struct ublksrv_io_cmd);

As Jens already said, no need for the shouting.  Also please break the
lines to keep things readable.

> -static inline const void *io_uring_sqe_cmd(const struct io_uring_sqe *sqe)
> -{
> -	return sqe->cmd;
> -}
> +#define IO_URING_SQE128_CMD(sqe, type)	({						\
> +	BUILD_BUG_ON(sizeof(type) > ((2 * sizeof(struct io_uring_sqe)) -		\
> +				     offsetof(struct io_uring_sqe, cmd)));		\
> +	(type *)(sqe)->cmd;								\
> +})
> +
> +#define IO_URING_SQE_CMD(sqe, type)	({						\
> +	BUILD_BUG_ON(sizeof(type) > ((sizeof(struct io_uring_sqe)) -			\
> +				     offsetof(struct io_uring_sqe, cmd)));		\
> +	(type *)(sqe)->cmd;								\
> +})

I'm also not sure adding a BUILD_BUG_ON to every derefence is great for
compile times.  But I'm not really sure what would be a good other
place for it.


  parent reply	other threads:[~2026-01-30  5:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-29 20:13 [PATCH 0/2] io_uring: Add macro to validate SQE cmd size Govindarajulu Varadarajan
2026-01-29 20:13 ` [PATCH 1/2] io_uring: Add size check for sqe->cmd Govindarajulu Varadarajan
2026-01-29 20:19   ` Jens Axboe
2026-01-29 20:48   ` Caleb Sander Mateos
2026-01-30  5:11   ` Christoph Hellwig [this message]
2026-01-29 20:13 ` [PATCH 2/2] block/ublk_drv: Validate SQE128 flag before accessing the cmd Govindarajulu Varadarajan

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=20260130051125.GB32492@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=govind.varadar@gmail.com \
    --cc=io-uring@vger.kernel.org \
    --cc=kbusch@kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=ming.lei@redhat.com \
    --cc=sagi@grimberg.me \
    /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