]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs.xfs: null-terminate symlinks created via protofile
authorEric Sandeen <sandeen@redhat.com>
Wed, 12 Dec 2018 17:42:40 +0000 (11:42 -0600)
committerEric Sandeen <sandeen@redhat.com>
Wed, 12 Dec 2018 17:42:40 +0000 (11:42 -0600)
Now that we have a symlink verifier which checks that in-memory
symlink names are null-terminated, be sure we do that when we
create them via the mkfs protofile.

We only want to null-terminate inline data if it's a symlink;
we only ever /call/ newfile() with "dolocal" for symlinks, so
rename that function argument for clarity.

Then, rather than open-coding all this, just call
xfs_init_local_fork which handles it properly.

Zorro found this by running xfs/019 on an s390x machine, it
failed with:

 Metadata corruption detected at 0x101214a, inode 0x89 data fork

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reported-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_api_defs.h
mkfs/proto.c

index ad5d65dea4dcba468422325d7f49379bdd1317b6..c3792e120e2474504e5df792ce2b5f4868fda279 100644 (file)
 #define xfs_dir_get_ops                        libxfs_dir_get_ops
 #define xfs_default_ifork_ops          libxfs_default_ifork_ops
 #define xfs_fs_geometry                        libxfs_fs_geometry
+#define xfs_init_local_fork            libxfs_init_local_fork
 
 #endif /* __LIBXFS_API_DEFS_H__ */
index 1cd5436b992cab8c8468e38ef5f86930d0d3e245..3bba49171983a0bc3475152083c71f4331a6cdd8 100644 (file)
@@ -15,7 +15,7 @@ static char *getstr(char **pp);
 static void fail(char *msg, int i);
 static struct xfs_trans * getres(struct xfs_mount *mp, uint blocks);
 static void rsvfile(xfs_mount_t *mp, xfs_inode_t *ip, long long len);
-static int newfile(xfs_trans_t *tp, xfs_inode_t *ip, int dolocal, int logit,
+static int newfile(xfs_trans_t *tp, xfs_inode_t *ip, int symlink, int logit,
                        char *buf, int len);
 static char *newregfile(char **pp, int *len);
 static void rtinit(xfs_mount_t *mp);
@@ -220,7 +220,7 @@ static int
 newfile(
        xfs_trans_t     *tp,
        xfs_inode_t     *ip,
-       int             dolocal,
+       int             symlink,
        int             logit,
        char            *buf,
        int             len)
@@ -236,13 +236,8 @@ newfile(
 
        flags = 0;
        mp = ip->i_mount;
-       if (dolocal && len <= XFS_IFORK_DSIZE(ip)) {
-               libxfs_idata_realloc(ip, len, XFS_DATA_FORK);
-               if (buf)
-                       memmove(ip->i_df.if_u1.if_data, buf, len);
-               ip->i_d.di_size = len;
-               ip->i_df.if_flags &= ~XFS_IFEXTENTS;
-               ip->i_df.if_flags |= XFS_IFINLINE;
+       if (symlink && len <= XFS_IFORK_DSIZE(ip)) {
+               libxfs_init_local_fork(ip, XFS_DATA_FORK, buf, len);
                ip->i_d.di_format = XFS_DINODE_FMT_LOCAL;
                flags = XFS_ILOG_DDATA;
        } else if (len > 0) {