Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3864069pxb; Tue, 17 Nov 2020 05:41:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJyulo+cUkjNU2nsi3D7CsGljoPrWuOEMUPH9m19WBYLmCLevwelGGzScmqyZ/FWssSAJEZ0 X-Received: by 2002:a17:906:48a:: with SMTP id f10mr19790324eja.5.1605620506863; Tue, 17 Nov 2020 05:41:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605620506; cv=none; d=google.com; s=arc-20160816; b=H8DnvyRNgXpF2jNMziJCzTOOjTij/4iax29Lxp1RZlvyMUK1qLJxHTe9Ute9AQKsrg sPFtHT5spPX8sHjyHlv8cy/aIC8NmzNRvScd9Ng+40sZGlCfaFzXm1p2dT2xf3neAJEz Bon/JJYDmm4qV+9reMgIHKzj1fuirzgxIgC7kqZahaIjmC6rhPNpcFwQoLZEZkHWdbe6 FK4mUBML47mHuP1ni7EPylEoXGUE29bzXVl8dm+wvQwJ2mRlMl2kiwUYKB2CbZTiDGAG mkxPNYmg4R4HIJKNXutzNxd/ZBYTI4nlA2AabF+lg56UzeoCS6PhSsPJozlGiAPcq4c+ +y7Q== 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:subject:cc:to :from:dkim-signature; bh=ifXaPf6q9pxcZHsk+wP/QFRXTj8TStcDeb0XBhd3UUM=; b=kaSvltrSAq3u8sDPwjsFgj5OCnkij9Y5NtC7xbb6GgrJoLZrOg/sdHjJ3HdO71YBLV Yy038L9HPZKxpkXq9W9dWSZLpM+Js8vBd4X+OaMlyROqDEuidciB2E+S6zaCtEgCYpS0 bukolJtoFzeRus+P4tTLYY/SkWWuox3QgIyAQ7arLaX8tXwg4g1+SdwUvlBnYqqfWsXO FGZIxCL1K8YZihf236Gv+leKwiyDGs6qp+JNX5eMgYUFbjvI6aKxVEXR/mdq4HGTPHdb /21c2FkLFzqAP9TAip7UPV0hW/QDDKz/W2KDlpxaw0MueY9HlZ5UuAG6//YnruojTotM iXNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Tat+r/99"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs35si14134650ejc.312.2020.11.17.05.41.23; Tue, 17 Nov 2020 05:41:46 -0800 (PST) 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=@kernel.org header.s=default header.b="Tat+r/99"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731680AbgKQNin (ORCPT + 99 others); Tue, 17 Nov 2020 08:38:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:50008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731383AbgKQNia (ORCPT ); Tue, 17 Nov 2020 08:38:30 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3778B207BC; Tue, 17 Nov 2020 13:38:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605620309; bh=aYYzHOoCV6gCysEZbfGYvQNc1yvGfnQmzubeoEYDYII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tat+r/999pndcTJpP1QZ0cVVkJT+S0+fWI8EjG9qIhGs+9iwsJOl91cZQVdpslwo2 7dYkRGb/rZnHa/iUT/ROXJEcx7ygyGx1+aLrJjvW9IAyOMXy9dEiR88de/MTJCHQzs G0yQfv4Oy/Gq+5R+XPCpnihwgTKIdeY9tg7g3BNI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells , Linus Torvalds , Sasha Levin Subject: [PATCH 5.9 175/255] afs: Fix afs_write_end() when called with copied == 0 [ver #3] Date: Tue, 17 Nov 2020 14:05:15 +0100 Message-Id: <20201117122147.442866855@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122138.925150709@linuxfoundation.org> References: <20201117122138.925150709@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Howells [ Upstream commit 3ad216ee73abc554ed8f13f4f8b70845a7bef6da ] When afs_write_end() is called with copied == 0, it tries to set the dirty region, but there's no way to actually encode a 0-length region in the encoding in page->private. "0,0", for example, indicates a 1-byte region at offset 0. The maths miscalculates this and sets it incorrectly. Fix it to just do nothing but unlock and put the page in this case. We don't actually need to mark the page dirty as nothing presumably changed. Fixes: 65dd2d6072d3 ("afs: Alter dirty range encoding in page->private") Signed-off-by: David Howells Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/afs/write.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/afs/write.c b/fs/afs/write.c index 50371207f3273..c9195fc67fd8f 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -169,11 +169,14 @@ int afs_write_end(struct file *file, struct address_space *mapping, unsigned int f, from = pos & (PAGE_SIZE - 1); unsigned int t, to = from + copied; loff_t i_size, maybe_i_size; - int ret; + int ret = 0; _enter("{%llx:%llu},{%lx}", vnode->fid.vid, vnode->fid.vnode, page->index); + if (copied == 0) + goto out; + maybe_i_size = pos + copied; i_size = i_size_read(&vnode->vfs_inode); -- 2.27.0