Skip to contentSkip to conversation

potential argument order bug in fs/xfs/xfs_dir2_node.c:xfs_dir2_leafn_unbalance

DISCUSSION Dave Jones 2 participants 3 messages Sep 5, 2013

lore
Share & tools
lore

Dave Jones

author
#0 lore raw

I'm picking through some of the bugs in coverity's database, and I came across this one, which I'm unsure of..

In xfs_dir2_leafn_unbalance we have this code..

1583 if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp))
1584 xfs_dir3_leafn_moveents(args, drop_blk->bp, &drophdr, dents, 0,
1585 save_blk->bp, &savehdr, sents, 0,
1586 drophdr.count);
1587 else
1588 xfs_dir3_leafn_moveents(args, drop_blk->bp, &drophdr, dents, 0,
1589 save_blk->bp, &savehdr, sents,
1590 savehdr.count, drophdr.count);

The issue that coverity picked up in both cases, is that 'sents' and 'dents' are in a different order to how the xfs_dir3_leafn_moveents function expects them.

Is this intentional ? If so I'll mark it as such in their db.

thanks,

Dave

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw
Quoted 14 lines · Dave Jones

I'm picking through some of the bugs in coverity's database, and I came across this one, which I'm unsure of..

In xfs_dir2_leafn_unbalance we have this code..

1583 if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp))
1584 xfs_dir3_leafn_moveents(args, drop_blk->bp, &drophdr, dents, 0,
1585 save_blk->bp, &savehdr, sents, 0,
1586 drophdr.count);
1587 else
1588 xfs_dir3_leafn_moveents(args, drop_blk->bp, &drophdr, dents, 0,
1589 save_blk->bp, &savehdr, sents,
1590 savehdr.count, drophdr.count);

Quoted 2 lines

The issue that coverity picked up in both cases, is that 'sents' and 'dents' are in a different order to how the xfs_dir3_leafn_moveents function expects them.

What does "order" mean to coverity? Is it really complaining about function parameters being ordered (src, dst) rather than (dst, src)? Or is it detecting that we are passing parameters names (dxxx, sxxx) into a function that declares those parameters (syyy, dyyy) and it throws based on that?

In more detail, the function prototype is effectively xfs_dir3_leafn_moveents(source, destination, count), and so in both cases here objects are being moved from the block being dropped (freed) to the block being saved (merged block).

What the xfs_dir2_leafn_order() call tells us is whether the objects in the drop block get inserted into the save block before or after the objects in the save block. i.e. if we are merging from the left or right sibling....

So I don't see that there's a problem here.

Quoted 1 line

Is this intentional ? If so I'll mark it as such in their db.

The code looks fine to me...

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
author
#2 lore raw
Quoted 15 lines · Dave Chinner
Quoted 14 lines · Dave Jones

I'm picking through some of the bugs in coverity's database, and I came across this one, which I'm unsure of..

In xfs_dir2_leafn_unbalance we have this code..

1583 if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp))
1584 xfs_dir3_leafn_moveents(args, drop_blk->bp, &drophdr, dents, 0,
1585 save_blk->bp, &savehdr, sents, 0,
1586 drophdr.count);
1587 else
1588 xfs_dir3_leafn_moveents(args, drop_blk->bp, &drophdr, dents, 0,
1589 save_blk->bp, &savehdr, sents,
1590 savehdr.count, drophdr.count);

Quoted 8 lines
Quoted 2 lines

The issue that coverity picked up in both cases, is that 'sents' and 'dents' are in a different order to how the xfs_dir3_leafn_moveents function expects them.

What does "order" mean to coverity? Is it really complaining about function parameters being ordered (src, dst) rather than (dst, src)? Or is it detecting that we are passing parameters names (dxxx, sxxx) into a function that declares those parameters (syyy, dyyy) and it throws based on that?

Yeah, the latter. It's done it to quite a few parts of the kernel. In most cases I've looked through so far, it's not a problem, but there have been 1-2 real bugs.

Quoted 4 lines

In more detail, the function prototype is effectively xfs_dir3_leafn_moveents(source, destination, count), and so in both cases here objects are being moved from the block being dropped (freed) to the block being saved (merged block).

Ok, thanks for looking it over anyway.
I've marked it as being intentional in their db, so it shouldn't show up in future.

Dave

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs