Not logged in
Log in now
Create an account
Subscribe to LWN
LWN.net Weekly Edition for May 16, 2013
A look at the PyPy 2.0 release
PostgreSQL 9.3 beta: Federated databases and more
LWN.net Weekly Edition for May 9, 2013
(Nearly) full tickless operation in 3.10
This is not correct. You want
> fd = open(av, O_RDWR, 0777)
Yes, it's an octal constant. Or use the symbolic constants.
Also, this is more of a personal preference thing, but bumpyCaps and hungarian notation are frowned on by most.
In a larger sense, I think you don't want to rebuild glibc. You probably just want to use "the LD_PRELOAD trick"
If I were you, I would print my nastygrams to syslog, using the syslog(3) function. Most sysadmins don't check random areas of shared memory that often. If you do choose to use shm, try shm_open.
Glibc change exposing bugs
Posted Nov 12, 2010 9:09 UTC (Fri) by dafid_b (guest, #67424)
Is syslog() safe to call at this point?
It generates formatted output, which seems like it could itself call memcpy() or do other stuff in te library that the app did not allow for in its plan when it called memcpy.
Also is the system call that sends the message to the log safe, or can it have side effect such as signals and new error codes in errno?
I would be very happy if the answer to the above is: syslog() safe to call like this with no side-effects.
Posted Nov 13, 2010 3:02 UTC (Sat) by cmccabe (guest, #60281)
You raise a good issue. glibc's version of syslog is known to call malloc sometimes, which means that you shouldn't use it from within a signal handler. Surprisingly, memcpy isn't on the official list of "async-signal safe" functions, so you could argue that such an implementation would be POSIX conforming :)
But seriously. I think the best thing to do is probably implement your own version of syslog with no memory allocations or calls to memcpy. It's pretty easy to do in a few hundred lines. I had to do it before when writing a good signal handler.
Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds