Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp640398pxu; Wed, 7 Oct 2020 11:52:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1ysm7TOP+nmm45jT5j/0b+AVaj6IIEvo14SXpiZbLWV3vxQ02lRBKd61zeoMZA9uiUM0T X-Received: by 2002:a17:906:5509:: with SMTP id r9mr4995783ejp.12.1602096737499; Wed, 07 Oct 2020 11:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602096737; cv=none; d=google.com; s=arc-20160816; b=fazCwMwBJEGa8DX0sekHmgb5b2cmIrKv6ZTIeJzKrtMiGejqsTOaHliJAYBObryYCg mQg6pkRXDb5O+mayKLAjc2cTSdmu6iBZii7ng0L1yZYsMpCwPFdp6R94SN2VUCGLBaiU hK19dZW/cvUuJ3/pNupNtLcpEj0OWB7nZdxELeKPXArpgfiv9WpYjFb1rZuoPSNf1Qy6 cV8JOEQIyOueIPJb5jaAOiCPXxaUKkI3KYOz+3vhHz3RNzgW/s11jC7GJ2INjBQ9KN7B wTxAhfySwsUyqczj+VdC57HbXY53ITpd6InbyM2nKH7isGe95c+vQw7YMpGZQG7Ot4Jw YJNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Fd9c7NnGlZlQsPoX32Y7E0H7T+E2rrcfUhUeaY9NVV4=; b=xz+0C1qdMNlquk+pRA1ZQxedU5juo5wn4DeDSILZlNnCff8FpCZEqKqnfmTjXXZPeU SXaHpopns3vRTVmoeeN7tvy2C9Ev6xGIMTHHgW9q7aa+/3QU8LHSohU/6/8wwFuYNxkD bc/X0iu6A3sjWeKoLz2cQWDe+irMj1Mrh6b2BYzq5Dhw2q+invxZQm4y4w0OkcsDJdfe NP0nOfExlGCU0K76sWBCZVSyFHAodJw0UH7xuQW9uVHovSwawSi3UGoO/Xl4eJuHGGlN crv7Xy9XgFtvFrPDCgRxNk9q0PNXZ8fqH7Fhfvhognp8koN8Q+A8JarUFb746ce33pE/ h0tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ZTQCinhx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n18si1916277edo.610.2020.10.07.11.51.54; Wed, 07 Oct 2020 11:52:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ZTQCinhx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728253AbgJGSrf (ORCPT + 99 others); Wed, 7 Oct 2020 14:47:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728119AbgJGSre (ORCPT ); Wed, 7 Oct 2020 14:47:34 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86D2CC061755; Wed, 7 Oct 2020 11:47:34 -0700 (PDT) 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=Fd9c7NnGlZlQsPoX32Y7E0H7T+E2rrcfUhUeaY9NVV4=; b=ZTQCinhxmjer2B4rWKjYH5Zt45 jkp9CrbpI7giGfDFPrQO8yS1DANnlbqytLhjgJ6zCKxt4PPjzryYAjRdzaIjwIqteaaegdVmBd3rh 7l2GniIcTZNK7ZOgUdn8kgeSejFLP89v0sDQhBWa0B+LyRp8CYVQzwzreuLIG8oa5X+HzvwVn+qaD NwkEw5W7uMFUQTWmuuNHkHtJjIyJWCRIET5Rf5PfhTb4wBbqN/64JntPZtIkBQ7TPsh4vfIUgqVsx 7qdChRAM994JJ0YjxFO5EKOdi3LaeniRItdUqu9KH5Q0BRuHkEErw5JKLkv9RZ67yFfYET6J96ebw oesKFOSQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQETK-0004O9-Q8; Wed, 07 Oct 2020 18:47:30 +0000 Date: Wed, 7 Oct 2020 19:47:30 +0100 From: Matthew Wilcox To: Christoph Hellwig Cc: linux-fsdevel@vger.kernel.org, ericvh@gmail.com, lucho@ionkov.net, viro@zeniv.linux.org.uk, jlayton@kernel.org, idryomov@gmail.com, mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, ocfs2-devel@oss.oracle.com, linux-btrfs@vger.kernel.org, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, stable@vger.kernel.org Subject: Re: [PATCH 1/7] 9P: Cast to loff_t before multiplying Message-ID: <20201007184730.GW20115@casper.infradead.org> References: <20201004180428.14494-1-willy@infradead.org> <20201004180428.14494-2-willy@infradead.org> <20201007054849.GA16556@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201007054849.GA16556@infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 07, 2020 at 06:48:49AM +0100, Christoph Hellwig wrote: > > - .range_start = vma->vm_pgoff * PAGE_SIZE, > > + .range_start = (loff_t)vma->vm_pgoff * PAGE_SIZE, > > Given the may places where this issue shows up I think we really need > a vma_offset or similar helper for it. Much better than chasing missing > casts everywhere. Good point. I think these patches need to go in to fix the bugs in the various stable releases, but we should definitely have a helper for the future. Also, several of these patches are for non-VMA pgoff_t. vma_offset() is a bit weird for me -- vmas have all kinds of offsets. vma_file_offset() would work or vma_fpos(). I tend to prefer the shorter function name ;-) A quick grep shows we probably want a vmf_fpos() too: arch/powerpc/platforms/cell/spufs/file.c: unsigned long area, offset = vmf->pgoff << PAGE_SHIFT; arch/x86/entry/vdso/vma.c: sym_offset = (long)(vmf->pgoff << PAGE_SHIFT) + drivers/gpu/drm/gma500/framebuffer.c: address = vmf->address - (vmf->pgoff << PAGE_SHIFT); drivers/scsi/cxlflash/ocxl_hw.c: offset = vmf->pgoff << PAGE_SHIFT; I'm sure a lot of this will never run on a 32-bit kernel or with a 4GB file, but it's not good to have bad code around for people to copy from.