]> www.infradead.org Git - mtd-utils.git/commitdiff
ubifs-utils: libubifs: Update source files from linux kernel 6.13-rc7
authorZhihao Cheng <chengzhihao1@huawei.com>
Sun, 26 Jan 2025 06:42:03 +0000 (14:42 +0800)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Thu, 30 Jan 2025 17:30:17 +0000 (18:30 +0100)
Update source files from linux kernel 6.13-rc7 aa22f4da2a46.
Following changes since 6.8-rc2 41bccc98fb7931d63:
 1) 60f16e912a53a ("ubifs: fix sort function prototype")
 2) ec724e534dfdd ("ubifs: fix function pointer cast warnings")
 3) 39986148bc2ab ("ubifs: fix kernel-doc warnings")
 4) 94f5b1571ec8d ("ubifs: Convert to use ERR_CAST()")
 5) 4617fb8fc15ef ("ubifs: authentication: Fix use-after-free in
   ubifs_tnc_end_commit")

Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
ubifs-utils/libubifs/README
ubifs-utils/libubifs/find.c
ubifs-utils/libubifs/lpt.c
ubifs-utils/libubifs/lpt_commit.c
ubifs-utils/libubifs/replay.c
ubifs-utils/libubifs/tnc_commit.c

index 551ed8e62e371d62906c326c09ada37dd75a62d8..dd9322a81b2357ac9ea38be46f8258dc088e2cf0 100644 (file)
@@ -1,4 +1,4 @@
-UBIFS Library (Imported from linux kernel 6.8-rc2 41bccc98fb7931d63)
+UBIFS Library (Imported from linux kernel 6.13-rc7 aa22f4da2a46)
 
 * ubifs.h is a selection of definitions from fs/ubifs/ubifs.h from the linux kernel.
 * key.h is copied from fs/ubifs/key.h from the linux kernel.
index ecf689c44cf4f13ca0374b8ef4acf287cd74a3b9..364252ef79333c88082766b8b3225df198b44636 100644 (file)
@@ -80,7 +80,7 @@ static int valuable(struct ubifs_info *c, const struct ubifs_lprops *lprops)
  * @c: the UBIFS file-system description object
  * @lprops: LEB properties to scan
  * @in_tree: whether the LEB properties are in main memory
- * @data: information passed to and from the caller of the scan
+ * @arg: information passed to and from the caller of the scan
  *
  * This function returns a code that indicates whether the scan should continue
  * (%LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree
@@ -89,8 +89,9 @@ static int valuable(struct ubifs_info *c, const struct ubifs_lprops *lprops)
  */
 static int scan_for_dirty_cb(struct ubifs_info *c,
                             const struct ubifs_lprops *lprops, int in_tree,
-                            struct scan_data *data)
+                            void *arg)
 {
+       struct scan_data *data = arg;
        int ret = LPT_SCAN_CONTINUE;
 
        /* Exclude LEBs that are currently in use */
@@ -173,8 +174,7 @@ static const struct ubifs_lprops *scan_for_dirty(struct ubifs_info *c,
        data.pick_free = pick_free;
        data.lnum = -1;
        data.exclude_index = exclude_index;
-       err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum,
-                                   (ubifs_lpt_scan_callback)scan_for_dirty_cb,
+       err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, scan_for_dirty_cb,
                                    &data);
        if (err)
                return ERR_PTR(err);
@@ -347,7 +347,7 @@ out:
  * @c: the UBIFS file-system description object
  * @lprops: LEB properties to scan
  * @in_tree: whether the LEB properties are in main memory
- * @data: information passed to and from the caller of the scan
+ * @arg: information passed to and from the caller of the scan
  *
  * This function returns a code that indicates whether the scan should continue
  * (%LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree
@@ -356,8 +356,9 @@ out:
  */
 static int scan_for_free_cb(struct ubifs_info *c,
                            const struct ubifs_lprops *lprops, int in_tree,
-                           struct scan_data *data)
+                           void *arg)
 {
+       struct scan_data *data = arg;
        int ret = LPT_SCAN_CONTINUE;
 
        /* Exclude LEBs that are currently in use */
@@ -453,7 +454,7 @@ const struct ubifs_lprops *do_find_free_space(struct ubifs_info *c,
        data.pick_free = pick_free;
        data.lnum = -1;
        err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum,
-                                   (ubifs_lpt_scan_callback)scan_for_free_cb,
+                                   scan_for_free_cb,
                                    &data);
        if (err)
                return ERR_PTR(err);
@@ -587,7 +588,7 @@ out:
  * @c: the UBIFS file-system description object
  * @lprops: LEB properties to scan
  * @in_tree: whether the LEB properties are in main memory
- * @data: information passed to and from the caller of the scan
+ * @arg: information passed to and from the caller of the scan
  *
  * This function returns a code that indicates whether the scan should continue
  * (%LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree
@@ -596,8 +597,9 @@ out:
  */
 static int scan_for_idx_cb(struct ubifs_info *c,
                           const struct ubifs_lprops *lprops, int in_tree,
-                          struct scan_data *data)
+                          void *arg)
 {
+       struct scan_data *data = arg;
        int ret = LPT_SCAN_CONTINUE;
 
        /* Exclude LEBs that are currently in use */
@@ -632,8 +634,7 @@ static const struct ubifs_lprops *scan_for_leb_for_idx(struct ubifs_info *c)
        int err;
 
        data.lnum = -1;
-       err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum,
-                                   (ubifs_lpt_scan_callback)scan_for_idx_cb,
+       err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, scan_for_idx_cb,
                                    &data);
        if (err)
                return ERR_PTR(err);
@@ -733,11 +734,10 @@ out:
        return err;
 }
 
-static int cmp_dirty_idx(const struct ubifs_lprops **a,
-                        const struct ubifs_lprops **b)
+static int cmp_dirty_idx(const void *a, const void *b)
 {
-       const struct ubifs_lprops *lpa = *a;
-       const struct ubifs_lprops *lpb = *b;
+       const struct ubifs_lprops *lpa = *(const struct ubifs_lprops **)a;
+       const struct ubifs_lprops *lpb = *(const struct ubifs_lprops **)b;
 
        return lpa->dirty + lpa->free - lpb->dirty - lpb->free;
 }
@@ -761,7 +761,7 @@ int ubifs_save_dirty_idx_lnums(struct ubifs_info *c)
               sizeof(void *) * c->dirty_idx.cnt);
        /* Sort it so that the dirtiest is now at the end */
        sort(c->dirty_idx.arr, c->dirty_idx.cnt, sizeof(void *),
-            (int (*)(const void *, const void *))cmp_dirty_idx, NULL);
+            cmp_dirty_idx, NULL);
        dbg_find("found %d dirty index LEBs", c->dirty_idx.cnt);
        if (c->dirty_idx.cnt)
                dbg_find("dirtiest index LEB is %d with dirty %d and free %d",
@@ -780,7 +780,7 @@ int ubifs_save_dirty_idx_lnums(struct ubifs_info *c)
  * @c: the UBIFS file-system description object
  * @lprops: LEB properties to scan
  * @in_tree: whether the LEB properties are in main memory
- * @data: information passed to and from the caller of the scan
+ * @arg: information passed to and from the caller of the scan
  *
  * This function returns a code that indicates whether the scan should continue
  * (%LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree
@@ -789,8 +789,9 @@ int ubifs_save_dirty_idx_lnums(struct ubifs_info *c)
  */
 static int scan_dirty_idx_cb(struct ubifs_info *c,
                           const struct ubifs_lprops *lprops, int in_tree,
-                          struct scan_data *data)
+                          void *arg)
 {
+       struct scan_data *data = arg;
        int ret = LPT_SCAN_CONTINUE;
 
        /* Exclude LEBs that are currently in use */
@@ -849,8 +850,7 @@ static int find_dirty_idx_leb(struct ubifs_info *c)
        if (c->pnodes_have >= c->pnode_cnt)
                /* All pnodes are in memory, so skip scan */
                return -ENOSPC;
-       err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum,
-                                   (ubifs_lpt_scan_callback)scan_dirty_idx_cb,
+       err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, scan_dirty_idx_cb,
                                    &data);
        if (err)
                return err;
index 8e20a173e8ae838e8c1737d856b11ea7aa76ba35..f2f272756d4690277a3424c445d660755131650e 100644 (file)
@@ -2009,6 +2009,7 @@ out_err:
  * @pnode: where to keep a pnode
  * @cnode: where to keep a cnode
  * @in_tree: is the node in the tree in memory
+ * @ptr: union of node pointers
  * @ptr.nnode: pointer to the nnode (if it is an nnode) which may be here or in
  * the tree
  * @ptr.pnode: ditto for pnode
index ee84f8019b7a30f27e40e39045743f72e6b4bb87..79f7b143e0ccdb59b73ae1c1be16454543c2068e 100644 (file)
@@ -580,7 +580,7 @@ struct ubifs_pnode *ubifs_find_next_pnode(struct ubifs_info *c,
        /* Go right */
        nnode = ubifs_get_nnode(c, nnode, iip);
        if (IS_ERR(nnode))
-               return (void *)nnode;
+               return ERR_CAST(nnode);
 
        /* Go down to level 1 */
        while (nnode->level > 1) {
@@ -597,7 +597,7 @@ struct ubifs_pnode *ubifs_find_next_pnode(struct ubifs_info *c,
                }
                nnode = ubifs_get_nnode(c, nnode, iip);
                if (IS_ERR(nnode))
-                       return (void *)nnode;
+                       return ERR_CAST(nnode);
        }
 
        for (iip = 0; iip < UBIFS_LPT_FANOUT; iip++)
index 3943b32d2e6a0acd91f0f3089ad0a21508329761..9d61133ad9d42a253455719813490bc95d211333 100644 (file)
@@ -34,6 +34,7 @@
  * @lnum: logical eraseblock number of the node
  * @offs: node offset
  * @len: node length
+ * @hash: node hash
  * @deletion: non-zero if this entry corresponds to a node deletion
  * @sqnum: node sequence number
  * @list: links the replay list
index d797006ee406ffa5b8841d9ffd3ee3605e1ddd4b..66922d4f41a64463019788f68b5f385e88851122 100644 (file)
@@ -663,6 +663,8 @@ static int get_znodes_to_commit(struct ubifs_info *c)
                znode->alt = 0;
                cnext = find_next_dirty(znode);
                if (!cnext) {
+                       ubifs_assert(c, !znode->parent);
+                       znode->cparent = NULL;
                        znode->cnext = c->cnext;
                        break;
                }