Message ID | 163967172373.1823006.6118195970180365070.stgit@warthog.procyon.org.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-cifs-owner@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACBF0C4332F for <linux-cifs@archiver.kernel.org>; Thu, 16 Dec 2021 16:22:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239566AbhLPQWa (ORCPT <rfc822;linux-cifs@archiver.kernel.org>); Thu, 16 Dec 2021 11:22:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39187 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239597AbhLPQW3 (ORCPT <rfc822;linux-cifs@vger.kernel.org>); Thu, 16 Dec 2021 11:22:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639671748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aMAmhA/2iZbrM5E0RnQr0aNCUgy/+HjmDwYbn/reyfE=; b=TKtvS5w6eF2fkzy9sCS6V4Ivo/w+iBzXE0IHTJliMVgFgJXFQcA5JXE1I6oIObemOIxPBN 9/xw+DYJ6fFQ6S3z4Rjn97SmzLHFx46eRx5oQEmyardNY3rwohd8Ep3R9yxDugG3sbv083 5mVMNc8Wl2QSpiB4rp4tAmqQvdPN9p4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-618-EeQ_DrgzNQyZUD_1Nko1sA-1; Thu, 16 Dec 2021 11:22:23 -0500 X-MC-Unique: EeQ_DrgzNQyZUD_1Nko1sA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 68B4D6408E; Thu, 16 Dec 2021 16:22:21 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id A044A47376; Thu, 16 Dec 2021 16:22:04 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH v3 57/68] afs: Fix afs_write_end() to handle len > page size From: David Howells <dhowells@redhat.com> To: linux-cachefs@redhat.com Cc: Jeff Layton <jlayton@kernel.org>, Jeff Layton <jlayton@kernel.org>, Marc Dionne <marc.dionne@auristor.com>, Al Viro <viro@zeniv.linux.org.uk>, Matthew Wilcox <willy@infradead.org>, linux-afs@lists.infradead.org, dhowells@redhat.com, Trond Myklebust <trondmy@hammerspace.com>, Anna Schumaker <anna.schumaker@netapp.com>, Steve French <sfrench@samba.org>, Dominique Martinet <asmadeus@codewreck.org>, Jeff Layton <jlayton@kernel.org>, Matthew Wilcox <willy@infradead.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Omar Sandoval <osandov@osandov.com>, JeffleXu <jefflexu@linux.alibaba.com>, Linus Torvalds <torvalds@linux-foundation.org>, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 16 Dec 2021 16:22:03 +0000 Message-ID: <163967172373.1823006.6118195970180365070.stgit@warthog.procyon.org.uk> In-Reply-To: <163967073889.1823006.12237147297060239168.stgit@warthog.procyon.org.uk> References: <163967073889.1823006.12237147297060239168.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: <linux-cifs.vger.kernel.org> X-Mailing-List: linux-cifs@vger.kernel.org |
Series |
fscache, cachefiles: Rewrite
|
expand
|
On Thu, Dec 16, 2021 at 8:22 AM David Howells <dhowells@redhat.com> wrote: > > It is possible for the len argument to afs_write_end() to overrun the end > of the page (len is used to key the size of the page in afs_write_start() > when compound pages become a regular thing). This smells like a bug in the caller. It's just insane to call "write_end()" with a range that doesn't actually fit in the page provided. Exactly how does that happen, and why should AFS deal with it, not whoever called write_end()? Linus
diff --git a/fs/afs/write.c b/fs/afs/write.c index 8e4e87d66855..9db3ddb1c45b 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -120,6 +120,7 @@ int afs_write_end(struct file *file, struct address_space *mapping, _enter("{%llx:%llu},{%lx}", vnode->fid.vid, vnode->fid.vnode, folio_index(folio)); + len = min_t(size_t, len, folio_size(folio) - from); if (!folio_test_uptodate(folio)) { if (copied < len) { copied = 0;