Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11615209ybi; Thu, 25 Jul 2019 20:22:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzln+6ZoSC9sJ7f22ZM7A7V99nx5gkw0OjAy6SMMcuzaK4Xr6UjnBbi79lGGx9KLcOLDxCR X-Received: by 2002:a17:902:e6:: with SMTP id a93mr93776337pla.175.1564111352459; Thu, 25 Jul 2019 20:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564111352; cv=none; d=google.com; s=arc-20160816; b=MFplIgemMM0/b0QQ9jqEBkcS+24h+76AJgJsL0TTpvs/Hl/edtSm+uj+wndCamyE99 qC61iLzlgX2Z0AcTNnfxjMKykLzT93uHNxgyAImD2q8SkWAUb5jriYCy1+39QTqRp39H lwyPzSh0Vb7dUoEDDF7iF49xtWrLt69tZkba4kwp7zRmrSCW8znpp2rekbXI3Vi5bwVA cnNe+7vF5kWWevQZMUaQEldH6rqCEQZ5DuHWUzlyn6Lj9y5VoiyvN02edARJMaHo860y suYxeXTjV7RsE835k/wn2fAa+MIBt74rvEPOhswSp8ezHbgCbK1DYA4A3nyh74p1fCfw yiTA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=jsLNV33T8EDqJt/6PQmJAt68HGz+YOCCpsQJ79Ita4Y=; b=duFH1vcqqHaw5QYyktPjCSIrd4P0iYbDX+emYhpacyGYEfTbCWNQw4F/+im5l8EAl9 D9D9WZvjpEmlFzRkR+F9fltfzP7XC/6ccdcyysxCfsCf1KGOQPlIAKEWt6ZiU+Bzg3OG +Q+mxpoZhGPftekxQKSFkO7s13N4JwvgVfj/c4i284IcXc4L95nghw66iCdC067fkOkb VWiUoGEWJA73CIS9Wq2pkJfiUj7DlhrfDJpKtVqDfMFa99v46gLVM60JsDoyEXLjgsRh 4684f65rLymn2ksdNScGfLLhW7LiaVEbeBNyXe+nSsSQTp07VgYoiVnUr9WIb5hKcQoh su0Q== ARC-Authentication-Results: i=1; mx.google.com; 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 a14si17344362pjo.40.2019.07.25.20.22.17; Thu, 25 Jul 2019 20:22:32 -0700 (PDT) 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; 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 S1726193AbfGZDTt (ORCPT + 99 others); Thu, 25 Jul 2019 23:19:49 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:58782 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725909AbfGZDTt (ORCPT ); Thu, 25 Jul 2019 23:19:49 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 273C2B958C07B3984965; Fri, 26 Jul 2019 11:19:45 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 26 Jul 2019 11:19:43 +0800 Subject: Re: [BUG] fs: f2fs: Possible null-pointer dereferences in update_general_status() To: Jia-Ju Bai , CC: , References: From: Chao Yu Message-ID: <2d66cd56-eccf-9086-c5db-118acce717a6@huawei.com> Date: Fri, 26 Jul 2019 11:19:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jiaju, Thanks for the report, I checked the code, and found it doesn't need to check SM_I(sbi) pointer, this is because in fill_super() and put_super(), we will call f2fs_destroy_stats() in prior to f2fs_destroy_segment_manager(), so if current sbi can still be visited in global stat list, SM_I(sbi) should be released yet. So anyway, let's remove unneeded check in line 70/78. :) Thanks, On 2019/7/25 17:49, Jia-Ju Bai wrote: > In update_general_status(), there are two if statements to > check whether SM_I(sbi) is NULL: > LINE 70:     if (SM_I(sbi) && SM_I(sbi)->fcc_info) > LINE 78:     if (SM_I(sbi) && SM_I(sbi)->dcc_info) > > When SM_I(sbi) is NULL, it is used at some places, such as: > LINE 88: reserved_segments(sbi) >                   return SM_I(sbi)->reserved_segments; > LINE 89: overprovision_segments(sbi) >                   return SM_I(sbi)->ovp_segments; > LINE 112: MAIN_SEGS(sbi) >                     (SM_I(sbi)->main_segments) > > Thus, possible null-pointer dereferences may occur. > > These bugs are found by a static analysis tool STCheck written by us. > > I do not know how to correctly fix these bugs, so I only report them. > > > Best wishes, > Jia-Ju Bai > . >