C

共 58 篇文章。

一个不太明显的安全问题

• Security

在内核里面,程序的结构大概是这样:

函数开始……
struct bar foo;

某些处理(没动foo),然后……
strlcpy(foo.field, k->field, sizeof(k->field));

其他对foo其他字段的赋值处理……

最后
error = copyout(&foo, someaddress, sizeof(foo));

现在问题来了,上面这些东西的问题是什么?应该如何解决?

阅读全文… ( 本文约 219 字,阅读大致需要 1 分钟 )

BerkeleyDB使用中的cache同步问题

• Development

今天被一个程序折腾了很久。大致的流程是这样:

事件处理:

  • 打开db文件,如果已经打开,直接使用该handle
  • 获得排他锁,并读某一key对应的value
  • 根据value和一些环境信息以及事件所附带的输入计算新的value
  • 更新value,并同步文件、释放排他锁

锁的机制没有大毛病,可是数据死活不对。

阅读全文… ( 本文约 166 字,阅读大致需要 1 分钟 )

*BSD queue.h

• Kernel

Derived from the ancient BSD Unix, *BSD has a set of queue related macros which are described in queue(3), and implemented in src/sys/sys/queue.h. These are primarily used in the kernel, but also useful for userland applications.

阅读全文… ( 本文约 100 字,阅读大致需要 1 分钟 )

AMD64 string function optimizations

• Development

So time comes that we should consider whether some of our string operations is not optimial and needs some operation. NetBSD seems to have done a lot of good work to make their MD layer better, and we should take these improvements if they are proven.

David O’Brien has pointed out that we should be careful on this, however, since some micro optimizations may hinder performance in a large scenario. With this concern in mind, I will redo some more benchmarks and request for -arch@’s idea before considering commiting the patchset. Currently, the NetBSD implementation of swab(2) is proven to be slower than the GCC generated code by about 25%. I will look into the assembly code generated to see whether I can help to solve this.

阅读全文… ( 本文约 160 字,阅读大致需要 1 分钟 )

gcc 3.4.4 imported into FreeBSD base

• Development
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
kan         2005-06-03 03:29:21 UTC

  FreeBSD src repository

  src/contrib/gcc - Imported sources
  Update of /home/ncvs/src/contrib/gcc
  In directory repoman.freebsd.org:/tmp/cvs-serv9201

  Log Message:
  Gcc 3.4.4 release.

  Status:

  Vendor Tag:	FSF
  Release Tags:	gcc_3_4_4_20050518
参与评论

About integrating my WARNS=6 cleanups to FreeBSD tree

• Development

I started the work almost four months ago, but I have lost all my work last month. Therefore, I’m trying to integrate as much as possible whenever possible. The current workflow is:

  • Bump WARNS
  • Fix errors
  • Testdrive on almost all T1 platform I can touch
  • Commit
阅读全文… ( 本文约 105 字,阅读大致需要 1 分钟 )

About strict-aliasing optimization

• Development

What is strict aliasing? To make the long thing short, it means that the compiler apply strictest aliasing rules applicable to the language and having these assumptions the optimizer can do further optimizations.

To quote gcc manual:

阅读全文… ( 本文约 119 字,阅读大致需要 1 分钟 )