Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8517773ybl; Thu, 16 Jan 2020 18:36:37 -0800 (PST) X-Google-Smtp-Source: APXvYqxz+um5UfVbRBLc0lldDCKNxLj2kT/dbMsWftUhVXbfAADkCwbkQ4hCZfiGJmbkSDAa/AHu X-Received: by 2002:aca:5303:: with SMTP id h3mr1748328oib.109.1579228597448; Thu, 16 Jan 2020 18:36:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579228597; cv=none; d=google.com; s=arc-20160816; b=cEuFgD0j23po85U7BtBmqqssVAzH2PGRHH8J81CbSrOI3ZpOy2/MZ7Uh3VAGJM/i3c XIkwU7PvpMJpAijKD1KTDOE/+Lq8z463U68C6Izz+kLu5ew4LLjjVeFQdafn6nPUMbuK ovdXBziRIFAzkLcOsfSlCHy7qZabPrM509xTq3lUYSOel6wuTbfNC+VAPtkZFQZPl6x2 ony1R6qcsbuF2AjUZpWYJQNuhs6FybBbs1C8DO9yPU8AeZ3NgN58v+gup/zhzVxBFL8L KfyPhU7r/Bke77FX7xLT8NFP+9lfw7ED3dctiF65899gYtMbE2eWPfGZAHhOMFQszhr9 1Dng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=D+TIKXi/Zpd2AHNAKfnyROn5Ktc0PPib4YQ61rP3Xc0=; b=RLD7N0x33wPQORNHWMpSf1WVHZ1fpabotfEG0Wz5foVLQqSLw2W6ZbrzSXiep54g+h i/r7E50lPatyuoYE8/7HvyM09WRmERnlBpHDl0BhVRB7S9ILMZDLL71h7k5bMk92ng2O yPUiT77FQOoY0Su2Irn1O3eaYLaENrgnblRYESppuyspObneBHhAxpcdK3AFb/ZYCQEY 4zpKEWJoQu480ndcrheiYcgfWJOxqJRMqG+k1dRVCucAsK1j7+W0gZdUpTN+szTvtA+i 843SurjDmrwW1XhLdU7+etlmG0CMKYQpZp0Gz4yBgcOp+N9tTidHOX5M6Ly9KPcD7CiL R1JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SwRQBHX7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 30si14044717otr.75.2020.01.16.18.36.26; Thu, 16 Jan 2020 18:36:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SwRQBHX7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388353AbgAPX0e (ORCPT + 99 others); Thu, 16 Jan 2020 18:26:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:56518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388576AbgAPX0L (ORCPT ); Thu, 16 Jan 2020 18:26:11 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 811182073A; Thu, 16 Jan 2020 23:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579217171; bh=SQLaG+Rhvxl7OCgsAARRdSQ0xmHBXEP/Q3RysXc5wEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SwRQBHX7SP+LR/DX0HWFoZLieAuaLChYrWfd7SeLs6bXhFxnWa+GdrEWK67bjKh4L tp003UaiIUTYq37ybNqoaga/gQWPg0nt/YYcSD2JH08HLzpJ/J5j0m4qL9VEyowa3N 6mAAInqlV33mnNhLPPuIU6XV5ZucG7Gcvkvrfr+o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Jaegeuk Kim Subject: [PATCH 5.4 176/203] f2fs: fix potential overflow Date: Fri, 17 Jan 2020 00:18:13 +0100 Message-Id: <20200116231759.851132096@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231745.218684830@linuxfoundation.org> References: <20200116231745.218684830@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Yu commit 1f0d5c911b64165c9754139a26c8c2fad352c132 upstream. We expect 64-bit calculation result from below statement, however in 32-bit machine, looped left shift operation on pgoff_t type variable may cause overflow issue, fix it by forcing type cast. page->index << PAGE_SHIFT; Fixes: 26de9b117130 ("f2fs: avoid unnecessary updating inode during fsync") Fixes: 0a2aa8fbb969 ("f2fs: refactor __exchange_data_block for speed up") Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/data.c | 2 +- fs/f2fs/file.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2098,7 +2098,7 @@ static int __write_data_page(struct page loff_t i_size = i_size_read(inode); const pgoff_t end_index = ((unsigned long long) i_size) >> PAGE_SHIFT; - loff_t psize = (page->index + 1) << PAGE_SHIFT; + loff_t psize = (loff_t)(page->index + 1) << PAGE_SHIFT; unsigned offset = 0; bool need_balance_fs = false; int err = 0; --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1139,7 +1139,7 @@ static int __clone_blkaddrs(struct inode } dn.ofs_in_node++; i++; - new_size = (dst + i) << PAGE_SHIFT; + new_size = (loff_t)(dst + i) << PAGE_SHIFT; if (dst_inode->i_size < new_size) f2fs_i_size_write(dst_inode, new_size); } while (--ilen && (do_replace[i] || blkaddr[i] == NULL_ADDR));