Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2288090pxb; Fri, 5 Feb 2021 13:58:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYufDRRoZxbIFMPYzrID6to5ri1JaJI+uCyVmcYW2WHM2vU5WmHv4U/nEzS1gQwU3stdJJ X-Received: by 2002:aa7:c685:: with SMTP id n5mr5803645edq.150.1612562309899; Fri, 05 Feb 2021 13:58:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612562309; cv=none; d=google.com; s=arc-20160816; b=EChzZe38K2+JvuSYmWA8unnx4bBREJCOqnhdCmsLke6sGmblV/5tbtNBsvMKK7IIKD puzxMOS4OHWAFSzqswUYq01KkbWM9CGBibcyj9uxzbvgS+OrJrfigWsRrh119hYRvpUc ogK4xzNScwrVoEXV9QiUnB9UZ3IbG6cmt+kUh1dI+jXfYK6HqJTLHCu1lg9y8HmVGHY7 W5uo+bhKsioWyOESZ4C+YaUNO2FWoqnYG8H3LlYduGnJPL29MG/Tlz5OkJLHc5NztgCD yOsMaC5on2PHuT+xiuK/TS/YQPBiI2q1Z2F0I++icFQv/5bty8FJ0nVa8jdsT69Fkw06 suvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+oj3jf0h35ULSnP16LRDpazOkaG3rXEAN71Z/OqJnaY=; b=bZ5QrshNdmuIQ2lqvUsCLyAcbmjVy6K6XqNOa9Z7atCHEnVROzN/hIMyCuCm56MILJ nouvZLtSu4yTPcePF3TtCCv9i85lPpeOr5MrQosMvi0tVTb4m+5uH/BVHZcZn+ZOx7xa 5meeESDi4a1a9niXuay8JHv/ko1LmdcRnSrFvzI8ezZ82sJBPFyjXRpws2AjR5UMUnIu aaP7qTiXW+xcYiS2nJkvh4e+kViFcv4KhOzmrAE+xLLsX6N47ddyXjVOliC6dnztWyOE d21dDRpb11p0EB9ErRokliuo4qx4X+ETgU7ABQMAPfh1MM+iPd6phdbyG0HJMYn3qK0i mFEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GcDSbk87; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si6296213eje.581.2021.02.05.13.58.05; Fri, 05 Feb 2021 13:58:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GcDSbk87; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229561AbhBEVzW (ORCPT + 99 others); Fri, 5 Feb 2021 16:55:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:45246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233011AbhBEO7i (ORCPT ); Fri, 5 Feb 2021 09:59:38 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 05BC765081; Fri, 5 Feb 2021 14:13:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612534405; bh=oM8JB8Qgfq06tyGeAVxKc/yIj9t/c0I1tywi4103OQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GcDSbk87tbzZYk/teKwL7doyZrzfrgv9w53hd3XlUs7vALxTATiOy85/wOAJBtOzi 682PXx+GNdy3j+4MkUTGmN0Ydy28vQeWCoRq7yXhx04kAGewBr9MrfUCfIvgo0/cCx q6Bq0iTnpzH8fSjTCTAa0fY9Z2XCezfbU9r8Yktw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, lianzhi chang , Jan Kara , Sasha Levin Subject: [PATCH 5.4 25/32] udf: fix the problem that the disc content is not displayed Date: Fri, 5 Feb 2021 15:07:40 +0100 Message-Id: <20210205140653.413160745@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210205140652.348864025@linuxfoundation.org> References: <20210205140652.348864025@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: lianzhi chang [ Upstream commit 5cdc4a6950a883594e9640b1decb3fcf6222a594 ] When the capacity of the disc is too large (assuming the 4.7G specification), the disc (UDF file system) will be burned multiple times in the windows (Multisession Usage). When the remaining capacity of the CD is less than 300M (estimated value, for reference only), open the CD in the Linux system, the content of the CD is displayed as blank (the kernel will say "No VRS found"). Windows can display the contents of the CD normally. Through analysis, in the "fs/udf/super.c": udf_check_vsd function, the actual value of VSD_MAX_SECTOR_OFFSET may be much larger than 0x800000. According to the current code logic, it is found that the type of sbi->s_session is "__s32", when the remaining capacity of the disc is less than 300M (take a set of test values: sector=3154903040, sbi->s_session=1540464, sb->s_blocksize_bits=11 ), the calculation result of "sbi->s_session << sb->s_blocksize_bits" will overflow. Therefore, it is necessary to convert the type of s_session to "loff_t" (when udf_check_vsd starts, assign a value to _sector, which is also converted in this way), so that the result will not overflow, and then the content of the disc can be displayed normally. Link: https://lore.kernel.org/r/20210114075741.30448-1-changlianzhi@uniontech.com Signed-off-by: lianzhi chang Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/udf/super.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/udf/super.c b/fs/udf/super.c index 4aba4878ed967..8bb001c7927f0 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -705,6 +705,7 @@ static int udf_check_vsd(struct super_block *sb) struct buffer_head *bh = NULL; int nsr = 0; struct udf_sb_info *sbi; + loff_t session_offset; sbi = UDF_SB(sb); if (sb->s_blocksize < sizeof(struct volStructDesc)) @@ -712,7 +713,8 @@ static int udf_check_vsd(struct super_block *sb) else sectorsize = sb->s_blocksize; - sector += (((loff_t)sbi->s_session) << sb->s_blocksize_bits); + session_offset = (loff_t)sbi->s_session << sb->s_blocksize_bits; + sector += session_offset; udf_debug("Starting at sector %u (%lu byte sectors)\n", (unsigned int)(sector >> sb->s_blocksize_bits), @@ -757,8 +759,7 @@ static int udf_check_vsd(struct super_block *sb) if (nsr > 0) return 1; - else if (!bh && sector - (sbi->s_session << sb->s_blocksize_bits) == - VSD_FIRST_SECTOR_OFFSET) + else if (!bh && sector - session_offset == VSD_FIRST_SECTOR_OFFSET) return -1; else return 0; -- 2.27.0