summaryrefslogtreecommitdiffstats
path: root/Documentation/magic-number.txt
blob: ca5c3e20c62ede38b494bc6b7d15c1b6d0b2b033 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
This file is a registry of magic numbers which are in use.  When you
add a magic number to a structure, you should also add it to this
file, since it is best if the magic numbers used by various structures
are unique.

It is a *very* good idea to protect kernel data structures with magic
numbers.  This allows you to check at run time whether (a) a structure
has been clobbered, or (b) you've passed the wrong structure to a
routine.  This last is especially useful --- particularly when you are
passing pointers to structures via a void * pointer.  The tty code,
for example, does this frequently to pass driver-specific and line
discipline-specific structures back and forth.

The way to use magic numbers is to declare then at the beginning of
the structure, like so:

struct tty_ldisc {
	int	magic;
	...
};

Please follow this discipline when you are adding future enhancements
to the kernel!  It has saved me countless hours of debugging,
especially in the screwy cases where an array has been overrun and
structures following the array have been overwritten.  Using this
discipline, these cases get detected quickly and safely.

					Theodore Ts'o
					31-Mar-94

The magic table is current to Linux 2.1.55.

					Michael Chastain
					<mailto:mec@shout.net>
					22 Sep 1997



Magic Name          Number      Structure            File
===========================================================================

MKISS_DRIVER_MAGIC    0x04bf      mkiss_channel     drivers/net/mkiss.h
RISCOM8_MAGIC         0x0907      riscom_port       drivers/char/riscom8.h
APM_BIOS_MAGIC        0x4101      apm_bios_struct   include/linux/apm_bios.h
CYCLADES_MAGIC        0x4359      cyclades_port     include/linux/cyclades.h
FASYNC_MAGIC          0x4601      fasync_struct     include/linux/fs.h
PPP_MAGIC             0x5002      ppp               include/linux/if_ppp.h
SERIAL_MAGIC          0x5301      async_struct      include/linux/serial.h
SSTATE_MAGIC          0x5302      serial_state      include/linux/serial.h
SLIP_MAGIC            0x5302      slip              drivers/net/slip.h
STRIP_MAGIC           0x5303      strip             drivers/net/strip.c
X25_ASY_MAGIC         0x5303      x25_asy           drivers/net/x25_asy.h
AX25_MAGIC            0x5316      ax_disp           drivers/net/mkiss.h
ESP_MAGIC             0x53ee      esp_struct        drivers/char/esp.h
TTY_MAGIC             0x5401      tty_struct        include/linux/tty.h
TTY_DRIVER_MAGIC      0x5402      tty_driver        include/linux/tty_driver.h
TTY_LDISC_MAGIC       0x5403      tty_ldisc         include/linux/tty_ldisc.h
SCC_MAGIC             0x8530      scc_channel       include/linux/scc.h
RPORT_MAGIC           0x525001    r_port            drivers/char/rocket_int.h
SLAB_C_MAGIC          0x4f17a36d  kmem_cache_s      mm/slab.c
SLAB_RED_MAGIC2       0x170fc2a5  (any)             mm/slab.c
ECP_MAGIC             0x21504345  cdkecpsig         include/linux/cdk.h
ISDN_ASYNC_MAGIC      0x49344C01  modem_info        include/linux/isdn.h
ISDN_NET_MAGIC        0x49344C02  isdn_net_local_s  include/linux/isdn.h
STLI_BOARDMAGIC       0x4bc6c825  stlibrd           include/linux/istallion.h
ROUTER_MAGIC          0x524d4157  wan_device        include/linux/wanrouter.h
SLAB_RED_MAGIC1       0x5a2cf071  (any)             mm/slab.c
STL_PORTMAGIC         0x5a7182c9  stlport           include/linux/stallion.h
HDLCDRV_MAGIC         0x5ac6e778  hdlcdrv_state     include/linux/hdlcdrv.h
EPCA_MAGIC            0x5c6df104  channel           include/linux/epca.h
PCXX_MAGIC            0x5c6df104  channel           drivers/char/pcxx.h
STL_PANELMAGIC        0x7ef621a1  stlpanel          include/linux/stallion.h
STL_BOARDMAGIC        0xa2267f52  stlbrd            include/linux/stallion.h
SLAB_MAGIC_ALLOC      0xa5c32f2b  kmem_slab_s       mm/slab.c
SLAB_MAGIC_DESTROYED  0xb2f23c5a  kmem_slab_s       mm/slab.c
STLI_PORTMAGIC        0xe671c7a1  stliport          include/linux/istallion.h
CCB_MAGIC             0xf2691ad2  ccb               drivers/scsi/ncr53c8xx.c