Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3081012pxb; Mon, 18 Oct 2021 07:53:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMCPaPfj6yj9hnzgmEKNmRQnl0yxsq9CuQN+CsKyP1L6nkP0kfykvfsW9Ry23EPOF1iDN0 X-Received: by 2002:a17:906:a404:: with SMTP id l4mr30886311ejz.175.1634568815007; Mon, 18 Oct 2021 07:53:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634568814; cv=none; d=google.com; s=arc-20160816; b=YgFwcOep+W3EX/7wP4+kSh+bM3i6rkCWZ4d54o+zTFDp9ZZEPQ/QKH245xKGkGTzrv 0cAUaBct0wsO/b6/uOIg9dg7jznX0/8lZJPkJp/akNXPbT7WO7tLH9kMMmx22oPxA1hl 5SLTUo3IUoWMIRBmuoyxP0heVViGuqqvyltDng60J3FvXrP9P6jvo1yfnOI7Rf8+PQij EBDPrWqtj/RmZtW0IyHNibUo31nCaz4cn1fMyCQVRkq5ekF7tu5JS/AnwbLRCYvRLH/r R1ALWQzmksZ88fbKmvGEsJka0pN0gn2EM+cnK/bcnMhLmuCHZbRj6mrdXUixxPqAbT2Z HOkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=J2pO0HYOIIwD/Lw/VU0P6w15qtVfjBqMaV1iunSc4EI=; b=UtAzDtLYD1c9D1izHIILGz2Kx6A7Ue5Gz+bkJ1EIxJ7Oirw+1HULSnFjGQGLTeliYz M4Z0YdrEDhWdWQOJFGgO8p481TagiNzVf/ASV7wStDKXjxnhuMI3wx3n5gROFYWwqDbu dsyyQ13ZK6pBnZ75NL0XrM/4dZWkkjpqImZ7J5Xafpn4ccasfICB1J/E8fmF42sqBgqZ n1srrJMk0QPOBQfl0AXmdw2y1InoehJ+KK0Ih7ELtsTuiHElisLH8llStt9gtcQs8qUJ LGXDHhvm/iNqivQPucd4vIZmi8lx0Nj4KcnFt87Ic0xyzM3eSuNQSnw2NWSySb7dnkJW 6Ojw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Bf7mvUcL; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a24si17848629edr.610.2021.10.18.07.53.11; Mon, 18 Oct 2021 07:53:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@redhat.com header.s=mimecast20190719 header.b=Bf7mvUcL; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232483AbhJROyO (ORCPT + 99 others); Mon, 18 Oct 2021 10:54:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56641 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232476AbhJROyJ (ORCPT ); Mon, 18 Oct 2021 10:54:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634568718; 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=J2pO0HYOIIwD/Lw/VU0P6w15qtVfjBqMaV1iunSc4EI=; b=Bf7mvUcLvbfo0fI58x35zipm8ZLEXcIjntpxCI3TE+4oEI7t9NYlvl5zIonBWWKXcPBLWy R0R8TfHREK1jwnLnAxq+8TB2guoEDYNsZaS/6gfe8qYzUaIOL+l0z2rAbEN9DzXSnxOWda 3kxzIjRLyE6n/vxggNH58q4DljN/BZ0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-174-SRK6oy3jNimOUw2cLzn71A-1; Mon, 18 Oct 2021 10:51:55 -0400 X-MC-Unique: SRK6oy3jNimOUw2cLzn71A-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 B055A362F9; Mon, 18 Oct 2021 14:51:52 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0EBB5F4EE; Mon, 18 Oct 2021 14:51:44 +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 05/67] afs: Fix afs_write_end() to handle len > page size From: David Howells To: linux-cachefs@redhat.com Cc: Jeff Layton , Jeff Layton , Al Viro , Matthew Wilcox , linux-afs@lists.infradead.org, dhowells@redhat.com, Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , Jeff Layton , Matthew Wilcox , Alexander Viro , Omar Sandoval , Linus Torvalds , 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: Mon, 18 Oct 2021 15:51:43 +0100 Message-ID: <163456870391.2614702.14754663282861965969.stgit@warthog.procyon.org.uk> In-Reply-To: <163456861570.2614702.14754548462706508617.stgit@warthog.procyon.org.uk> References: <163456861570.2614702.14754548462706508617.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: X-Mailing-List: linux-nfs@vger.kernel.org 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). Fix afs_write_end() to correctly trim the write length so that it doesn't exceed the end of the page. Fixes: 3003bbd0697b ("afs: Use the netfs_write_begin() helper") Reported-by: Jeff Layton Signed-off-by: David Howells Acked-by: Jeff Layton cc: Al Viro cc: Matthew Wilcox cc: linux-afs@lists.infradead.org Link: https://lore.kernel.org/r/162367682522.460125.5652091227576721609.stgit@warthog.procyon.org.uk/ # v1 --- fs/afs/write.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/afs/write.c b/fs/afs/write.c index c09830c9dc43..e1cb19cb6314 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -119,6 +119,7 @@ int afs_write_end(struct file *file, struct address_space *mapping, _enter("{%llx:%llu},{%lx}", vnode->fid.vid, vnode->fid.vnode, page->index); + len = min_t(size_t, len, thp_size(page) - from); if (!PageUptodate(page)) { if (copied < len) { copied = 0;