From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1605CC3F2CD for ; Mon, 23 Mar 2020 15:10:41 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D79F2206F8 for ; Mon, 23 Mar 2020 15:10:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="kXHbxnnf"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="QxeJZ/ss"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="fp35Xy2S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D79F2206F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jGOiu-0007y5-DC; Mon, 23 Mar 2020 15:10:40 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jGOit-0007xz-UX for linux-f2fs-devel@lists.sourceforge.net; Mon, 23 Mar 2020 15:10:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; 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:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0AoPx3M//CC4MKv+fqKfXM7iuK3yRsz/4Eiic0tSJ0Y=; b=kXHbxnnfnWlpcAh29HD+TpiNcl kv5LVFhR+sniDjSSBw7afT64V9x5vY8gIkcW9qw2k8CxyVx+RPdpGNFgRfrFnk0KWixnp0l5OaSxn tMDxi5QCynHw3Whi5juLAcH0ztN0ckU1ZJY96Z+sHDXskT3Kdu3TQVzCRM20eT5D30jI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; 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:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=0AoPx3M//CC4MKv+fqKfXM7iuK3yRsz/4Eiic0tSJ0Y=; b=QxeJZ/sst29h6sPxroAfc59jgW 0zFX3WY1meHRtejtZtWMxvBo531jrfI1OER9L9UgxiK14vayr7S6WQmfNtu5kONdMIOdtmpS9Qhgx 1iQGpRfSo4Iw2fWudKw35HyFHwya0dWrLOHIc15JRzJhCnhoYhyAI8XLJ7k9/Mt2Rg1w=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1jGOir-004gun-W7 for linux-f2fs-devel@lists.sourceforge.net; Mon, 23 Mar 2020 15:10:39 +0000 Received: from localhost (unknown [104.132.1.66]) (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 89130206F8; Mon, 23 Mar 2020 15:10:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584976227; bh=DEot+U5aAhQnERI+yODgTb0Q/N9eQ71HwwOhlgIpZNg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fp35Xy2S29GLP/ffijwK4fWsN+7zW24b/sRU3E5KJRjWgG2NDU9PL5qcUH5rARgsq U/XhqJhFFnjVPTVydoGD1OUz86UQbWzlEmA/IJXfp1RWhT6z5RLNP6inFn/hEAWGja x4PkJp+QG2cQ6qnZ7pz53hrZcikOl+4Q50CiCUls= Date: Mon, 23 Mar 2020 08:10:27 -0700 From: Jaegeuk Kim To: Joe Perches Message-ID: <20200323151027.GA123526@google.com> References: <20200323031807.94473-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) X-Headers-End: 1jGOir-004gun-W7 Subject: Re: [f2fs-dev] [PATCH v5] f2fs: fix potential .flags overflow on 32bit architecture X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 03/23, Joe Perches wrote: > On Mon, 2020-03-23 at 11:18 +0800, Chao Yu wrote: > > f2fs_inode_info.flags is unsigned long variable, it has 32 bits > > in 32bit architecture, since we introduced FI_MMAP_FILE flag > > when we support data compression, we may access memory cross > > the border of .flags field, corrupting .i_sem field, result in > > below deadlock. > [] > > diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c > [] > > @@ -362,7 +362,7 @@ static int do_read_inode(struct inode *inode) > > fi->i_flags = le32_to_cpu(ri->i_flags); > > if (S_ISREG(inode->i_mode)) > > fi->i_flags &= ~F2FS_PROJINHERIT_FL; > > - fi->flags = 0; > > + bitmap_zero(fi->flags, BITS_TO_LONGS(FI_MAX)); > > Sorry, I misled you here, this should be > > bitmap_zero(fi->flags, FI_MAX); Thanks, I applied this directly in the f2fs tree. _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0865BC54EEB for ; Mon, 23 Mar 2020 15:10:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D35932074D for ; Mon, 23 Mar 2020 15:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584976229; bh=DEot+U5aAhQnERI+yODgTb0Q/N9eQ71HwwOhlgIpZNg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=xOteWfghfjFstXvHGRGh9D1jEuZYa0DOQZZkMjgh9WrkyBkBEy3lOyuZW1AOW9rwn MZYVVTu2haNwsW1SOFO4rOlotbZhhRX31cGwSch+zvzj8LX+ne4m7kgAXfoDN6Vqsa vHBOUKC0rybouYE6pO8suYMFpjsNuU0x57a9DKnU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727261AbgCWPK2 (ORCPT ); Mon, 23 Mar 2020 11:10:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:32926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727064AbgCWPK2 (ORCPT ); Mon, 23 Mar 2020 11:10:28 -0400 Received: from localhost (unknown [104.132.1.66]) (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 89130206F8; Mon, 23 Mar 2020 15:10:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584976227; bh=DEot+U5aAhQnERI+yODgTb0Q/N9eQ71HwwOhlgIpZNg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fp35Xy2S29GLP/ffijwK4fWsN+7zW24b/sRU3E5KJRjWgG2NDU9PL5qcUH5rARgsq U/XhqJhFFnjVPTVydoGD1OUz86UQbWzlEmA/IJXfp1RWhT6z5RLNP6inFn/hEAWGja x4PkJp+QG2cQ6qnZ7pz53hrZcikOl+4Q50CiCUls= Date: Mon, 23 Mar 2020 08:10:27 -0700 From: Jaegeuk Kim To: Joe Perches Cc: Chao Yu , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, chao@kernel.org Subject: Re: [PATCH v5] f2fs: fix potential .flags overflow on 32bit architecture Message-ID: <20200323151027.GA123526@google.com> References: <20200323031807.94473-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/23, Joe Perches wrote: > On Mon, 2020-03-23 at 11:18 +0800, Chao Yu wrote: > > f2fs_inode_info.flags is unsigned long variable, it has 32 bits > > in 32bit architecture, since we introduced FI_MMAP_FILE flag > > when we support data compression, we may access memory cross > > the border of .flags field, corrupting .i_sem field, result in > > below deadlock. > [] > > diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c > [] > > @@ -362,7 +362,7 @@ static int do_read_inode(struct inode *inode) > > fi->i_flags = le32_to_cpu(ri->i_flags); > > if (S_ISREG(inode->i_mode)) > > fi->i_flags &= ~F2FS_PROJINHERIT_FL; > > - fi->flags = 0; > > + bitmap_zero(fi->flags, BITS_TO_LONGS(FI_MAX)); > > Sorry, I misled you here, this should be > > bitmap_zero(fi->flags, FI_MAX); Thanks, I applied this directly in the f2fs tree.