Re: [RFC PATCH 16/37] iov_iter_gap_alignment(): get rid of iterate_all_kinds()

From: Al Viro
Date: Wed Jun 09 2021 - 14:06:40 EST


On Wed, Jun 09, 2021 at 09:01:36AM -0400, Qian Cai wrote:

> On 6/6/2021 3:10 PM, Al Viro wrote:
> > For one thing, it's only used for iovec (and makes sense only for those).
^^^^^^^^^^^^^^^^^^^

[snip]

> > - if (unlikely(iov_iter_is_pipe(i) || iov_iter_is_discard(i))) {
> > + if (unlikely(iter_is_iovec(i))) {
^^^^^^^^^^^^^^^^
This. A nice demonstration of braino repeatedly overlooked on read-through,
especially when the change described in commit message is obvious and
looks similar to the change done in the patch.

Happens without any deliberate attacks involved - as the matter of fact,
it's easier to spot that kind of crap in somebody else's patch...

Anyway, the obvious fix (
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 3a68f578695f..6569e3f5d01d 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1402,10 +1402,8 @@ unsigned long iov_iter_gap_alignment(const struct iov_iter *i)
size_t size = i->count;
unsigned k;

- if (unlikely(iter_is_iovec(i))) {
- WARN_ON(1);
+ if (WARN_ON(!iter_is_iovec(i)))
return ~0U;
- }

for (k = 0; k < i->nr_segs; k++) {
if (i->iov[k].iov_len) {
) folded in and pushed...