Kernel Debug
Kernel Debug
+1-866-488-6691 Contact Us checkpoint.com CheckMates FAQs Blog Welcome: Don Paterson | Sign Out
Kernel Debug
Solution ID sk98799
Product Security Gateway
Version R76, R77, R77.10, R77.20, R77.30, R80.10, R80.20, R80.30
Platform / Model All
Date Created 06-Mar-2014
Last Modified 24-Jun-2019
Solution
The kernel is the bridge between the hardware and the OS. In the Check Point kernel, packets are inspected both in Inbound (ingress) and Outbound (egress) directions. Each direction
has its own modules and order of inspection.
Handlers (INSPECT code) decide which modules will inspect the packet.
The inspection operations in the Check Point kernel are divided into modules, and the modules are divided into chains. The number of chains on every Security Gateway is different. It
depends on which blades/features are enabled on the Security Gateway.
Example:
in chain (17):
0: -7f800000 (f206df90) (ffffffff) IP Options Strip (in) (ipopt_strip)
1: - 2000000 (f149dd70) (00000003) vpn decrypt (vpn)
2: - 1fffff8 (f14a8b20) (00000001) l2tp inbound (l2tp)
3: - 1fffff6 (f206f290) (00000001) Stateless verifications (in) (asm)
4: - 1fffff2 (f14c4940) (00000003) vpn tagging inbound (tagging)
5: - 1fffff0 (f149bc10) (00000003) vpn decrypt verify (vpn_ver)
6: - 1000000 (f20c4980) (00000003) SecureXL conn sync (secxl_sync)
7: 0 (f201df50) (00000001) fw VM inbound (fw)
8: 1 (f2087ed0) (00000002) wire VM inbound (wire_vm)
9: 10 (f202f610) (00000001) fw accounting inbound (acct)
10: 2000000 (f149eaf0) (00000003) vpn policy inbound (vpn_pol)
11: 10000000 (f20ca740) (00000003) SecureXL inbound (secxl)
12: 7f600000 (f20646b0) (00000001) fw SCV inbound (scv)
13: 7f730000 (f21b11f0) (00000001) passive streaming (in) (pass_str)
14: 7f750000 (f231c540) (00000001) TCP streaming (in) (cpas)
15: 7f800000 (f206e320) (ffffffff) IP Options Restore (in) (ipopt_res)
16: 7fb00000 (f22de3b0) (00000001) HA Forwarding (ha_for)
When troubleshooting and trying to understand which chain is causing a problem on the Security Gateway, use the following command:
The '-p all' flag will show all the chains, through which the traffic passed.
To see it in kernel debug, use module fw with the flags monitorall, vm, chain and chainfwd
Note: These flags generate large number of messages, hence will cause high load on CPU.
https://supportcenter.checkpoint.com/supportcenter/portal?action=portlets.SearchResultMainAction&eventSubmit_doGoviewsolutiondetails=&solu… 1/6
11/09/2019
[Expert@HostName]# fw ctl debug -m Kernel Debug
Debugging Modules
Module Explanation
Kissflow Kernel I/s communication with other modules and policy enforcement
uc UserCheck module
Very important I/S, DNS resolving, string matching, md5sum check against database and 3rd party, resource
RAD_KERNEL
categorization
UP Unified Policy module (For more information, refer to sk120964 - ATRG: Unified Policy)
When debugging the kernel, it is important to first understand the flow of the packets and connections and understand the failure point; it is important to understand which module
you need to debug.
Every module has its own flags that were designed to print specific debug information. It is important to know the common flags to be more accurate when debugging the kernel.
Module Explanation
drop the connection that was dropped, the function in the firewall that dropped it and the reason
information from the connections table (everything that can be seen with this command #fw tab -t 8158) . Direction of packets in
conn
connections, source/destination of IP and ports, service type, handler, timeout, the rule that this packet is matched on, ETC
this flag refers to the kernel dynamic tables infrastructure. It reads and write everything that is written to any kernel table. Adding this
ld flag to the debug syntax may cause the machine high CPU and can even cause the machine to hang. Check load before performing this
debug on production environment.
xlate the firewall NAT infrastructure - basic NAT information + NAT cache
xltrc NAT additional information, print NAT rulebase information and more information from the NAT kernel table (fwx_alloc)
packet information on actions performed on packet - like accept, drop, fragment, inspection
advanced information of the packet's header. stateless verifications - sequences, fragments, translations and other header changes and
packval
verifications.
shows actions of all the virtual chains that can be seen with the command: # fw ctl chain on the traffic that go through the chain handle
vm
function fw_filter_chain
tcpstr TCP streaming mechanism, organize TCP packets by order and checks protocol messages. debug the PSL I/S. (passive streaming layer)
chainfwd chain forwarding - related to fwha_perform_chain_forwarding global kernel variable (clusterXL only)
the kernel saves information and holds connections for inspection, this flag will show virtual de-fragmentation and cookie issues (cookies
cookie
in the data structure holding the packets)
Module Explanation
Note: For R80.20 and above, kernel debug buffer is defined per CoreXL instance and it is limited to 8200 bytes.
If the machine has enough memory, it is recommended to set the maximum buffer of 32768.
The fact that the buffer size is 8000 or 32768 will not affect the file size.
The kernel writes the debug messages to the buffer. A user mode process named 'kdebug' writes the messages from the buffer to the file.
Dividing the debug output file into multiple file limited to certain size:
Kernel tables
The kernel writes all of its actions to relevant tables. Every kernel table has an assigned name and assigned kernel ID, and it holds specific information.
The forwarding, handling and decisions will be done based on informatin that is stored in different kernel tables.
[Expert@HostName]# fw tab
To delete all entries from a certain kernel table (all involved connections will be immediately lost and disconnected):
https://supportcenter.checkpoint.com/supportcenter/portal?action=portlets.SearchResultMainAction&eventSubmit_doGoviewsolutiondetails=&solu… 3/6
11/09/2019
[Expert@HostName]# fw tab -t <Table_Name | Table_ID> -x -y Kernel Debug
Important Note: This operation deletes all information from the table. Do NOT use this command in production environment, as it might cause a traffic outage.
[Expert@HostName]# fw tab -s
Connections Table
The most used kernel table is the Connections Table. Every connection that passed the firewall is written to the Connections Table. Timeouts, rule numbers, symbolic links, state
decisions, all are written and decided by this table.
<DIRECTION,6-tuple-
key;r_ctype,r_cflags,rule,service_id,handler,uuid1,uuid2,uuid3,uuid4,ifncin,ifncout,ifnsin,ifnsout,bits1,bits2,connection_module_kbufs@ttl/timeout>
Tuple is the basic information on the connection that is written to the connections table.
<direction,src_ip,src_port,dst_ip,dst_port,protocol>
Example 1:
<00000001, C21D2B59, 0000AF6B, C21D24D9, 00000035, 00000011> - This is the first connection that was written to the Connections Table. The culmination of all six values
named "six tuple" or - connections table EntryID
00000001 - first value of the tuple indicates the direction (00000001 - outbound)
Example 2:
00000000 - first value of the tuple indicates the direction (00000000 - inbound)
C21D24D9 - Source IP- in our example, DNS Server (in Dec = 194.29.36.217)
In terms of analysis for the debug, the ability to analyze the debug depends on how familiar you are with the expected behavior.
1. fwconn_lookup: connection lookup, the Security Gateway wants to see if there is a match for the connection that just arrived via the interface
Before VM:
https://supportcenter.checkpoint.com/supportcenter/portal?action=portlets.SearchResultMainAction&eventSubmit_doGoviewsolutiondetails=&solu… 4/6
<192.168.121.1:4461 -> 10.0.121.13:23 IPP 6> (len-48) TCP flags-0x2 (SYN), seq-55a92b89,
11/09/2019 Kernelack-0,
Debugdata end-55a92b8a (ifn-0) (first seen) (looked up)
2. Since the connection is "not found in connections table", the next step is to record it
Since we have enabled the syn_sent flag, only RST or SYN-ACK are allowed. In the phase for example, if any other packet besides RST or SYN-ACK, it will be dropped on "out of
state".
fwconn_init_links: Creating links (inbound). One way links-0, Replies from any-0;
;fwconn_set_links_inbound: create link cls_o <dir 1, 10.0.121.13:23 -> 192.168.121.1:4461 IPP 6> -> <dir 0, 192.168.121.1:4461 -> 10.0.121.13:23 IPP 6>(0x5);
fwconn_set_links_inbound: create link srs_o <dir 1, 192.168.121.1:4461 -> 10.0.121.13:23 IPP 6> -> <dir 0, 192.168.121.1:4461 -> 10.0.121.13:23 IPP 6>(0x2);
<10001,44000,1,1ae,0,4a2cc1db,0,4779a8c0,ffff,0,ffffffff,ffffffff,ffffffff,2000000,0,0,0,0,0,0,0,0,0,0,0,0,7c9c0800,0,0>
After this phase, the packet is entering the outbound chains and the handling will continue in accordance with the chain forwarding.
Before VM:
<192.168.121.1:4461 -> 10.0.121.13:23 IPP 6> (len-48) TCP flags-0x2 (SYN), seq-55a92b89, ack-0, data end-55a92b8a (ifn-1) (looked up) ;
https://supportcenter.checkpoint.com/supportcenter/portal?action=portlets.SearchResultMainAction&eventSubmit_doGoviewsolutiondetails=&solu… 5/6
fwconn_chain_update_anti_spoofing_cache: updating anti-spoofing interface info. [cin-0,
11/09/2019 Kernelcout--1,
Debug sin--1, sout--1], dir-1, cdir-1, new ifn-1, spoof offset-3, previous ifn--1;
17. NAT rulebase match, cache and Slinks, after we have routing info.
fw_xlate_match: conn-<192.168.121.1:4461 -> 10.0.121.13:23 IPP 6>; ; 8Jun2009 10:46:35.420110;fw_xlate_match: cache hit!;
19. Syn accepted, written, inspected by stateful inspection, rulebase and anti-spoofing.
After VM:
<192.168.121.1:4461 -> 10.0.121.13:23 IPP 6> (len-48) TCP flags-0x2 (SYN), seq-55a92b89, ack-0, data end-55a92b8a
VM Final action-ACCEPT
----- Stateful VM outbound Completed -----
Currently as we see, the timeout is "25", as the handshake was not completed.
The SYN-ACK will go through the same inspection process, however the timeout will be also be "25". It will change only after the 3-way handshake will be completed.
In terms of stateful inspection, the only allowed flags according to the current state (SYN_SENT) are SYN-ACK and RST.
This solution has been verified for the specific scenario, described by the combination of Product, Version and Symptoms. It may not work in other scenarios.
https://supportcenter.checkpoint.com/supportcenter/portal?action=portlets.SearchResultMainAction&eventSubmit_doGoviewsolutiondetails=&solu… 6/6