From: Jan Kara <jack@suse.cz>
To: "Pali Rohár" <pali.rohar@gmail.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Jan Kara <jack@suse.cz>
Subject: Re: [WIP PATCH 1/4] udf: Do not access LVIDIU revision members when they are not filled
Date: Mon, 13 Jan 2020 13:00:49 +0100 [thread overview]
Message-ID: <20200113120049.GF23642@quack2.suse.cz> (raw)
In-Reply-To: <20200112175933.5259-2-pali.rohar@gmail.com>
On Sun 12-01-20 18:59:30, Pali Rohár wrote:
> minUDFReadRev, minUDFWriteRev and maxUDFWriteRev members were introduced in
> UDF 1.02. Previous UDF revisions used that area for implementation specific
> data. So in this case do not touch these members.
>
> To check if LVIDIU contain revisions members, first read UDF revision from
> LVD. If revision is at least 1.02 LVIDIU should contain revision members.
>
> This change should fix mounting UDF 1.01 images in R/W mode. Kernel would
> not touch, read overwrite implementation specific area of LVIDIU.
>
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Maybe we could store the fs revision in the superblock as well to avoid
passing the udf_rev parameter?
Also this patch contains several lines over 80 columns.
Honza
> ---
> fs/udf/super.c | 37 ++++++++++++++++++++++++++-----------
> fs/udf/udf_sb.h | 3 +++
> 2 files changed, 29 insertions(+), 11 deletions(-)
>
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index 2d0b90800..8df6e9962 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -765,7 +765,7 @@ static int udf_check_vsd(struct super_block *sb)
> }
>
> static int udf_verify_domain_identifier(struct super_block *sb,
> - struct regid *ident, char *dname)
> + struct regid *ident, char *dname, u16 *udf_rev)
> {
> struct domainIdentSuffix *suffix;
>
> @@ -779,6 +779,8 @@ static int udf_verify_domain_identifier(struct super_block *sb,
> goto force_ro;
> }
> suffix = (struct domainIdentSuffix *)ident->identSuffix;
> + if (udf_rev)
> + *udf_rev = le16_to_cpu(suffix->UDFRevision);
> if ((suffix->domainFlags & DOMAIN_FLAGS_HARD_WRITE_PROTECT) ||
> (suffix->domainFlags & DOMAIN_FLAGS_SOFT_WRITE_PROTECT)) {
> if (!sb_rdonly(sb)) {
> @@ -801,7 +803,7 @@ static int udf_load_fileset(struct super_block *sb, struct fileSetDesc *fset,
> {
> int ret;
>
> - ret = udf_verify_domain_identifier(sb, &fset->domainIdent, "file set");
> + ret = udf_verify_domain_identifier(sb, &fset->domainIdent, "file set", NULL);
> if (ret < 0)
> return ret;
>
> @@ -1404,7 +1406,7 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,
> }
>
> ret = udf_verify_domain_identifier(sb, &lvd->domainIdent,
> - "logical volume");
> + "logical volume", &sbi->s_lvd_udfrev);
> if (ret)
> goto out_bh;
> ret = udf_sb_alloc_partition_maps(sb, le32_to_cpu(lvd->numPartitionMaps));
> @@ -2055,12 +2057,19 @@ static void udf_close_lvid(struct super_block *sb)
> mutex_lock(&sbi->s_alloc_mutex);
> lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
> lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
> - if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev))
> - lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
> - if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev))
> - lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev);
> - if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev))
> - lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev);
> +
> + /* minUDFReadRev, minUDFWriteRev and maxUDFWriteRev members were
> + * introduced in UDF 1.02. Previous UDF revisions used that area for
> + * implementation specific data. So in this case do not touch it. */
> + if (sbi->s_lvd_udfrev >= 0x0102) {
> + if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev))
> + lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
> + if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev))
> + lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev);
> + if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev))
> + lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev);
> + }
> +
> if (!UDF_QUERY_FLAG(sb, UDF_FLAG_INCONSISTENT))
> lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
>
> @@ -2220,8 +2229,14 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
> ret = -EINVAL;
> goto error_out;
> }
> - minUDFReadRev = le16_to_cpu(lvidiu->minUDFReadRev);
> - minUDFWriteRev = le16_to_cpu(lvidiu->minUDFWriteRev);
> +
> + if (sbi->s_lvd_udfrev >= 0x0102) { /* minUDFReadRev and minUDFWriteRev were introduced in UDF 1.02 */
> + minUDFReadRev = le16_to_cpu(lvidiu->minUDFReadRev);
> + minUDFWriteRev = le16_to_cpu(lvidiu->minUDFWriteRev);
> + } else {
> + minUDFReadRev = minUDFWriteRev = sbi->s_lvd_udfrev;
> + }
> +
> if (minUDFReadRev > UDF_MAX_READ_VERSION) {
> udf_err(sb, "minUDFReadRev=%x (max is %x)\n",
> minUDFReadRev,
> diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
> index 3d83be54c..6bd0d4430 100644
> --- a/fs/udf/udf_sb.h
> +++ b/fs/udf/udf_sb.h
> @@ -137,6 +137,9 @@ struct udf_sb_info {
> /* Fileset Info */
> __u16 s_serial_number;
>
> + /* LVD UDF revision filled to media at format time */
> + __u16 s_lvd_udfrev;
> +
> /* highest UDF revision we have recorded to this media */
> __u16 s_udfrev;
>
> --
> 2.20.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2020-01-13 12:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-12 17:59 [WIP PATCH 0/4] Support for UDF 1.01 and 2.60 revisions Pali Rohár
2020-01-12 17:59 ` [WIP PATCH 1/4] udf: Do not access LVIDIU revision members when they are not filled Pali Rohár
2020-01-13 12:00 ` Jan Kara [this message]
2020-01-13 18:37 ` Pali Rohár
2020-01-14 12:01 ` Jan Kara
2020-01-12 17:59 ` [WIP PATCH 2/4] udf: Fix reading numFiles and numDirs from UDF 2.00+ VAT discs Pali Rohár
2020-01-13 11:58 ` Jan Kara
2020-01-13 18:11 ` Pali Rohár
2020-01-14 11:18 ` Jan Kara
2020-01-14 11:37 ` Jan Kara
2020-01-12 17:59 ` [WIP PATCH 3/4] udf: Fix reading minUDFReadRev and minUDFWriteRev " Pali Rohár
2020-01-12 17:59 ` [WIP PATCH 4/4] udf: Allow to read UDF 2.60 discs Pali Rohár
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200113120049.GF23642@quack2.suse.cz \
--to=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pali.rohar@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®