From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@redhat.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH v2 09/14] xfs_scrub: don't warn about confusing names if dir/file only writable by root
Date: Mon, 26 Mar 2018 12:59:03 -0700 [thread overview]
Message-ID: <20180326195903.GY4818@magnolia> (raw)
In-Reply-To: <152160363583.8288.9124313321960984587.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
If we are scanning the directory entries or attribute names of a
dir/file and the inode can only be written by root, don't warn about
Unicode confusable names by default because the system administrator
presumably made the system like that. Also don't warn about really
short confusable names because of the high chance of collisions. If
the caller really wants all the output, they can run in verbose mode.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
v2: fix resource cleanup breakage in unicrash_init
---
scrub/unicrash.c | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/scrub/unicrash.c b/scrub/unicrash.c
index 8b58269..f60e07f 100644
--- a/scrub/unicrash.c
+++ b/scrub/unicrash.c
@@ -92,6 +92,7 @@ struct unicrash {
USpoofChecker *spoof;
const UNormalizer2 *normalizer;
bool compare_ino;
+ bool is_only_root_writeable;
size_t nr_buckets;
struct name_entry *buckets[0];
};
@@ -395,7 +396,8 @@ unicrash_init(
struct unicrash **ucp,
struct scrub_ctx *ctx,
bool compare_ino,
- size_t nr_buckets)
+ size_t nr_buckets,
+ bool is_only_root_writeable)
{
struct unicrash *p;
UErrorCode uerr = U_ZERO_ERROR;
@@ -425,6 +427,7 @@ unicrash_init(
uspoof_setChecks(p->spoof, USPOOF_ALL_CHECKS, &uerr);
if (U_FAILURE(uerr))
goto out_spoof;
+ p->is_only_root_writeable = is_only_root_writeable;
*ucp = p;
return true;
@@ -435,6 +438,20 @@ unicrash_init(
return false;
}
+/*
+ * Is this inode owned by root and not writable by others? If so, skip
+ * even the informational messages, because this was put in place by the
+ * administrator.
+ */
+static bool
+is_only_root_writable(
+ struct xfs_bstat *bstat)
+{
+ if (bstat->bs_uid != 0 || bstat->bs_gid != 0)
+ return false;
+ return !(bstat->bs_mode & S_IWOTH);
+}
+
/* Initialize the collision detector for a directory. */
bool
unicrash_dir_init(
@@ -446,7 +463,8 @@ unicrash_dir_init(
* Assume 64 bytes per dentry, clamp buckets between 16 and 64k.
* Same general idea as dir_hash_init in xfs_repair.
*/
- return unicrash_init(ucp, ctx, true, bstat->bs_size / 64);
+ return unicrash_init(ucp, ctx, true, bstat->bs_size / 64,
+ is_only_root_writable(bstat));
}
/* Initialize the collision detector for an extended attribute. */
@@ -457,7 +475,8 @@ unicrash_xattr_init(
struct xfs_bstat *bstat)
{
/* Assume 16 attributes per extent for lack of a better idea. */
- return unicrash_init(ucp, ctx, false, 16 * (1 + bstat->bs_aextents));
+ return unicrash_init(ucp, ctx, false, 16 * (1 + bstat->bs_aextents),
+ is_only_root_writable(bstat));
}
/* Free the crash detector. */
@@ -549,6 +568,15 @@ _("Unicode name \"%s\" in %s contains control characters."),
}
/*
+ * Skip the informational messages if the inode owning the name is
+ * only writeable by root, because those files were put there by the
+ * sysadmin. Also skip names less than four letters long because
+ * there's a much higher chance of collisions with short names.
+ */
+ if (!verbose && (uc->is_only_root_writeable || entry->namelen < 4))
+ goto out;
+
+ /*
* It's not considered good practice (says Unicode) to mix LTR
* characters with RTL characters. The mere presence of different
* bidirectional characters isn't enough to trip up software, so don't
next prev parent reply other threads:[~2018-03-26 19:59 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-21 3:39 [PATCH 00/14] xfsprogs: online scrub fixes Darrick J. Wong
2018-03-21 3:39 ` [PATCH 01/14] xfs_scrub: avoid buffer overflow when scanning attributes Darrick J. Wong
2018-04-03 17:30 ` Eric Sandeen
2018-04-05 3:57 ` Darrick J. Wong
2018-04-11 0:20 ` Darrick J. Wong
2018-04-11 0:27 ` [PATCH v2 " Darrick J. Wong
2018-03-21 3:39 ` [PATCH 02/14] xfs_scrub: only run ascii name checks if unicode name checker Darrick J. Wong
2018-04-03 17:49 ` Eric Sandeen
2018-03-21 3:39 ` [PATCH 03/14] xfs_scrub: don't complain about different normalization Darrick J. Wong
2018-04-10 23:37 ` Eric Sandeen
2018-03-21 3:40 ` [PATCH 04/14] xfs_scrub: communicate name problems via flagset instead of booleans Darrick J. Wong
2018-04-10 23:46 ` Eric Sandeen
2018-03-21 3:40 ` [PATCH 05/14] xfs_scrub: make name_entry a first class structure Darrick J. Wong
2018-03-21 3:40 ` [PATCH 06/14] xfs_scrub: transition from libunistring to libicu for Unicode processing Darrick J. Wong
2018-03-21 3:40 ` [PATCH 07/14] xfs_scrub: check name for suspicious characters Darrick J. Wong
2018-03-21 3:40 ` [PATCH 08/14] xfs_scrub: use Unicode skeleton function to find confusing names Darrick J. Wong
2018-03-26 19:58 ` [PATCH v2 " Darrick J. Wong
2018-03-21 3:40 ` [PATCH 09/14] xfs_scrub: don't warn about confusing names if dir/file only writable by root Darrick J. Wong
2018-03-26 19:59 ` Darrick J. Wong [this message]
2018-03-21 3:40 ` [PATCH 10/14] xfs_scrub: refactor mountpoint finding code to use libfrog path code Darrick J. Wong
2018-04-11 1:48 ` Eric Sandeen
2018-03-21 3:40 ` [PATCH 11/14] xfs_scrub_all: report version Darrick J. Wong
2018-04-11 0:28 ` Eric Sandeen
2018-03-21 3:40 ` [PATCH 12/14] xfs_scrub: disable private /tmp for scrub service Darrick J. Wong
2018-04-11 1:45 ` Eric Sandeen
2018-04-11 1:49 ` Darrick J. Wong
2018-04-11 1:53 ` [PATCH v2 " Darrick J. Wong
2018-03-21 3:41 ` [PATCH 13/14] xfs_scrub_all: escape paths being passed to systemd service instances Darrick J. Wong
2018-04-11 1:31 ` Eric Sandeen
2018-03-21 3:41 ` [PATCH 14/14] xfs_scrub_all: use system encoding for lsblk output decoding Darrick J. Wong
2018-04-11 1:35 ` Eric Sandeen
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=20180326195903.GY4818@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.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;
as well as URLs for NNTP newsgroup(s).