Skip to content

Instantly share code, notes, and snippets.

@majek
Last active July 16, 2019 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save majek/bd083dae769804d39134ce01f4f802bb to your computer and use it in GitHub Desktop.
Save majek/bd083dae769804d39134ce01f4f802bb to your computer and use it in GitHub Desktop.
out of memory in sctp
a.out invoked oom-killer: gfp_mask=0x2dc0(GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO), order=0, oom_score_adj=0
CPU: 0 PID: 131 Comm: a.out Not tainted 5.2.1+ #31
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
Call Trace:
dump_header.cold.35+0x11/0x985
? ___ratelimit+0x1c6/0x400
oom_kill_process+0x151/0x850
? lockdep_sys_exit+0x50/0x50
? _raw_spin_unlock+0x1f/0x30
? oom_badness.part.26+0x3e1/0x510
out_of_memory+0x2ac/0x12b0
? unregister_oom_notifier+0x10/0x10
? mutex_trylock+0x160/0x1a0
? __alloc_pages_slowpath+0xd50/0x1af0
__alloc_pages_slowpath+0x1373/0x1af0
? find_held_lock+0x33/0x1c0
? warn_alloc+0x110/0x110
__alloc_pages_nodemask+0x3be/0x600
? gfp_pfmemalloc_allowed+0x140/0x140
? memset+0x1f/0x40
__get_free_pages+0xc/0x40
__genradix_ptr_alloc+0x173/0x2f0
__genradix_prealloc+0x32/0x50
sctp_stream_alloc_out+0xab/0x100
sctp_stream_init+0xe6/0x300
? __raw_spin_lock_init+0x28/0x100
sctp_association_new+0x1253/0x21b0
sctp_sendmsg_new_asoc+0x31f/0xf80
? sctp_endpoint_lookup_assoc+0x150/0x210
? sctp_apply_asoc_delayed_ack+0x4e0/0x4e0
? lockdep_sys_exit+0x50/0x50
? lock_acquire+0x135/0x2d0
? sctp_endpoint_lookup_assoc+0x17d/0x210
sctp_sendmsg+0x1349/0x15b0
? sctp_id2assoc+0x2d0/0x2d0
? find_held_lock+0x33/0x1c0
? __might_fault+0xe6/0x198
? lock_acquire+0x135/0x2d0
inet_sendmsg+0x15f/0x210
__sys_sendto+0x280/0x3d0
? __x64_sys_getpeername+0xb0/0xb0
? __local_bh_enable_ip+0x117/0x1a0
? lockdep_hardirqs_on+0x392/0x580
? __local_bh_enable_ip+0x117/0x1a0
? sctp_bind+0x9e/0xc0
? inet6_bind+0x95/0x110
? __sys_setsockopt+0x14f/0x200
? __sys_socket+0x15f/0x1e0
? lockdep_hardirqs_on+0x392/0x580
? entry_SYSCALL_64_after_hwframe+0x3e/0xbe
__x64_sys_sendto+0xdd/0x1b0
? lockdep_hardirqs_on+0x392/0x580
do_syscall_64+0x8f/0xc9f
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f003eb85da7
Code: 64 89 02 48 c7 c0 ff ff ff ff eb b6 0f 1f 80 00 00 00 00 48 8d 05 61 db 2c 00 41 89 ca 8b 00 85 c0 75 18 b8 2c 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 79 f3 c3 0f 1f 80 00 00 00 00 41 57 41 56 4d
RSP: 002b:00007ffe254d2ea8 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f003eb85da7
RDX: 0000000000023900 RSI: 00007ffe254d2ef0 RDI: 0000000000000003
RBP: 00007ffe254f6800 R08: 00007ffe254d2ec0 R09: 000000000000001c
R10: 0000000000000800 R11: 0000000000000246 R12: 000055c948d03780
R13: 00007ffe254f68e0 R14: 0000000000000000 R15: 0000000000000000
Mem-Info:
active_anon:625 inactive_anon:611 isolated_anon:0
active_file:0 inactive_file:0 isolated_file:0
unevictable:0 dirty:0 writeback:0 unstable:0
slab_reclaimable:2084 slab_unreclaimable:9196
mapped:5 shmem:619 pagetables:55 bounce:0
free:1772 free_pcp:77 free_cma:0
Node 0 active_anon:2500kB inactive_anon:2444kB active_file:0kB inactive_file:0kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:20kB dirty:0kB writeback:0kB shmem:2476kB writeback_tmp:0kB unstable:0kB all_unreclaimable? yes
DMA free:1556kB min:4196kB low:4220kB high:4244kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:15992kB managed:15908kB mlocked:0kB kernel_stack:0kB pagetables:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
lowmem_reserve[]: 0 362 362 362
DMA32 free:5532kB min:6476kB low:7068kB high:7660kB active_anon:2500kB inactive_anon:2444kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:507776kB managed:374892kB mlocked:0kB kernel_stack:768kB pagetables:220kB bounce:0kB free_pcp:308kB local_pcp:308kB free_cma:0kB
lowmem_reserve[]: 0 0 0 0
DMA: 1*4kB (U) 0*8kB 1*16kB (U) 0*32kB 2*64kB (UE) 1*128kB (E) 1*256kB (E) 0*512kB 1*1024kB (E) 0*2048kB 0*4096kB = 1556kB
DMA32: 229*4kB (UME) 253*8kB (UME) 64*16kB (UME) 25*32kB (UME) 10*64kB (UME) 1*128kB (E) 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 5532kB
623 total pagecache pages
0 pages in swap cache
Swap cache stats: add 0, delete 0, find 0/0
Free swap = 0kB
Total swap = 0kB
130942 pages RAM
0 pages HighMem/MovableOnly
33242 pages reserved
Unreclaimable slab info:
Name Used Total
9p-fcall-cache 24KB 148KB
9p-fcall-cache 24KB 148KB
p9_req_t 4KB 4KB
SCTPv6 3840KB 3840KB
sctp_chunk 1579KB 2317KB
sctp_bind_bucket 120KB 120KB
fib6_nodes 4KB 4KB
ip6_dst_cache 3KB 3KB
RAWv6 30KB 30KB
sd_ext_cdb 3KB 3KB
virtio_scsi_cmd 15KB 15KB
sgpool-128 29KB 29KB
sgpool-64 31KB 31KB
sgpool-32 15KB 15KB
sgpool-16 7KB 7KB
sgpool-8 3KB 3KB
bio-1 4KB 4KB
UNIX 20KB 30KB
ip_fib_trie 4KB 4KB
ip_fib_alias 3KB 3KB
RAW 15KB 15KB
UDP 15KB 15KB
eventpoll_pwq 4KB 7KB
eventpoll_epi 3KB 7KB
inotify_inode_mark 3KB 3KB
bio-0 4KB 4KB
biovec-max 29KB 29KB
skbuff_head_cache 1816KB 2617KB
fsnotify_mark_connector 3KB 3KB
shmem_inode_cache 2510KB 2511KB
proc_dir_entry 55KB 56KB
pde_opener 3KB 3KB
seq_file 3KB 19KB
sigqueue 3KB 3KB
kernfs_node_cache 2279KB 2279KB
mnt_cache 16KB 16KB
filp 268KB 268KB
names_cache 29KB 178KB
nsproxy 3KB 3KB
vm_area_struct 42KB 81KB
mm_struct 18KB 60KB
fs_cache 4KB 8KB
files_cache 9KB 23KB
signal_cache 38KB 63KB
sighand_cache 78KB 120KB
task_struct 150KB 249KB
cred_jar 6KB 23KB
anon_vma_chain 14KB 35KB
anon_vma 21KB 30KB
pid 5KB 8KB
Acpi-Operand 39KB 75KB
Acpi-ParseExt 3KB 19KB
Acpi-Parse 3KB 19KB
Acpi-State 3KB 19KB
Acpi-Namespace 19KB 19KB
trace_event_file 43KB 43KB
ftrace_event_field 68KB 68KB
pool_workqueue 4KB 4KB
vmap_area 3KB 3KB
kmalloc-8k 74KB 99KB
kmalloc-4k 9936KB 9936KB
kmalloc-2k 272KB 286KB
kmalloc-1k 2786KB 4394KB
kmalloc-512 2045KB 2835KB
kmalloc-256 269KB 285KB
kmalloc-192 37KB 68KB
kmalloc-128 126KB 126KB
kmalloc-96 232KB 232KB
kmalloc-64 578KB 578KB
kmalloc-32 266KB 266KB
kmalloc-16 35KB 40KB
kmalloc-8 96KB 103KB
kmem_cache_node 27KB 27KB
kmem_cache 48KB 48KB
Tasks state (memory values in pages):
[ pid ] uid tgid total_vm rss pgtables_bytes swapents oom_score_adj name
[ 61] 0 61 8800 374 94208 0 -1000 systemd-udevd
[ 127] 0 127 4626 113 77824 0 0 bash
[ 131] 0 131 1098 58 53248 0 0 a.out
oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),task=bash,pid=127,uid=0
Out of memory: Killed process 127 (bash) total-vm:18504kB, anon-rss:448kB, file-rss:4kB, shmem-rss:0kB
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <linux/sctp.h>
int main() {
// This seem to be significant. 130736 seems to be okay,
// 130737 seem to cause the crash. Keeping it higher.
char snd_buf[145664] = {};
int run;
for (run = 0; 1; run++) {
int port;
for (port = 1024; port < 32000; port ++) {
// Run the test.
int sd = socket(AF_INET6, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_SCTP);
char sctp_events[7] = "\10\10\10\10rrr";
setsockopt(sd, IPPROTO_SCTP, SCTP_EVENTS, sctp_events, sizeof(sctp_events));
struct sockaddr_in6 sa_dst = {
.sin6_family = AF_INET6,
.sin6_addr = IN6ADDR_LOOPBACK_INIT,
.sin6_port = htons(port),
};
bind(sd, (struct sockaddr*)&sa_dst, sizeof(struct sockaddr_in6));
sendto(sd, snd_buf, sizeof(snd_buf),
MSG_CONFIRM, (struct sockaddr*)&sa_dst, sizeof(sa_dst));
close(sd);
}
if (run % 100 == 0){
fprintf(stderr, ".");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment