From: Eli Cohen <eli-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
To: Yann Droneaud <ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
Cc: roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
Eli Cohen <eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH for-next 09/14] IB/mlx5: Add support for resize CQ
Date: Wed, 15 Jan 2014 09:33:16 +0200 [thread overview]
Message-ID: <20140115073316.GB31664@mtldesk30> (raw)
In-Reply-To: <1389717410.1585.67.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
On Tue, Jan 14, 2014 at 05:36:50PM +0100, Yann Droneaud wrote:
> > + if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd)))
> > + return -EFAULT;
> > +
>
> You might also write
>
> err = ib_copy_from_udata(&ucmd, udata, sizeof(ucmd));
> if (err)
> return err;
>
> Then you should check reserved fields being set to the default value:
> As noted by Daniel Vetter in its article "Botching up ioctls"[1]
> "Check *all* unused fields and flags and all the padding for whether
> it's 0, and reject the ioctl if that's not the case. Otherwise your
> nice plan for future extensions is going right down the gutters
> since someone *will* submit an ioctl struct with random stack
> garbage in the yet unused parts. Which then bakes in the ABI that
> those fields can never be used for anything else but garbage."
> It's important to ensure that reserved fields are set to known value,
> so that it will be possible to use them latter to extend the ABI.
>
> [1] http://blog.ffwll.ch/2013/11/botching-up-ioctls.html
>
> if (ucmd.reserved0 || ucmd.reserved1)
> return -EINVAL;
>
It is not likely that someone will pass non-zero values here since
libmlx5 clears and most apps will use it. But I agree with your
comment - thanks for pointing this out. Probably there are other
places that need to be checked.
> > + }
> > + mutex_unlock(&cq->resize_mutex);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Is everything in this section really critical.
> For example, allocating and setting 'in' structure or releasing the
> ressources could probably move outside the mutex protected section ?
>
Well, you could move things around to shorten the overall time the
lock is held but that might require structural changes in the code
that will not necessairily fit nice. Resizing a CQ is not a frequent
operation and this lock is used to avoid concurrent attempts of
resizing of the same CQ so I would not invest more effort here.
> >
> >
> > int mlx5_core_modify_cq(struct mlx5_core_dev *dev, struct mlx5_core_cq *cq,
> > - struct mlx5_modify_cq_mbox_in *in)
> > + struct mlx5_modify_cq_mbox_in *in, int in_sz)
> ^^^^^^^^^^
>
> Should probably be 'unsigned' ? size_t ?
>
> same here.
>
The resized value is defined int at the ib core layer so I chose to
follow the same type to avoid need for casting. Maybe a future patch
could change the type all over.
> diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
> > index dbb03ca..87e2371 100644
> > --- a/include/linux/mlx5/device.h
> > +++ b/include/linux/mlx5/device.h
> > @@ -710,6 +711,7 @@ struct mlx5_modify_cq_mbox_in {
> >
> > struct mlx5_modify_cq_mbox_out {
> > struct mlx5_outbox_hdr hdr;
> > + u8 rsvd[8];
> > };
> >
> > struct mlx5_enable_hca_mbox_in {
> >
>
> It not clear why 8 bytes are needed here ?
>
This is a requirement of the driver/firmware interface.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-01-15 7:33 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-14 15:45 [PATCH for-next 00/14] Patch set for 3.14 Eli Cohen
[not found] ` <1389714323-20130-1-git-send-email-eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-01-14 15:45 ` [PATCH for-next 01/14] IB/mlx5: Remove unused coded in mr.c Eli Cohen
2014-01-14 15:45 ` [PATCH for-next 02/14] mlx5_core: Remove dead code Eli Cohen
2014-01-14 15:45 ` [PATCH for-next 03/14] IB/mlx5: Fix micro UAR allocator Eli Cohen
2014-01-14 15:45 ` [PATCH for-next 04/14] net/mlx5_core: Fix out arg size in access_register command Eli Cohen
2014-01-14 15:45 ` [PATCH for-next 05/14] IB/mlx5: Clear out struct before create QP command Eli Cohen
2014-01-14 15:45 ` [PATCH for-next 06/14] net/mlx5_core: Use mlx5 core style warning Eli Cohen
2014-01-14 15:45 ` [PATCH for-next 07/14] IB/mlx5: Make sure doorbell record is visible before doorbell Eli Cohen
[not found] ` <1389714323-20130-8-git-send-email-eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-01-14 16:36 ` Yann Droneaud
[not found] ` <1389717393.1585.66.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2014-01-15 6:47 ` Eli Cohen
2014-01-15 10:19 ` Yann Droneaud
2014-01-14 15:45 ` [PATCH for-next 08/14] IB/mlx5: Implement modify CQ Eli Cohen
2014-01-14 15:45 ` [PATCH for-next 09/14] IB/mlx5: Add support for resize CQ Eli Cohen
[not found] ` <1389714323-20130-10-git-send-email-eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-01-14 16:36 ` Yann Droneaud
[not found] ` <1389717410.1585.67.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2014-01-15 7:33 ` Eli Cohen [this message]
2014-01-15 10:02 ` Yann Droneaud
[not found] ` <1389780175.572.10.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2014-01-15 11:24 ` Eli Cohen
2014-01-16 9:58 ` Yann Droneaud
2014-01-14 15:45 ` [PATCH for-next 10/14] net/mlx5_core: Improve debugfs readability Eli Cohen
2014-01-14 15:45 ` [PATCH for-next 11/14] mlx5_core: Fix PowerPC support Eli Cohen
2014-01-14 15:45 ` [PATCH for-next 12/14] IB/mlx5: Allow creation of QPs with zero length work queues Eli Cohen
2014-01-14 15:45 ` [PATCH for-next 13/14] IB/mlx5: Abort driver cleanup if teardown hca fails Eli Cohen
2014-01-14 15:45 ` [PATCH for-next 14/14] IB/mlx5: Remove old field for create mkey mailbox Eli Cohen
[not found] ` <1389714323-20130-15-git-send-email-eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-01-14 16:37 ` Yann Droneaud
[not found] ` <1389717437.1585.68.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2014-01-15 7:38 ` Eli Cohen
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=20140115073316.GB31664@mtldesk30 \
--to=eli-ldsdmyg8hgv8yrgs2mwiifqbs+8scbdb@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.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