You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Boolean, enables/disables the Memorizer tool. Memorizer traces the memory allocations of kernel objects to track patterns across an object's lifetime.
154
154
155
155
``MEMORIZER_STATS``
156
-
Boolean, enables/disables the Memorizer statistics summary. The statistics summary includes the number of accesses and shadow objects allocated for Memorizer which will slow down the performance of the system.
156
+
Boolean, enables/disables the Memorizer statistics summary. The
157
+
statistics summary includes the number of accesses and shadow objects
158
+
allocated for Memorizer which will slow down the performance of
159
+
the system.
157
160
158
161
``MEMORIZER_TRACKPIDS``
159
-
Boolean, enables/disables the segregation of memory access counts by process id (PID) within Memorizer data.
162
+
Boolean, enables/disables the segregation of memory access counts by
163
+
process id (PID) within Memorizer data.
160
164
161
165
``MEMORIZER_DEBUGFS_RAM``
162
-
Boolean, enables/disables the exposure of Memorizer's buffer via a debugfs file.
166
+
Boolean, enables/disables the exposure of Memorizer's buffer via a
167
+
debugfs file.
163
168
164
169
``INLINE_LIBS``
165
-
Boolean, forces gcc to use inline calls for some library functions. This must be enabled to run Memorizer.
170
+
Boolean, forces gcc to use inline calls for some library functions. This
171
+
must be enabled to run Memorizer.
166
172
167
173
Dependencies
168
174
~~~~~~~~~~~~
169
175
``KASAN``
170
-
Boolean, enables/disables Kernel Address Sanitizer (KASAN). This is an error detector designed to find out-of-bounds and use-after-free bugs in dynamic memory. This must be enabled to run Memorizer.
176
+
Boolean, enables/disables Kernel Address Sanitizer (KASAN). This is
177
+
an error detector designed to find out-of-bounds and use-after-free
178
+
bugs in dynamic memory. This must be enabled to run Memorizer.
171
179
172
180
.. _`debugfs-files`:
173
181
@@ -333,24 +341,29 @@ Status Files
333
341
334
342
``stats``
335
343
Reading this file generates human-readable statistical data
336
-
about the current state of Memorizer. For more information,
337
-
see :ref:`debugfs-stat`.
344
+
about the current state of Memorizer. The format is intended
345
+
to be self-evident and is subject to change from release to release.
346
+
347
+
External scripts should not rely upon the format of this file.
338
348
339
349
340
350
File Formats
341
351
============
342
352
343
-
.. _`debugfs-stat`:
344
-
345
353
``stat``
346
354
~~~~~~~~
347
355
348
-
blah.
356
+
Reading this file generates human-readable statistical data
357
+
about the current state of Memorizer. The format is intended
358
+
to be self-evident and is subject to change from release to release.
349
359
350
-
.. _`debugfs-kmap`:
360
+
External scripts should not rely upon the format of this file.
351
361
352
-
``kmap``
353
-
~~~~~~~~
362
+
.. _debugfs-kmap-stream:
363
+
.. _debugfs-kmap:
364
+
365
+
``kmap`` and ``kmap_stream``
366
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
354
367
355
368
.. note::
356
369
@@ -365,16 +378,73 @@ Memorizer outputs data as text. The format of the ``kmap`` file is as follows::
365
378
...
366
379
...
367
380
368
-
The longer line represents the allocation and destruction of a kernel object.
369
-
The shorter, indented, line represents the memory accesses of that same object.
370
-
Each shorter line refers to the immediately preceding long line. There may be
371
-
any number of shorter lines per long line. There may be any number of long lines
372
-
in a kmap file.
381
+
The longer line represents the allocation and destruction of a kernel
382
+
object. The shorter, indented, line represents the memory accesses of
383
+
that same object. Each shorter line refers to the immediately preceding
384
+
long line. There may be any number of shorter lines per long line. There
385
+
may be any number of long lines in a kmap file.
386
+
387
+
The following fields are printed as unsigned hexadecimal values:
388
+
389
+
* ``alloc_ip``
390
+
* ``obj_va_ptr``
391
+
* ``free_ip``
392
+
393
+
The following fields are printed as unsigned decimal values:
394
+
395
+
* ``size``
396
+
* ``alloc_index``
397
+
* ``free_index``
398
+
399
+
The following fields are printed as (possibly blank) character strings:
400
+
401
+
* ``alloc_type``
402
+
* ``command``
403
+
* ``slabname``
404
+
* ``new_alloc_type``
405
+
406
+
* The following field is printed as a signed decimal value:
407
+
408
+
* ``pid``
409
+
410
+
373
411
374
412
``alloc_ip``
375
-
The instruction pointer of the ``call`` instruction which resulted
413
+
The return instruction pointer of the ``call`` instruction which resulted
376
414
in the allocation of the object.
377
415
416
+
For some allocations, it is either not useful or not possible
417
+
to describe the actual ``call`` instruction. For example, a
418
+
statically-declared object does not have the same vmalloc-use-vfree
419
+
life cycle as a dynamically-allocated object. In those cases synthetic
420
+
values are used, each with a special meaning.
421
+
422
+
``MEMORIZER_PREALLOCATED(0xfeedbeef)``
423
+
This flag is used when Slub allocates new objects for a cache.
424
+
Memorizer preallocates objects here so any accesses from constructors
425
+
are captured correctly. This value is subsequently overwritten with
426
+
the actual instruction pointer of the ``call`` instruction which
427
+
resulted in the allocation of the object.
428
+
429
+
``0``
430
+
Memorizer maintains a set of general-purpose object descriptors,
431
+
each with ``alloc_ip`` set to zero and with ``alloc_type`` set to
432
+
a valid :ref:alloc_type value. These are used when a memory access
433
+
occurs and the memory address is not described by an existing
434
+
object descriptor.
435
+
436
+
Other ``alloc_type`` values
437
+
Some memory accesses which cannot be associated with existing
438
+
object descriptors result in the creation of new descriptors
439
+
with ``alloc_ip`` set equal to :ref:alloc_type. These
440
+
types include UFO_MEMBLOCK(0x14), STACK_PAGE(0x3),
441
+
UFO_GLOBAL(0x18), and UFO_NONE(0x19),
442
+
443
+
.. note::
444
+
``alloc_ip`` is printed as a hexadecimal value without a ``0x``
445
+
prefix. The printed value ``14``, for example is ``0x14`` or
446
+
decimal 20.
447
+
378
448
``pid``
379
449
The process ID of the process that allocated the object.
380
450
@@ -394,7 +464,7 @@ in a kmap file.
394
464
`memorizer_index_type`_ for a description.
395
465
396
466
``free_ip``
397
-
The instruction pointer of the `call` instruction which destroyed the object.
467
+
The instruction pointer of the ``call`` instruction which destroyed the object.
398
468
399
469
There are a few special cases:
400
470
@@ -403,57 +473,114 @@ in a kmap file.
403
473
the free, then ``free_ip`` is also zero.
404
474
405
475
- If a subsequently allocated object exists in the same virtual addresses
406
-
as a previously allocated, not freed, object, then Memorizer probably
407
-
did not observe the intervening free.
408
-
409
-
In this case, ``free_ip`` of the previous object is ``0xdeadbeef`` and
410
-
the ``free_index`` of the previous object is set equal to the
411
-
``alloc_ip`` of the subsequent object.
412
-
``new_alloc_type`` of the previous
413
-
allocation is set to the ``alloc_type`` of the subsequent allocation.
414
-
415
-
- If a subsequently allocated object has exactly the same virtual address
416
-
as the immediately preceding allocation, this represents a
417
-
nested allocation. In this case, ``free_ip`` is set to ``0xfedbeef``.
418
-
``new_alloc_type`` of the previous
419
-
allocation is set to the ``alloc_type`` of the subsequent allocation.
420
-
``free_index`` of the previous allocation is set to ``alloc_index``
421
-
of the subsequent allocation.
476
+
as a previously allocated, not freed, object, then either Memorizer
477
+
did not observe the intervening free, or there was no interveneing free.
478
+
479
+
* If this is the result of nested allocations, then ``free_ip`` of
480
+
the previous allocation will have ``0xfedbeef``.
481
+
482
+
* If this occurs for some other, unknown, reason, then ``free_ip`` of
483
+
the previous allocation will have ``0xdeadbeef``.
484
+
485
+
In either case, the ``free_index`` of the previous allocation is
486
+
set equal to the ``alloc_index`` of the subsequent allocation.
422
487
423
488
``alloc_type``
424
489
Memorizer tracks various sorts of object allocation. This field
425
490
gives an indication of which type this is.
426
491
427
492
This field has several possible values. Consult the source code
428
-
for information on each of these::
429
-
430
-
STACK
431
-
STACK_FRAME
432
-
STACK_ARGS
433
-
STACK_PAGE
434
-
GEN_HEAP
435
-
UFO_HEAP
436
-
GLOBAL
437
-
KMALLOC
438
-
KMALLOC_ND
439
-
KMEM_CACHE
440
-
KMEM_CACHE_ND
441
-
KMEM_CACHE_BULK
442
-
ALLOC_PAGES
443
-
ALLOC_PAGES_EXACT
444
-
ALLOC_PAGES_GETFREEPAGES
445
-
ALLOC_PAGES_FOLIO
446
-
VMALLOC
447
-
INDUCED_ALLOC
448
-
BOOTMEM
449
-
MEMBLOCK
450
-
UFO_MEMBLOCK
451
-
MEMORIZER
452
-
USER
453
-
BUG
454
-
UFO_GLOBAL
455
-
UFO_NONE
456
-
NONE
493
+
for more information on each of these:
494
+
495
+
STACK (MEM_STACK, 0x0)
496
+
Unused.
497
+
498
+
STACK_FRAME (MEM_STACK_FRAME, 0x1)
499
+
Used in the generation of call frame graphs (CFGs).This value should
500
+
not appear in kmap.
501
+
502
+
STACK_ARGS (MEM_STACK_ARGS, 0x2)
503
+
Used in the generation of call frame graphs (CFGs).This value should
504
+
not appear in kmap.
505
+
506
+
STACK_PAGE (MEM_STACK_PAGE, 0x3)
507
+
Used to describe a kernel object allocated in a stack frame.
508
+
509
+
GEN_HEAP (MEM_HEAP, 0x4)
510
+
Unused.
511
+
512
+
UFO_HEAP (MEM_UFO_HEAP, 0x5)
513
+
Unused.
514
+
515
+
GLOBAL (MEM_GLOBAL, 0x6)
516
+
The object is globally declared.
517
+
518
+
KMALLOC (MEM_KMALLOC, 0x7)
519
+
The subject allocation was from either the ``kmalloc`` or
520
+
``kmalloc_node`` family of allocators.
521
+
522
+
KMALLOC_ND (MEM_KMALLOC_ND, 0x8)
523
+
The subject allocation was from either the ``kmalloc`` or
524
+
``kmalloc_node`` family of allocators.
525
+
526
+
KMEM_CACHE (MEM_KMEM_CACHE, 0x9)
527
+
The subject allocation was from the kmem_cache_alloc family of allocators.
528
+
529
+
KMEM_CACHE_ND (MEM_KMEM_CACHE_ND, 0xA)
530
+
The subject allocation was from the kmem_cache_alloc family of allocators.
531
+
532
+
KMEM_CACHE_BULK (MEM_KMEM_CACHE_BULK, 0xB)
533
+
The subject allocation was from the kmem_cache_alloc family of allocators.
534
+
535
+
VMALLOC (MEM_VMALLOC, 0xC)
536
+
The subject allocation was from ``vmalloc``.
537
+
538
+
ALLOC_PAGES (MEM_ALLOC_PAGES, 0xD)
539
+
The subject allocation was from ``__alloc_pages``., et al.
540
+
541
+
ALLOC_PAGES_EXACT (MEM_ALLOC_PAGES_EXACT, 0xE)
542
+
The subject allocation was from ``alloc_pages_exact``.
0 commit comments