Commit d88e8b67 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'jfs-5.12' of git://github.com/kleikamp/linux-shaggy

Pull jfs updates from David Kleikamp:
 "A few jfs fixes"

* tag 'jfs-5.12' of git://github.com/kleikamp/linux-shaggy:
  fs/jfs: fix potential integer overflow on shift of a int
  jfs: turn diLog(), dataLog() and txLog() into void functions
  JFS: more checks for invalid superblock
parents 961a9b51 4208c398
...@@ -1656,7 +1656,7 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen) ...@@ -1656,7 +1656,7 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen)
} else if (rc == -ENOSPC) { } else if (rc == -ENOSPC) {
/* search for next smaller log2 block */ /* search for next smaller log2 block */
l2nb = BLKSTOL2(nblocks) - 1; l2nb = BLKSTOL2(nblocks) - 1;
nblocks = 1 << l2nb; nblocks = 1LL << l2nb;
} else { } else {
/* Trim any already allocated blocks */ /* Trim any already allocated blocks */
jfs_error(bmp->db_ipbmap->i_sb, "-EIO\n"); jfs_error(bmp->db_ipbmap->i_sb, "-EIO\n");
......
...@@ -268,5 +268,6 @@ ...@@ -268,5 +268,6 @@
* fsck() must be run to repair * fsck() must be run to repair
*/ */
#define FM_EXTENDFS 0x00000008 /* file system extendfs() in progress */ #define FM_EXTENDFS 0x00000008 /* file system extendfs() in progress */
#define FM_STATE_MAX 0x0000000f /* max value of s_state */
#endif /* _H_JFS_FILSYS */ #endif /* _H_JFS_FILSYS */
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/log2.h>
#include "jfs_incore.h" #include "jfs_incore.h"
#include "jfs_filsys.h" #include "jfs_filsys.h"
...@@ -366,6 +367,15 @@ static int chkSuper(struct super_block *sb) ...@@ -366,6 +367,15 @@ static int chkSuper(struct super_block *sb)
sbi->bsize = bsize; sbi->bsize = bsize;
sbi->l2bsize = le16_to_cpu(j_sb->s_l2bsize); sbi->l2bsize = le16_to_cpu(j_sb->s_l2bsize);
/* check some fields for possible corruption */
if (sbi->l2bsize != ilog2((u32)bsize) ||
j_sb->pad != 0 ||
le32_to_cpu(j_sb->s_state) > FM_STATE_MAX) {
rc = -EINVAL;
jfs_err("jfs_mount: Mount Failure: superblock is corrupt!");
goto out;
}
/* /*
* For now, ignore s_pbsize, l2bfactor. All I/O going through buffer * For now, ignore s_pbsize, l2bfactor. All I/O going through buffer
* cache. * cache.
......
...@@ -148,10 +148,10 @@ static struct { ...@@ -148,10 +148,10 @@ static struct {
/* /*
* forward references * forward references
*/ */
static int diLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, static void diLog(struct jfs_log *log, struct tblock *tblk, struct lrd *lrd,
struct tlock * tlck, struct commit * cd); struct tlock *tlck, struct commit *cd);
static int dataLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, static void dataLog(struct jfs_log *log, struct tblock *tblk, struct lrd *lrd,
struct tlock * tlck); struct tlock *tlck);
static void dtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, static void dtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
struct tlock * tlck); struct tlock * tlck);
static void mapLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, static void mapLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
...@@ -159,8 +159,8 @@ static void mapLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, ...@@ -159,8 +159,8 @@ static void mapLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
static void txAllocPMap(struct inode *ip, struct maplock * maplock, static void txAllocPMap(struct inode *ip, struct maplock * maplock,
struct tblock * tblk); struct tblock * tblk);
static void txForce(struct tblock * tblk); static void txForce(struct tblock * tblk);
static int txLog(struct jfs_log * log, struct tblock * tblk, static void txLog(struct jfs_log *log, struct tblock *tblk,
struct commit * cd); struct commit *cd);
static void txUpdateMap(struct tblock * tblk); static void txUpdateMap(struct tblock * tblk);
static void txRelease(struct tblock * tblk); static void txRelease(struct tblock * tblk);
static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
...@@ -1256,8 +1256,7 @@ int txCommit(tid_t tid, /* transaction identifier */ ...@@ -1256,8 +1256,7 @@ int txCommit(tid_t tid, /* transaction identifier */
* *
* txUpdateMap() resets XAD_NEW in XAD. * txUpdateMap() resets XAD_NEW in XAD.
*/ */
if ((rc = txLog(log, tblk, &cd))) txLog(log, tblk, &cd);
goto TheEnd;
/* /*
* Ensure that inode isn't reused before * Ensure that inode isn't reused before
...@@ -1365,9 +1364,8 @@ int txCommit(tid_t tid, /* transaction identifier */ ...@@ -1365,9 +1364,8 @@ int txCommit(tid_t tid, /* transaction identifier */
* *
* RETURN : * RETURN :
*/ */
static int txLog(struct jfs_log * log, struct tblock * tblk, struct commit * cd) static void txLog(struct jfs_log *log, struct tblock *tblk, struct commit *cd)
{ {
int rc = 0;
struct inode *ip; struct inode *ip;
lid_t lid; lid_t lid;
struct tlock *tlck; struct tlock *tlck;
...@@ -1414,7 +1412,7 @@ static int txLog(struct jfs_log * log, struct tblock * tblk, struct commit * cd) ...@@ -1414,7 +1412,7 @@ static int txLog(struct jfs_log * log, struct tblock * tblk, struct commit * cd)
} }
} }
return rc; return;
} }
/* /*
...@@ -1422,10 +1420,9 @@ static int txLog(struct jfs_log * log, struct tblock * tblk, struct commit * cd) ...@@ -1422,10 +1420,9 @@ static int txLog(struct jfs_log * log, struct tblock * tblk, struct commit * cd)
* *
* function: log inode tlock and format maplock to update bmap; * function: log inode tlock and format maplock to update bmap;
*/ */
static int diLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, static void diLog(struct jfs_log *log, struct tblock *tblk, struct lrd *lrd,
struct tlock * tlck, struct commit * cd) struct tlock *tlck, struct commit *cd)
{ {
int rc = 0;
struct metapage *mp; struct metapage *mp;
pxd_t *pxd; pxd_t *pxd;
struct pxd_lock *pxdlock; struct pxd_lock *pxdlock;
...@@ -1527,7 +1524,7 @@ static int diLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, ...@@ -1527,7 +1524,7 @@ static int diLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
} }
#endif /* _JFS_WIP */ #endif /* _JFS_WIP */
return rc; return;
} }
/* /*
...@@ -1535,8 +1532,8 @@ static int diLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, ...@@ -1535,8 +1532,8 @@ static int diLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
* *
* function: log data tlock * function: log data tlock
*/ */
static int dataLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, static void dataLog(struct jfs_log *log, struct tblock *tblk, struct lrd *lrd,
struct tlock * tlck) struct tlock *tlck)
{ {
struct metapage *mp; struct metapage *mp;
pxd_t *pxd; pxd_t *pxd;
...@@ -1562,7 +1559,7 @@ static int dataLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, ...@@ -1562,7 +1559,7 @@ static int dataLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
metapage_homeok(mp); metapage_homeok(mp);
discard_metapage(mp); discard_metapage(mp);
tlck->mp = NULL; tlck->mp = NULL;
return 0; return;
} }
PXDaddress(pxd, mp->index); PXDaddress(pxd, mp->index);
...@@ -1573,7 +1570,7 @@ static int dataLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, ...@@ -1573,7 +1570,7 @@ static int dataLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd,
/* mark page as homeward bound */ /* mark page as homeward bound */
tlck->flag |= tlckWRITEPAGE; tlck->flag |= tlckWRITEPAGE;
return 0; return;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment