Skip to content

Instantly share code, notes, and snippets.

View ice799's full-sized avatar

Joe Damato ice799

  • san francisco, ca
View GitHub Profile
@ice799
ice799 / igb-fix.patch
Created September 20, 2011 17:39
fix for igb bugs
commit 7def9e7f9b8738201677a9fa8d3f0bbe4c881b9a
Author: Joe Damato <joe@boundary.com>
Date: Tue Sep 20 17:32:20 2011 +0000
Fix for igb 2 second reporting bug and ioctl/stats race condition.
diff --git a/drivers/net/igb/igb.h b/drivers/net/igb/igb.h
index b1c1eb8..ce42798 100644
--- a/drivers/net/igb/igb.h
+++ b/drivers/net/igb/igb.h
@ice799
ice799 / future.c
Created August 11, 2011 01:15
the future you were waiting for
// Make an initial call to GetIfTable to get the
// necessary size into dwSize
dwSize = sizeof (MIB_IFTABLE);
if (GetIfTable(pIfTable, &dwSize, FALSE) == ERROR_INSUFFICIENT_BUFFER) {
FREE(pIfTable);
pIfTable = (MIB_IFTABLE *) MALLOC(dwSize);
if (pIfTable == NULL) {
printf("Error allocating memory needed to call GetIfTable\n");
return 1;
}
_______________________
< welcome to the future >
-----------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
On Thu, Jun 16, 2011 at 09:15, H.J. Lu <hjl.tools@gmail.com> wrote:
> On another platform, bad atexit implementation called from DSO caused
> weird run-time problems. The same problem can happen with glibc. The
> worse thing can happen with my patch is people will old compilers will
> get a link-time error, instead of strange run-time problems.
No. If there is no __dso_handle symbol the reference is NULL and
therefore atexit can work nicely when used in programs. It doesn't
work in DSOs but that was always the case before the introduction of
__dso_handle.
> I am trying to patch an executable with does not link to Lua (script library) yet includes the source. The function luaL_newstate is the
> one wanted, which is present in the mach-o and I can see the instruction address and the displacement to the function.
so you have a binary which does not link to lua_whatever.so ? ok...
> I have tried numerous methods of inserting the hook displacement for the displacement in the binary of interest. I would assume it requires
> using execve to run the binary of interest yet that will overwrite the address space of the patcher. I have tried fork -> ptrace
> PT_TRACE_ME execve and then trying dlsym(RTLD_DEFAULT, "luaL_newstate"); after a signal with the intention of overwriting memory with the
> hook. I tested this by not including the Lua lib in the patcher and it does not find the symbol.
0x48 0x89 0x5C 0x24 0xF0 0x48 0x89 0x6C 0x24 0xF8 0x48 0x83 0xEC 0x28 0x85 0xD2 0x48 0x89 0xFB 0x74 0x58 0x48 0x8B 0x7F 0x18 0x48 0x83 0xFF 0x04 0x74 0x19 0x48 0x8B 0x5C 0x24 0x18 0x48 0x8B 0x6C 0x24 0x20 0x89 0xD2 0x48 0x83 0xC4 0x28 0xE9 0x00 0x00 0x00 0x00 0xEB 0x02 0x90 0x90 0x89 0xD5 0x48 0x89 0x74 0x24 0x08 0x48 0x89 0xEF 0xE8 0x00 0x00 0x00 0x00 0x48 0x89 0x43 0x18 0xE8 0x00 0x00 0x00 0x00 0x48 0x8B 0x7B 0x18 0x48 0x8B 0x74 0x24 0x08 0x48 0x89 0xEA 0xE8 0x00 0x00 0x00 0x00 0x48 0x8B 0x43 0x18 0x48 0xC7 0x40 0x08 0x00 0x00 0x00 0x00 0x48 0x8B 0x5C 0x24 0x18 0x48 0x8B 0x6C 0x24 0x20 0x48 0x83 0xC4 0x28 0xC3 0xEB 0x02 0x90
// Returns number of bytes used, including *data.
int DisassemblerX64::JumpConditionalShort(byte* data) {
byte cond = *data & 0x0F;
byte b = *(data + 1);
byte* dest = data + static_cast<int8_t>(b) + 2;
const char* mnem = conditional_code_suffix[cond];
AppendToBuffer("j%s %s", mnem, NameOfAddress(dest));
return 2;
}
int pid = proc->pid;
int n, m;
int started = 0;
union {
long val;
char x[sizeof(long)];
} u;
if (addr & (sizeof(long) - 1)) {
/* addr not a multiple of sizeof(long) */
@ice799
ice799 / wat.sh
Created November 7, 2010 21:03
wat
is_gcc_m64() {
if test `echo $CFLAGS | grep "\-m64" -c` -eq 1 ; then echo ppc64;
else
if test `echo $CC | grep "\-m64" -c` -eq 1 ; then echo ppc64; else echo ppc32; fi;
fi;
}
#!/custom/ree/bin/ruby
require 'net/smtp'
class RaidWatcher
def self.send_alert msg
begin
domain = $config.email.domain,
host = $config.email.server,
port = $config.email.port,
from = "raid@#{$config.email.domain}"