what is the meaning of 0xdead000000000000?

前端 未结 1 864
灰色年华
灰色年华 2021-02-10 12:26

This value was appeared in the poison.h (linux source\\include\\linux\\poison.h):

/*
 * Architectures might want to move the poison pointer offset
 * into some w         


        
1条回答
  •  灰色年华
    2021-02-10 13:02

    Pretty sure this is just a variant of deadbeef; i.e. it's just an easily identified signal value (see http://en.wikipedia.org/wiki/Hexspeak for deadbeef)

    The idea of pointer poisoning is to ensure that a poisoned list pointer can't be used without causing a crash. Say you unlink a structure from the list it was in. You then want to invalidate the pointer value to make sure it's not used again for traversing the list. If there's a bug somewhere in the code -- a dangling pointer reference -- you want to make sure that any code trying to follow the list through this now-unlinked node crashes immediately (rather than later in some possibly unrelated area of code).

    Of course you can poison the pointer simply by putting a null value in it or any other invalid address. Using 0xdead000000000000 as the base value just makes it easier to distinguish an explicitly poisoned value from one that was initialized with zero or got overwritten with zeroes. And it can be used with an offset (LIST_POISON{1,2}) to create multiple distinct poison values that all point into unusable areas of the virtual address space and are identifiable as invalid at a glance.

    0 讨论(0)
提交回复
热议问题