From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@mellanox.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Doug Ledford <dledford@redhat.com>,
Kees Cook <keescook@chromium.org>,
RDMA mailing list <linux-rdma@vger.kernel.org>,
Hadar Hen Zion <hadarh@mellanox.com>,
Matan Barak <matanb@mellanox.com>,
Michael J Ruhl <michael.j.ruhl@intel.com>,
Noa Osherovich <noaos@mellanox.com>,
Raed Salem <raeds@mellanox.com>,
Yishai Hadas <yishaih@mellanox.com>,
Saeed Mahameed <saeedm@mellanox.com>,
linux-netdev <netdev@vger.kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH rdma-next 08/12] overflow.h: Add arithmetic shift helper
Date: Tue, 26 Jun 2018 07:16:34 +0300 [thread overview]
Message-ID: <20180626041634.GL17747@mtr-leonro.mtl.com> (raw)
In-Reply-To: <20180625171157.GE5356@mellanox.com>
[-- Attachment #1: Type: text/plain, Size: 1413 bytes --]
On Mon, Jun 25, 2018 at 11:11:57AM -0600, Jason Gunthorpe wrote:
> On Mon, Jun 25, 2018 at 11:26:05AM +0200, Rasmus Villemoes wrote:
>
> > check_shift_overflow(a, s, d) {
> > unsigned _nbits = 8*sizeof(a);
> > typeof(a) _a = (a);
> > typeof(s) _s = (s);
> > typeof(d) _d = (d);
> >
> > *_d = ((u64)(_a) << (_s & (_nbits-1)));
> > _s >= _nbits || (_s > 0 && (_a >> (_nbits - _s -
> > is_signed_type(a))) != 0);
> > }
>
> Those types are not quite right.. What about this?
>
> check_shift_overflow(a, s, d) ({
> unsigned int _nbits = 8*sizeof(d) - is_signed_type(d);
> typeof(d) _a = a; // Shift is always performed on type 'd'
> typeof(s) _s = s;
> typeof(d) _d = d;
>
> *_d = (_a << (_s & (_nbits-1)));
>
> (((*_d) >> (_s & (_nbits-1)) != _a);
> })
>
> And can we use mathamatcial invertability to prove no overlow and
> bound _a ? As above.
Rasmus and Jason,
Thanks for the feedback.
The reason why I introduced function, because wanted to reuse
check_mul_overflow macro, but for any reasons which I don't remember
now, I had hard time to fix compilation errors.
Anyway, I'll resubmit.
Thanks
>
> Jason
> --
> 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
next prev parent reply other threads:[~2018-06-26 4:16 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-24 8:23 [PATCH rdma-next 00/12] RDMA fixes 2018-06-24 Leon Romanovsky
2018-06-24 8:23 ` [PATCH rdma-next 01/12] RDMA/uverbs: Protect from attempts to create flows on unsupported QP Leon Romanovsky
2018-06-25 21:14 ` Jason Gunthorpe
2018-06-24 8:23 ` [PATCH rdma-next 02/12] RDMA/uverbs: Check existence of create_flow callback Leon Romanovsky
2018-06-24 8:23 ` [PATCH rdma-next 03/12] RDMA/verbs: Drop kernel variant of create_flow Leon Romanovsky
2018-06-24 8:23 ` [PATCH rdma-next 04/12] RDMA/verbs: Drop kernel variant of destroy_flow Leon Romanovsky
2018-06-24 8:23 ` [PATCH mlx5-next 05/12] net/mlx5: Rate limit errors in command interface Leon Romanovsky
2018-06-27 5:48 ` Leon Romanovsky
2018-06-24 8:23 ` [PATCH rdma-next 06/12] RDMA/uverbs: Don't overwrite NULL pointer with ZERO_SIZE_PTR Leon Romanovsky
2018-06-24 19:57 ` Jason Gunthorpe
2018-06-25 8:08 ` Leon Romanovsky
2018-06-24 8:23 ` [PATCH rdma-next 07/12] RDMA/umem: Don't check for negative return value of dma_map_sg_attrs() Leon Romanovsky
2018-06-24 8:23 ` [PATCH rdma-next 08/12] overflow.h: Add arithmetic shift helper Leon Romanovsky
[not found] ` <CAKwiHFhgsyWYD+q+JFb2HJEphnjiiOp=o4Airv3MW031q2jx8w@mail.gmail.com>
2018-06-25 17:11 ` Jason Gunthorpe
2018-06-26 4:16 ` Leon Romanovsky [this message]
[not found] ` <CAKwiHFiRYbyiJqDYCgKXKZYRr0KjCt8q9AwKwfqoCA1sT2KFyQ@mail.gmail.com>
2018-06-26 11:37 ` Leon Romanovsky
2018-06-26 17:54 ` Jason Gunthorpe
[not found] ` <CAKwiHFgchr+6HYOZ4e4e1vzL9cFabe6eonNNM8NTWZypazcuKA@mail.gmail.com>
2018-06-27 17:39 ` Leon Romanovsky
2018-06-27 18:10 ` Jason Gunthorpe
2018-06-27 18:22 ` Leon Romanovsky
2018-06-27 21:35 ` Rasmus Villemoes
2018-06-27 18:44 ` Kees Cook
2018-08-01 9:36 ` Peter Zijlstra
2018-08-01 16:14 ` Jason Gunthorpe
2018-06-26 4:24 ` Leon Romanovsky
2018-06-24 8:23 ` [PATCH rdma-next 09/12] RDMA/mlx5: Fix shift overflow in mlx5_ib_create_wq Leon Romanovsky
2018-06-24 19:56 ` Jason Gunthorpe
2018-06-25 8:10 ` Leon Romanovsky
2018-06-25 14:58 ` Jason Gunthorpe
2018-06-24 8:23 ` [PATCH rdma-next 10/12] RDMA/mlx5: Reuse existed shift_overlow helper Leon Romanovsky
2018-06-24 8:23 ` [PATCH rdma-next 11/12] RDMA/uverbs: Remove redundant check Leon Romanovsky
2018-06-24 8:23 ` [PATCH rdma-next 12/12] RDMA/uverbs: Fix slab-out-of-bounds in ib_uverbs_ex_create_flow Leon Romanovsky
2018-06-25 21:34 ` [PATCH rdma-next 00/12] RDMA fixes 2018-06-24 Jason Gunthorpe
2018-06-26 4:21 ` Leon Romanovsky
2018-06-26 20:39 ` Jason Gunthorpe
2018-06-27 5:47 ` Leon Romanovsky
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=20180626041634.GL17747@mtr-leonro.mtl.com \
--to=leon@kernel.org \
--cc=dledford@redhat.com \
--cc=hadarh@mellanox.com \
--cc=jgg@mellanox.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=matanb@mellanox.com \
--cc=michael.j.ruhl@intel.com \
--cc=netdev@vger.kernel.org \
--cc=noaos@mellanox.com \
--cc=raeds@mellanox.com \
--cc=saeedm@mellanox.com \
--cc=yishaih@mellanox.com \
/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.