From: Yann Droneaud <ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>
To: Or Gerlitz <gerlitz.or-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Matan Barak <matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH for-next 1/2] IB/uverbs: Add QP creation flags, allow blocking UD multicast loopback
Date: Thu, 18 Sep 2014 09:25:51 +0200 [thread overview]
Message-ID: <1411025151.7830.48.camel@localhost.localdomain> (raw)
In-Reply-To: <CAJ3xEMidZpzXaD=ttc5qAWZfX4DPRZxwK9YK6pPPjyDLjFMM7g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Hi,
Le lundi 15 septembre 2014 à 20:36 +0300, Or Gerlitz a écrit :
> On Mon, Sep 15, 2014 at 7:52 PM, Yann Droneaud <ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org> wrote:
> >> --- a/include/uapi/rdma/ib_user_verbs.h
> >> +++ b/include/uapi/rdma/ib_user_verbs.h
> >> @@ -470,7 +470,7 @@ struct ib_uverbs_create_qp {
> >> __u8 sq_sig_all;
> >> __u8 qp_type;
> >> __u8 is_srq;
> >> - __u8 reserved;
> >> + __u8 create_flags;
> >> __u64 driver_data[0];
> >> };
> >>
> >
> > I'm not really happy with the way "reserved" field is used by this
> > patch: as the field wasn't check for being set to 0, any value could be
> > given by userspace (imagine the structure lay on stack). Using it now
> > could be dangerous. It must be double checked.
>
> We are only allowing user space applications to program certain
> aspects in the behavior
> of their own QPs, no risk to the system/kernel state.
>
I've checked the implementation on the most common userspace code
accessing the uverbs API, libibverbs, and found the "reserved" field is
explicitely cleared in:
ibv_cmd_create_qp_ex():
c7e3e61052dd7 (Sean Hefty 2013-08-01 18:04:16 +0300 651) cmd->reserved = 0;
ibv_cmd_create_qp():
0e0604213ed79 (Roland Dreier 2006-10-04 23:57:10 +0000 726) cmd->reserved = 0;
Latter commit is part of libibverbs-1.1-rc1, so before libibverbs-1.1,
reserved field was not cleared.
For example, mlx4_create_qp() allocate the ibv_create_qp structure on
stack and doesn't clear reserved field:
^d049a1279b82 (Roland Dreier 2007-04-09 00:49:42 -0700 358) struct mlx4_create_qp cmd;
So existing userspace program using libibverbs < 1.1 is likely to break
with newer kernel if reserved field is going to be used.
> We've done it very successfully in the past with adding the link_layer field
> to struct ib_uverbs_query_port_resp as part of the RoCE story instead of a
> reserved field.
>
ib_uverbs_query_port_resp is the opposite side: the kernel is adding stuff
where older userspace code don't expect to found anything, so this extra
information is skipped by such pre-existing program.
Using an unused field in the request has more chance to break than using
an extra field in the response.
Again:
"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."
As the "reserved" field was never check for being 0 in kernel side,
ensuring it could be used in the future for other purpose, we're in
a situation where "reserved" field is garbage when using older
libibverbs or other userspace software that can address uverbs
by-passing libibverbs.
That's likely to break existing userspace application.
Regards.
--
Yann Droneaud
OPTEYA
--
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-09-18 7:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-14 13:20 [PATCH for-next 0/2] Add creation flags for user space QPs Or Gerlitz
[not found] ` <1410700802-27848-1-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-09-14 13:20 ` [PATCH for-next 1/2] IB/uverbs: Add QP creation flags, allow blocking UD multicast loopback Or Gerlitz
[not found] ` <1410700802-27848-2-git-send-email-ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-09-15 16:52 ` Yann Droneaud
[not found] ` <1410799972.7830.25.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2014-09-15 17:36 ` Or Gerlitz
[not found] ` <CAJ3xEMidZpzXaD=ttc5qAWZfX4DPRZxwK9YK6pPPjyDLjFMM7g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-18 7:25 ` Yann Droneaud [this message]
[not found] ` <1411025151.7830.48.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2014-09-18 13:03 ` Or Gerlitz
2014-09-18 12:51 ` Or Gerlitz
[not found] ` <541AD55A.50102-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-09-19 8:23 ` Yann Droneaud
2014-09-14 13:20 ` [PATCH for-next 2/2] IB/mlx4: Enable blocking multicast loopback for user-space consumers Or Gerlitz
2014-09-16 14:04 ` [PATCH for-next 0/2] Add creation flags for user space QPs Christoph Lameter
[not found] ` <alpine.DEB.2.11.1409160903430.26070-gkYfJU5Cukgdnm+yROfE0A@public.gmane.org>
2014-09-16 20:07 ` Or Gerlitz
[not found] ` <CAJ3xEMgnym=kLbzx2oa+o+ZwKvf+dOQ4JawyO4_-T8YFHtiRyw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-16 20:55 ` Christoph Lameter
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=1411025151.7830.48.camel@localhost.localdomain \
--to=ydroneaud-rly5vtjfyj3qt0dzr+alfa@public.gmane.org \
--cc=cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org \
--cc=gerlitz.or-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=roland-DgEjT+Ai2ygdnm+yROfE0A@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