From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2166C48BCF for ; Wed, 9 Jun 2021 18:06:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F7D161359 for ; Wed, 9 Jun 2021 18:06:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232014AbhFISId (ORCPT ); Wed, 9 Jun 2021 14:08:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbhFISIc (ORCPT ); Wed, 9 Jun 2021 14:08:32 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9F70C061574; Wed, 9 Jun 2021 11:06:37 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lr2au-006Jht-FM; Wed, 09 Jun 2021 18:06:24 +0000 Date: Wed, 9 Jun 2021 18:06:24 +0000 From: Al Viro To: Qian Cai Cc: Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, David Sterba , Miklos Szeredi , Anton Altaparmakov , David Howells , Matthew Wilcox , Pavel Begunkov Subject: Re: [RFC PATCH 16/37] iov_iter_gap_alignment(): get rid of iterate_all_kinds() Message-ID: References: <20210606191051.1216821-1-viro@zeniv.linux.org.uk> <20210606191051.1216821-16-viro@zeniv.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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...