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=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 A320CC4338F for ; Fri, 30 Jul 2021 11:32:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6516660EFE for ; Fri, 30 Jul 2021 11:32:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6516660EFE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 0DF926B005D; Fri, 30 Jul 2021 07:32:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08DC36B006C; Fri, 30 Jul 2021 07:32:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE63E8D0001; Fri, 30 Jul 2021 07:32:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0117.hostedemail.com [216.40.44.117]) by kanga.kvack.org (Postfix) with ESMTP id D5B866B005D for ; Fri, 30 Jul 2021 07:32:28 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 85438250DC for ; Fri, 30 Jul 2021 11:32:28 +0000 (UTC) X-FDA: 78419041176.23.8A3A6A5 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id D3DF3801AF12 for ; Fri, 30 Jul 2021 11:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Fo7rG3IzaemGxikK31d//HrXgUCmOJhD7lTTEDkw0IA=; b=bGSJapEagljg+1XZOrtOSz7ujo i1ToiEcM2ScPF+MFaPRR3HeZ3IW/dy37Pa4Jj0j6ltEQ79bjibz3auCk22w6xuSZ7LAtAT3YNCRVQ rnF9Agn5YR1lETsDj+3CGjQRGtz2j9MFIqFb8xgknSIni5IWvBksFDy1aE/QstfGd2VNx7zhFKv9R UgeH7Dm5quuqg/LwJPeMInWQfDZRBNmQ9A7vPyT1Q4v0q18aOMhBoJNIxXmYEeMN3rLreXS2P+dBz SY+ClNpVao3fQDL4XfZ/slOJ/Vvzg9NTiumO1w8iBGXU2DCe386ppKyzGQ2ovoFwoaMuuL5MxrNVq fu62aszQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m9QjB-000eGm-VR; Fri, 30 Jul 2021 11:31:26 +0000 Date: Fri, 30 Jul 2021 12:30:57 +0100 From: Matthew Wilcox To: Ming Lei Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org Subject: Re: [PATCH v15 01/17] block: Add bio_add_folio() Message-ID: References: <20210719184001.1750630-1-willy@infradead.org> <20210719184001.1750630-2-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D3DF3801AF12 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bGSJapEa; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Stat-Signature: 4mi7qf58djiimy8xe3x81eoy1s6kd8a8 X-HE-Tag: 1627644747-344322 X-Bogosity: Ham, tests=bogofilter, spamicity=0.002207, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jul 30, 2021 at 04:25:17PM +0800, Ming Lei wrote: > > +size_t bio_add_folio(struct bio *bio, struct folio *folio, size_t len, > > + size_t off) > > +{ > > + if (len > UINT_MAX || off > UINT_MAX) > > + return 0; > > The added page shouldn't cross 4G boundary, so just wondering why not > check 'if (len > UINT_MAX - off)'? That check is going to be vulnerable to wrapping, eg off = 2^32, len = 512 It would be less vulnerable to wrapping if we cast both sides to signed long. But at that point, we're firmly into obscuring the intent of the check.