Message ID | 1447086657-15358-3-git-send-email-matanb@mellanox.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
On Mon, Nov 09, 2015 at 06:30:55PM +0200, Matan Barak wrote: > Extending core and vendor verb commands require us to check that the > unknown part of the user's given command is all zeros. > Adding ib_is_udata_cleared in order to do so. > > Signed-off-by: Matan Barak <matanb@mellanox.com> Acked-by: Eli Cohen <eli@mellanox.com> -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, Nov 09, 2015 at 06:30:55PM +0200, Matan Barak wrote: > > +static inline bool ib_is_udata_cleared(struct ib_udata *udata, > + char cleared_char, > + size_t offset, > + size_t len) > +{ > + short i; > + > + for (i = 0; i < len; i++) { You are comparing "len" which is declared as size_t which is "unsigned" int and "i" which is "short". -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, Nov 9, 2015 at 9:18 PM, Leon Romanovsky <leon@leon.nu> wrote: > On Mon, Nov 09, 2015 at 06:30:55PM +0200, Matan Barak wrote: >> >> +static inline bool ib_is_udata_cleared(struct ib_udata *udata, >> + char cleared_char, >> + size_t offset, >> + size_t len) >> +{ >> + short i; >> + >> + for (i = 0; i < len; i++) { > You are comparing "len" which is declared as size_t which is "unsigned" int and "i" which is "short". Thanks, I'll change i to be unsigned. > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index e4cc389..43f3cf2 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1855,6 +1855,26 @@ static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0; } +static inline bool ib_is_udata_cleared(struct ib_udata *udata, + char cleared_char, + size_t offset, + size_t len) +{ + short i; + + for (i = 0; i < len; i++) { + char c; + + if (copy_from_user(&c, udata->inbuf + offset + i, sizeof(c))) + return false; + + if (c != cleared_char) + return false; + } + + return true; +} + /** * ib_modify_qp_is_ok - Check that the supplied attribute mask * contains all required attributes and no attributes not allowed for
Extending core and vendor verb commands require us to check that the unknown part of the user's given command is all zeros. Adding ib_is_udata_cleared in order to do so. Signed-off-by: Matan Barak <matanb@mellanox.com> --- include/rdma/ib_verbs.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)