Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4919665imc; Mon, 25 Feb 2019 13:38:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IbgRKw5YVfIcy23agDwgQNivrmRgdO9R3j9jRszY6XRQu6qx0Pdqv1GA6G/9UluEp6TaKxO X-Received: by 2002:a63:4f58:: with SMTP id p24mr21084788pgl.283.1551130732890; Mon, 25 Feb 2019 13:38:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551130732; cv=none; d=google.com; s=arc-20160816; b=o/TfHJJLinMLdY4eKxECBrd7/wT+g6ENCLgvJ1W/4JxfZE8+8ybC6KrxR74JCUmipw NoN45nmgKnsSM2L5t8XUqPk36LzLqego7pesky/+nT/xPbjyo1s0uHwxbJdQvD/Q6n4O 8C6cTD3tPAP0c2Pe5LmscheQOTEf/Pysq2rMWxOQbn6FPCWN0lvOE2JxPepijJUNGXI1 KVZR2bGBdHHfjgYmyQRqR5WotqcLZwfKKvhDjCx24KLXQyaINHnaD+dC7i3XM+YfV5N9 R+CKEX9sxuH/wIL6Axxzco8FPBjNWUk1RZ1XO38Sgd7iI3+ZTPL8AUWSVd7g7IZhTMAV AjSA== 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=sfkcsYrHnH3yv3IvJd5dNifxFgfbkXakTtzNDI/ihpE=; b=RVUCNSl+kc0uOPg2dQ4IN3461JA9Yn/UFE4VMB7QlKBTVKw/lmjDs/0jOPSomqVukA SeaejQLIfLfMsVMktVgCSxsMbo/UFL1RqhofTpjeHXWx8FKo3XQuel1Ph6QdADdyJi13 Dt7HSYRRJwDOqKkR6FjeTtC92ekZB470V/t8/rvSAaZvN9sWFrcC+9rqdcgwmiB+CeZ4 xZJBYat6fOfqhYvMZO97r3meiggq5LhmMq2KTuOri8zUMx9sDqeg0UfUGcmz2OMTpqVy G7Bz42rmWbmvcbFICss0bMmhlJDX3vZB3LLHI8AF7Ygo+Usez+CwHupW5f9Kw0YKnSzY zmRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Lmca75rQ; 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 o9si11086161pfe.63.2019.02.25.13.38.37; Mon, 25 Feb 2019 13:38:52 -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=Lmca75rQ; 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 S1733270AbfBYVgw (ORCPT + 99 others); Mon, 25 Feb 2019 16:36:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:44046 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732813AbfBYVgu (ORCPT ); Mon, 25 Feb 2019 16:36:50 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 B979120578; Mon, 25 Feb 2019 21:36:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551130609; bh=nk7ixvIMDn8ESec8wrvDp4VFL4dd54Bqox5yKp9e32Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lmca75rQxG+NOfoFtaJXrTuEHa0BFhWfrIsG9RQOJGhZrAW03GbTYG6AjLFZ33H3c mh4ilvJG1NX1/YXD+dAxod50B7gADebmzN1UrPrTwO4KCKnMCi/SXO4X+dUj1618Nd 84Hm9xC7JSV9monsC5UkW4vR2vtns/Dgf6uDiIIc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gao Xiang Subject: [PATCH 4.20 174/183] staging: erofs: {dir,inode,super}.c: rectify BUG_ONs Date: Mon, 25 Feb 2019 22:12:27 +0100 Message-Id: <20190225195124.475116046@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190225195054.748060397@linuxfoundation.org> References: <20190225195054.748060397@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gao Xiang commit 8b987bca2d09649683cbe496419a011df8c08493 upstream. remove all redundant BUG_ONs, and turn the rest useful usages to DBG_BUGONs. Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/dir.c | 7 +++++-- drivers/staging/erofs/inode.c | 10 ++++++++-- drivers/staging/erofs/super.c | 13 ++++++------- 3 files changed, 19 insertions(+), 11 deletions(-) --- a/drivers/staging/erofs/dir.c +++ b/drivers/staging/erofs/dir.c @@ -53,8 +53,11 @@ static int erofs_fill_dentries(struct di strnlen(de_name, maxsize - nameoff) : le16_to_cpu(de[1].nameoff) - nameoff; - /* the corrupted directory found */ - BUG_ON(de_namelen < 0); + /* a corrupted entry is found */ + if (unlikely(de_namelen < 0)) { + DBG_BUGON(1); + return -EIO; + } #ifdef CONFIG_EROFS_FS_DEBUG dbg_namelen = min(EROFS_NAME_LEN - 1, de_namelen); --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -133,7 +133,13 @@ static int fill_inline_data(struct inode return -ENOMEM; m_pofs += vi->inode_isize + vi->xattr_isize; - BUG_ON(m_pofs + inode->i_size > PAGE_SIZE); + + /* inline symlink data shouldn't across page boundary as well */ + if (unlikely(m_pofs + inode->i_size > PAGE_SIZE)) { + DBG_BUGON(1); + kfree(lnk); + return -EIO; + } /* get in-page inline data */ memcpy(lnk, data + m_pofs, inode->i_size); @@ -171,7 +177,7 @@ static int fill_inode(struct inode *inod return PTR_ERR(page); } - BUG_ON(!PageUptodate(page)); + DBG_BUGON(!PageUptodate(page)); data = page_address(page); err = read_inode(inode, data + ofs); --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -40,7 +40,6 @@ static int __init erofs_init_inode_cache static void erofs_exit_inode_cache(void) { - BUG_ON(erofs_inode_cachep == NULL); kmem_cache_destroy(erofs_inode_cachep); } @@ -303,8 +302,8 @@ static int managed_cache_releasepage(str int ret = 1; /* 0 - busy */ struct address_space *const mapping = page->mapping; - BUG_ON(!PageLocked(page)); - BUG_ON(mapping->a_ops != &managed_cache_aops); + DBG_BUGON(!PageLocked(page)); + DBG_BUGON(mapping->a_ops != &managed_cache_aops); if (PagePrivate(page)) ret = erofs_try_to_free_cached_page(mapping, page); @@ -317,10 +316,10 @@ static void managed_cache_invalidatepage { const unsigned int stop = length + offset; - BUG_ON(!PageLocked(page)); + DBG_BUGON(!PageLocked(page)); - /* Check for overflow */ - BUG_ON(stop > PAGE_SIZE || stop < length); + /* Check for potential overflow in debug mode */ + DBG_BUGON(stop > PAGE_SIZE || stop < length); if (offset == 0 && stop == PAGE_SIZE) while (!managed_cache_releasepage(page, GFP_NOFS)) @@ -649,7 +648,7 @@ static int erofs_remount(struct super_bl unsigned int org_inject_rate = erofs_get_fault_rate(sbi); int err; - BUG_ON(!sb_rdonly(sb)); + DBG_BUGON(!sb_rdonly(sb)); err = parse_options(sb, data); if (err) goto out;