免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: sisi8408
打印 上一主题 下一主题

Kernel Bug-Vulnerability-Comment library [复制链接]

论坛徽章:
0
31 [报告]
发表于 2007-08-24 09:41 |只看该作者

  1. int ocfs2_node_map_iterate(struct ocfs2_super *osb,
  2.                            struct ocfs2_node_map *map,
  3.                            int idx)
  4. {
  5.         int i = idx;

  6.         idx = O2NM_INVALID_NODE_NUM;
  7.         spin_lock(&osb->node_map_lock);
  8.         if ((i != O2NM_INVALID_NODE_NUM) &&
  9.             (i >= 0) &&
  10.             (i < map->num_nodes)) {
  11.             /*
  12.          * linux-2.6.20.7/fs/ocfs2/heartbeat.c
  13.          *
  14.          * ¥1
  15.          *
  16.          * oversight bitops of arch version by linux
  17.              */
  18.                 while (i < map->num_nodes) {
  19.                         if (test_bit(i, map->map)) {
  20.                                 idx = i;
  21.                                 break;
  22.                         }
  23.                         i++;
  24.                 }
  25.         }
  26.         spin_unlock(&osb->node_map_lock);
  27.         return idx;
  28. }
复制代码

论坛徽章:
0
32 [报告]
发表于 2007-08-24 09:45 |只看该作者

  1. int vfs_rmdir(struct inode *dir, struct dentry *dentry)
  2. {
  3.         int error = may_delete(dir, dentry, 1);

  4.         if (error)
  5.                 return error;

  6.         if (!dir->i_op || !dir->i_op->rmdir)
  7.                 return -EPERM;

  8.         DQUOT_INIT(dir);

  9.         mutex_lock(&dentry->d_inode->i_mutex);
  10.         dentry_unhash(dentry);
  11.         if (d_mountpoint(dentry))
  12.                 error = -EBUSY;
  13.         else {
  14.                 error = security_inode_rmdir(dir, dentry);
  15.                 if (!error) {
  16.                         error = dir->i_op->rmdir(dir, dentry);
  17.                         if (!error)
  18.                                 dentry->d_inode->i_flags |= S_DEAD;
  19.                 }
  20.         }
  21.         mutex_unlock(&dentry->d_inode->i_mutex);
  22.         if (!error) {

  23. /*
  24. * linux-2.6.20.7/fs/namei.c
  25. *
  26. * potentially trigger-1
  27. */
  28.                 d_delete(dentry);
  29.         }
  30.         dput(dentry);

  31.         return error;
  32. }
复制代码

  1. void d_delete(struct dentry * dentry)
  2. {
  3.         int isdir = 0;
  4.         /*
  5.          * Are we the only user?
  6.          */
  7.         spin_lock(&dcache_lock);
  8.         spin_lock(&dentry->d_lock);
  9.         isdir = S_ISDIR(dentry->d_inode->i_mode);
  10.        
  11.         if (atomic_read(&dentry->d_count) == 1) {
  12.                 dentry_iput(dentry);
  13.                 fsnotify_nameremove(dentry, isdir);

  14.                 /* remove this and other inotify debug checks after 2.6.18 */
  15.                 dentry->d_flags &= ~DCACHE_INOTIFY_PARENT_WATCHED;

  16. /*
  17. * linux-2.6.20.7/fs/dcache.c
  18. *
  19. * potentially trigger-2
  20. */
  21.                 return;
  22.         }

  23.         if (!d_unhashed(dentry))
  24.                 __d_drop(dentry);

  25.         spin_unlock(&dentry->d_lock);
  26.         spin_unlock(&dcache_lock);

  27.         fsnotify_nameremove(dentry, isdir);
  28. }
复制代码

  1. void dput(struct dentry *dentry)
  2. {
  3.         if (!dentry)
  4.                 return;

  5. repeat:
  6.         if (atomic_read(&dentry->d_count) == 1)
  7.                 might_sleep();
  8.        
  9.         if (!atomic_dec_and_lock(&dentry->d_count, &dcache_lock))
  10.                 return;

  11. /*
  12. * linux-2.6.20.7/fs/dcache.c
  13. *
  14. * ¥6
  15. * potentially race @ here
  16. */
  17.         spin_lock(&dentry->d_lock);
  18.        
  19.         if (atomic_read(&dentry->d_count)) {
  20.                 spin_unlock(&dentry->d_lock);
  21.                 spin_unlock(&dcache_lock);
  22.                 return;
  23.         }

  24.         /*
  25.          * AV: ->d_delete() is _NOT_ allowed to block now.
  26.          */
  27.         if (dentry->d_op && dentry->d_op->d_delete) {
  28.                 if (dentry->d_op->d_delete(dentry))
  29.                         goto unhash_it;
  30.         }

  31.         /* Unreachable? Get rid of it */
  32.         if (d_unhashed(dentry))
  33.                 goto kill_it;
  34.        
  35.         if (list_empty(&dentry->d_lru)) {
  36.                   dentry->d_flags |= DCACHE_REFERENCED;
  37.                   list_add(&dentry->d_lru, &dentry_unused);
  38.                   dentry_stat.nr_unused++;
  39.           }
  40.         spin_unlock(&dentry->d_lock);
  41.         spin_unlock(&dcache_lock);
  42.         return;

  43. unhash_it:
  44.         __d_drop(dentry);

  45. kill_it: {
  46.                 struct dentry *parent;

  47.                 /* If dentry was on d_lru list,
  48.                  * delete it from there
  49.                  */
  50.                   if (!list_empty(&dentry->d_lru)) {
  51.                           list_del(&dentry->d_lru);
  52.                           dentry_stat.nr_unused--;
  53.                   }
  54.                   list_del(&dentry->d_u.d_child);
  55.                 dentry_stat.nr_dentry--;        /* For d_free, below */
  56.                
  57.                 /* drops the locks,
  58.                  * at that point nobody can reach this dentry
  59.                  */
  60.                 dentry_iput(dentry);
  61.                
  62.                 parent = dentry->d_parent;
  63.                 d_free(dentry);
  64.                
  65.                 if (dentry == parent)
  66.                         return;
  67.                 dentry = parent;
  68.                 goto repeat;
  69.         }
  70. }
复制代码

论坛徽章:
0
33 [报告]
发表于 2007-08-24 10:45 |只看该作者
你说的问题(BUG)怎么存在了?请详细解释好吗。


  1. void dput(struct dentry *dentry)
  2. {
  3.         if (!dentry)
  4.                 return;

  5. repeat:
  6.         if (atomic_read(&dentry->d_count) == 1)
  7.                 might_sleep();
  8.       
  9.         if (!atomic_dec_and_lock(&dentry->d_count, &dcache_lock))
  10.                 return;

  11. /*
  12. * linux-2.6.20.7/fs/dcache.c
  13. *
  14. * ¥6
  15. * potentially race @ here
  16. */
  17.         spin_lock(&dentry->d_lock);
  18.       
  19.         if (atomic_read(&dentry->d_count)) {
  20.                 spin_unlock(&dentry->d_lock);
  21.                 spin_unlock(&dcache_lock);
  22.                 return;
  23.         }

  24.         /*
  25.          * AV: ->d_delete() is _NOT_ allowed to block now.
  26.          */
  27.         if (dentry->d_op && dentry->d_op->d_delete) {
  28.                 if (dentry->d_op->d_delete(dentry))
  29.                         goto unhash_it;
  30.         }

  31.         /* Unreachable? Get rid of it */
  32.         if (d_unhashed(dentry))
  33.                 goto kill_it;
  34.       
  35.         if (list_empty(&dentry->d_lru)) {
  36.                   dentry->d_flags |= DCACHE_REFERENCED;
  37.                   list_add(&dentry->d_lru, &dentry_unused);
  38.                   dentry_stat.nr_unused++;
  39.           }
  40.         spin_unlock(&dentry->d_lock);
  41.         spin_unlock(&dcache_lock);
  42.         return;

  43. unhash_it:
  44.         __d_drop(dentry);

  45. kill_it: {
  46.                 struct dentry *parent;

  47.                 /* If dentry was on d_lru list,
  48.                  * delete it from there
  49.                  */
  50.                   if (!list_empty(&dentry->d_lru)) {
  51.                           list_del(&dentry->d_lru);
  52.                           dentry_stat.nr_unused--;
  53.                   }
  54.                   list_del(&dentry->d_u.d_child);
  55.                 dentry_stat.nr_dentry--;        /* For d_free, below */
  56.                
  57.                 /* drops the locks,
  58.                  * at that point nobody can reach this dentry
  59.                  */
  60.                 dentry_iput(dentry);
  61.                
  62.                 parent = dentry->d_parent;
  63.                 d_free(dentry);
  64.                
  65.                 if (dentry == parent)
  66.                         return;
  67.                 dentry = parent;
  68.                 goto repeat;
  69.         }
  70. }
复制代码

论坛徽章:
0
34 [报告]
发表于 2007-08-24 11:22 |只看该作者

回复 #33 思一克 的帖子


  1.         if (!error) {
  2.                 d_delete(dentry);
  3. /*
  4. *  d_delete return potentially without releasing dcache_lock & dentry->d_lock
  5. */
  6.         }
  7. /*
  8. * however dput at least try to get dentry->d_lock
  9. */
  10.         dput(dentry);


  11. /*
  12. * yeah, these codes used everyday after bootstrap,
  13. * why not heard bloat???
  14. */
复制代码

论坛徽章:
0
35 [报告]
发表于 2007-08-24 11:46 |只看该作者
你怎么知道d_delete return potentially without releasing dcache_lock & dentry->d_lock?

我看的是2。6。13版本。和你的应该差不多。

原帖由 sisi8408 于 2007-8-24 11:22 发表

        if (!error) {
                d_delete(dentry);
/*
*  d_delete return potentially without releasing dcache_lock & dentry->d_lock
*/
        }
/*
* however dput at least try to ...

论坛徽章:
0
36 [报告]
发表于 2007-08-24 11:57 |只看该作者
我觉得你提出的BUG中的大多数都是不存在的。尤其是在各版本都稳定了的代码中。


原帖由 思一克 于 2007-8-24 11:46 发表
你怎么知道d_delete return potentially without releasing dcache_lock & dentry->d_lock?

我看的是2。6。13版本。和你的应该差不多。

论坛徽章:
0
37 [报告]
发表于 2007-08-24 12:56 |只看该作者
天太热,BUG可能躲荫了。
喝杯清茶,回头再看,随手写来,表达个想法,不必当真,呵呵。

论坛徽章:
0
38 [报告]
发表于 2007-08-24 13:00 |只看该作者
没有当真。

d_delete中的dentry_iput()会spin_unlock ( ... d_lock)的。

还有,我说的是在版本稳定的代码中不大可能有你说的BUG。但是在驱动中,htimer中你你说的可能是有的。我的6.2.13中没有你贴出的那部分代码,所以没有法看。driver中的我又不懂。

原帖由 sisi8408 于 2007-8-24 12:56 发表
天太热,BUG可能躲荫了。
喝杯清茶,回头再看,随手写来,表达个想法,不必当真,呵呵。

论坛徽章:
0
39 [报告]
发表于 2007-08-24 13:11 |只看该作者
如果skipjack用的版本疮上了,这里提个醒,不算太罗唆。

哪个版本稳定呐?不好说,看的人多一点,可能稍好吧。

BUG,俺叫他八哥,一种好听的鸟,养着乐的。

论坛徽章:
0
40 [报告]
发表于 2007-08-24 13:22 |只看该作者
现在都到2。6。2X了,那么2.6.1X的就是稳定的。
还有,许多内河代码(函数)在版本升级后并没有变化。这部分也是稳定的。要找出其中的BUG是很难的。否则系统就不会运行的那样稳定可靠了。

驱动中BUG应该多些。

原帖由 sisi8408 于 2007-8-24 13:11 发表
如果skipjack用的版本疮上了,这里提个醒,不算太罗唆。

哪个版本稳定呐?不好说,看的人多一点,可能稍好吧。

BUG,俺叫他八哥,一种好听的鸟,养着乐的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP