milabs / drop-tcp-sock Goto Github PK
View Code? Open in Web Editor NEWThis module allows one to kill TCP sockets (including TIME-WAIT state).
This module allows one to kill TCP sockets (including TIME-WAIT state).
Привет.
Сабж в заголовке. После make:
/root/drop-tcp-sock/main.c:57:8: error: implicit declaration of function ‘inet6_lookup’; did you mean ‘inet_lookup’? [-Werror=implicit-function-declaration]
sk = inet6_lookup(net, &tcp_hashinfo,
Как быть. Спасибо.
The following usage is missing the netstat -t switch:
netstat -n | grep WAIT | awk '{print $4"\t"$5}'
Should be:
netstat -t -n | grep WAIT | awk '{print $4"\t"$5}'
I'm not sure yet if this happens at the second write to /proc/net/tcpdropsock, or just to kill a lot of connections, or both at the same time.
Without much certainty I'd say dnew = krealloc is actually ignored as if dnew is a different pointer, it's not save back in i_private?
[ 792.277473] usercopy: kernel memory overwrite attempt detected to 0000000053b3152f (kmalloc-8192) (8192 bytes)
[ 792.277956] ------------[ cut here ]------------
[ 792.277956] kernel BUG at /build/linux-vxxS7y/linux-4.15.0/mm/usercopy.c:72!
[ 792.278401] invalid opcode: 0000 [#1] SMP NOPTI
[ 792.278840] Modules linked in: drop_tcp_sock(OE) ufs qnx4 hfsplus hfs minix ntfs msdos jfs xfs cpuid rpcsec_gss_krb5 auth_rpcgss nfsv4 msr nfs lockd grace fscache rdma_ucm(OE) ib_ucm(OE) ib_ipoib(OE) ib_uverbs(OE) ib_umad(OE) esp6_offload esp6 esp4_offload esp4 xfrm_algo mlx5_fpga_tools(OE) mlx4_en(OE) mlx4_ib(OE) mlx4_core(OE) intel_rapl sb_edac x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel ipmi_ssif kvm irqbypass intel_cstate dcdbas intel_rapl_perf ipmi_si ipmi_devintf ipmi_msghandler acpi_power_meter mac_hid mei_me mei shpchp lpc_ich sch_fq_codel sunrpc rdma_cm(OE) iw_cm(OE) ib_cm(OE) iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ip_tables x_tables autofs4 btrfs zstd_compress raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1
[ 792.282388] raid0 multipath linear mlx5_ib(OE) mgag200 crct10dif_pclmul ib_core(OE) crc32_pclmul ttm ghash_clmulni_intel pcbc drm_kms_helper ixgbe syscopyarea igb mlx5_core(OE) aesni_intel sysfillrect mlxfw(OE) devlink sysimgblt aes_x86_64 dca mlx_compat(OE) fb_sys_fops i2c_algo_bit crypto_simd megaraid_sas ahci glue_helper ptp drm cryptd libahci mdio pps_core wmi
[ 792.284109] CPU: 10 PID: 10502 Comm: tee Tainted: G OE 4.15.0-43-generic #46-Ubuntu
[ 792.284700] Hardware name: Dell Inc. PowerEdge R630/0CNCJW, BIOS 1.0.4 08/28/2014
[ 792.285298] RIP: 0010:__check_object_size+0x123/0x1b0
[ 792.285890] RSP: 0018:ffffa688c720be28 EFLAGS: 00010282
[ 792.286478] RAX: 0000000000000062 RBX: 0000000000002000 RCX: 0000000000000006
[ 792.287072] RDX: 0000000000000000 RSI: 0000000000000096 RDI: ffff9006bfd56490
[ 792.287664] RBP: ffffa688c720be48 R08: 0000000000000000 R09: 00000000000005b6
[ 792.288258] R10: 0000000000002000 R11: 00000000ffffffff R12: 0000000000000000
[ 792.288848] R13: ffff8ffa4342a008 R14: ffff8ffa43428008 R15: ffff9006b8418c00
[ 792.289440] FS: 00007f067ecaa540(0000) GS:ffff9006bfd40000(0000) knlGS:0000000000000000
[ 792.290038] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 792.290637] CR2: 00007f067ecbd000 CR3: 00000003bf404006 CR4: 00000000001606e0
[ 792.291241] Call Trace:
[ 792.291844] dts_proc_write+0x53/0xd0 [drop_tcp_sock]
[ 792.292453] proc_reg_write+0x45/0x70
[ 792.293053] __vfs_write+0x1b/0x40
[ 792.293650] vfs_write+0xb1/0x1a0
[ 792.294241] SyS_write+0x55/0xc0
[ 792.294828] do_syscall_64+0x73/0x130
[ 792.295413] entry_SYSCALL_64_after_hwframe+0x3d/0xa2
[ 792.295996] RIP: 0033:0x7f067e7bb154
[ 792.296577] RSP: 002b:00007fff075b5aa8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[ 792.297169] RAX: ffffffffffffffda RBX: 0000000000002000 RCX: 00007f067e7bb154
[ 792.297767] RDX: 0000000000002000 RSI: 00007fff075b5b90 RDI: 0000000000000003
[ 792.298367] RBP: 00007fff075b5b90 R08: 0000000000002000 R09: 00007f067ecaa540
[ 792.298965] R10: 00000000000001b6 R11: 0000000000000246 R12: 00005606b2b00460
[ 792.299558] R13: 0000000000002000 R14: 00007f067ea92760 R15: 0000000000002000
[ 792.300150] Code: 48 0f 45 d1 48 c7 c6 93 ee 0d b5 48 c7 c1 3f fc 0e b5 48 0f 45 f1 49 89 d9 49 89 c0 4c 89 f1 48 c7 c7 48 fc 0e b5 e8 ed e0 e7 ff <0f> 0b f3 c3 48 8b 3d b2 1d 1a 01 48 8b 0d 43 9e 1d 01 be 00 00
[ 792.301396] RIP: __check_object_size+0x123/0x1b0 RSP: ffffa688c720be28
[ 792.302025] ---[ end trace c9aab99dea41e061 ]---
I added a little printk to show that the size of the "size" argument in ts_proc_write is 8192.
When using the module with a large amount of sockets, I eventually end up in soft lockup:
[93492.433061] Call Trace:
[93492.433061] in4_pton+0x3f/0x160
[93492.433061] dts_pton+0x3d/0xd0 [drop_tcp_sock]
[93492.433061] dts_proc_release+0x143/0x360 [drop_tcp_sock]
[93492.433061] close_pdeo+0x58/0x100
[93492.433061] proc_reg_release+0x6b/0x70
[93492.433061] __fput+0xea/0x220
[93492.433061] ____fput+0xe/0x10
[93492.433061] task_work_run+0x9d/0xc0
[93492.433061] exit_to_usermode_loop+0xc0/0xd0
[93492.433061] do_syscall_64+0x115/0x130
[93492.433061] entry_SYSCALL_64_after_hwframe+0x3d/0xa2
[93492.433061] RIP: 0033:0x7f15aad96947
[93492.433061] RSP: 002b:00007ffd06de2df8 EFLAGS: 00000206 ORIG_RAX: 0000000000000003
[93492.433061] RAX: 0000000000000000 RBX: 00005636a5885460 RCX: 00007f15aad96947
[93492.433061] RDX: 00007f15ab06d760 RSI: 00005636a58854e3 RDI: 0000000000000003
[93492.433061] RBP: 00007f15ab06e2a0 R08: 00007f15ab28e540 R09: 00007f15ab28e540
[93492.433061] R10: 00000000000001b6 R11: 0000000000000206 R12: 0000000000000000
[93492.433061] R13: 00005636a4a4317c R14: 0000000000000000 R15: 00007ffd06de4fb0
[93492.433061] Code: c2 01 80 3a 00 75 f7 48 83 c6 01 0f b6 4e ff 48 83 c2 01 84 c9 88 4a ff 75 ed 5d c3 0f 1f 00 80 3f 00 55 48 89 e5 74 14 48 89 f8 <48> 83 c7 01 80 3f 00 75 f7 48 29 c7 48 89 f8 5d c3 31 c0 5d c3
Maybe unrelated, but sometimes I get "Cannot allocate memory" when writing a big chunk to /dev/... . My system has 256G of memory. Maybe kmalloc is not necessary?
OS:centOS7.5.1804
make: *** /lib/modules/3.10.0-86.el7.x86_64/build: no such file or directory . stop.
make: *** [default] errer 2
Hello milabs,
I am trying install your module. I am not linux guru.
This is my commands
cd
git clone https://github.com/milabs/drop-tcp-sock.git
cd drop*
make
insmod ./drop-tcp-sock.ko
I am getting this error.
make -C /lib/modules/4.15.0-29-generic/build M=$PWD
make[1]: *** /lib/modules/4.15.0-29-generic/build: No such file or directory. Stop.
Makefile:7: recipe for target 'all' failed
make: *** [all] Error 2
What can i do?
Thank You.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.