Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3578739imj; Tue, 19 Feb 2019 06:03:36 -0800 (PST) X-Google-Smtp-Source: AHgI3Iaow4I2I5OcKna0rARd77cOOHhL8dOQj37SfhmOqKyqirOtd34az7/NsR0BxqGx/zPrS/tT X-Received: by 2002:a62:2e46:: with SMTP id u67mr29165364pfu.3.1550585016082; Tue, 19 Feb 2019 06:03:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550585016; cv=none; d=google.com; s=arc-20160816; b=Eu3RqO2A7/9FBenwh1To5+VWOWNm7iwrCcr1QxKtKgmX01mwaJAFdvfNeKPl92bcN1 SnzFrUq17fwPSzAbDsktJ8vvn8ntgkXsZ9qsesfHqc/pAHYT/PvDJfS5iozOpFAb3UGf USRzNpkdeiMH+/WW9jJsPOloep6ZeM9Zr6eKpq19Y0Sj7EB/lESOMQWbY3RAlAc+MsKU oPwXEqfNnqWYNUJubvZDg6/F0RO2WIC4ef0yz9bCF5sRGubsHMlUzKh9HPH0QpPEcAKb 2sSqMpBnuAMYJ9ycJnUArH1xb5xhwFPgyol1SNmX0mMmBrxK0+arEysEy6W4IV93lV6D uQFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=nPXplMffZ698k9/vXswWTo8lphpGHCZIDrTqUf0OrsE=; b=Sn/fNEnAOjZVMO8GA/Z/DvNcqq0pYje9UR19OqrFnbUc5HQxHoeE7HTVCfiOw8b0RC rckuI7vup8MhRM/XgFpJXgSsK3ZqsIGfDi15DRMqoBqPfzMcRgsUvsErp00xr+oYdP+Y 5/whOTyT1mE8EOVG1SBQfgRqyHFfyDTqfyApDe7akbE4dIEsLOaeS4x0nvzDHXWsAN33 2YAKCU/Wiatce+/IeeJUwdMQCzNBlb25kMiJXjcnlZywwygWT95ikmYNB6ouWYkNQzMg AVOGbr3IEx1R4DiOgdDHbq/P+8KHNWLoscQCUkbmmrCjByoxJ28gDmwxoUiMUgB1MEXp brjA== 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 c142si16226301pfb.33.2019.02.19.06.03.15; Tue, 19 Feb 2019 06:03:36 -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; 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 S1728839AbfBSOCn (ORCPT + 99 others); Tue, 19 Feb 2019 09:02:43 -0500 Received: from mx2.suse.de ([195.135.220.15]:59626 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725845AbfBSOCm (ORCPT ); Tue, 19 Feb 2019 09:02:42 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BFEF2AE6E; Tue, 19 Feb 2019 14:02:40 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 40DE71E1570; Tue, 19 Feb 2019 15:02:40 +0100 (CET) Date: Tue, 19 Feb 2019 15:02:40 +0100 From: Jan Kara To: Colin King Cc: Jan Kara , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][udf-next] udf: don't call mark_buffer_dirty on a null bh pointer Message-ID: <20190219140240.GA31849@quack2.suse.cz> References: <20190219114403.24771-1-colin.king@canonical.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="cWoXeonUoKmBZSoM" Content-Disposition: inline In-Reply-To: <20190219114403.24771-1-colin.king@canonical.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --cWoXeonUoKmBZSoM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue 19-02-19 11:44:03, Colin King wrote: > From: Colin Ian King > > There is a null check on the pointer bh to avoid a null pointer dereference > on bh->b_data however later bh is passed to mark_buffer_dirty that can also > cause a null pointer dereference on bh. Avoid this potential null pointer > dereference by moving the call to mark_buffer_dirty inside the null checked > block. > > Fixes: e8b4274735e4 ("udf: finalize integrity descriptor before writeback") > Signed-off-by: Colin Ian King Thanks for the patch! In fact it is the 'if (bh)' check that's unnecessarily defensive (we cannot have sbi->s_lvid_dirty and !sbi->s_lvid_bh). So I'll just drop that check (attached patch). Honza > --- > fs/udf/super.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/fs/udf/super.c b/fs/udf/super.c > index a6940d90bedd..b7e9a83d39db 100644 > --- a/fs/udf/super.c > +++ b/fs/udf/super.c > @@ -2336,13 +2336,13 @@ static int udf_sync_fs(struct super_block *sb, int wait) > > lvid = (struct logicalVolIntegrityDesc *)bh->b_data; > udf_finalize_lvid(lvid); > - } > > - /* > - * Blockdevice will be synced later so we don't have to submit > - * the buffer for IO > - */ > - mark_buffer_dirty(bh); > + /* > + * Blockdevice will be synced later so we don't have > + * to submit the buffer for IO > + */ > + mark_buffer_dirty(bh); > + } > sbi->s_lvid_dirty = 0; > } > mutex_unlock(&sbi->s_alloc_mutex); > -- > 2.20.1 > > -- Jan Kara SUSE Labs, CR --cWoXeonUoKmBZSoM Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="0001-udf-Drop-pointless-check-from-udf_sync_fs.patch" From a00eb52e3f2f815efa52a9e3bf1b730d86c05faa Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Tue, 19 Feb 2019 14:59:43 +0100 Subject: [PATCH] udf: Drop pointless check from udf_sync_fs() The check if (bh) in udf_sync_fs() is pointless as we cannot have sbi->s_lvid_dirty and !sbi->s_lvid_bh (as already asserted by udf_updated_lvid()). So just drop the pointless check. Reported-by: Colin Ian King Signed-off-by: Jan Kara --- fs/udf/super.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/udf/super.c b/fs/udf/super.c index a6940d90bedd..ffd8038ff728 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -2330,13 +2330,10 @@ static int udf_sync_fs(struct super_block *sb, int wait) mutex_lock(&sbi->s_alloc_mutex); if (sbi->s_lvid_dirty) { struct buffer_head *bh = sbi->s_lvid_bh; + struct logicalVolIntegrityDesc *lvid; - if (bh) { - struct logicalVolIntegrityDesc *lvid; - - lvid = (struct logicalVolIntegrityDesc *)bh->b_data; - udf_finalize_lvid(lvid); - } + lvid = (struct logicalVolIntegrityDesc *)bh->b_data; + udf_finalize_lvid(lvid); /* * Blockdevice will be synced later so we don't have to submit -- 2.16.4 --cWoXeonUoKmBZSoM--