PATCH: fix get_sock_info failure on 2.6.38

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2.6.38 introduced another change in struct inet_sock that breaks net -s
like this:

crash-5.1.8> net -s 2494

net: invalid structure member offset: inet_opt_daddr
     FILE: net.c  LINE: 829  FUNCTION: get_sock_info()

[/home/bobm/bin/crash-5.1.8] error trace: 4cccca => 4cb773 => 4ca4c0 =>
4f766a
PID: 2494   TASK: ffff8801226de540  CPU: 1   COMMAND: "racoon"
FD      SOCKET            SOCK       FAMILY:TYPE SOURCE-PORT
DESTINATION-PORT

  4f766a: OFFSET_verify+202
  4ca4c0: sym_socket_dump+1920
  4cb773: dump_sockets_workhorse+1571
  4cccca: cmd_net+3658

 3 ffff8801229470c0 ffff88011f8dfc00 net: invalid structure member
offset: inet_opt_daddr
     FILE: net.c  LINE: 829  FUNCTION: get_sock_info()


This patch adds a new final clause to net_init to handle the case where
inet_sock no longer contains inet_daddr (the previous final clause):

struct inet_sock {
        /* sk and pinet6 has to be the first two members of inet_sock */
        struct sock             sk;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
        struct ipv6_pinfo       *pinet6;
#endif
        /* Socket demultiplex comparisons on incoming packets. */
#define inet_daddr              sk.__sk_common.skc_daddr      <<<<<<<<<<<
#define inet_rcv_saddr          sk.__sk_common.skc_rcv_saddr   <<<<<<<<<<<<

The patch cheats by depending on inet_sock having struct sock as its
first element and struct sock having struct sock_common as its first
element without actually verifying that.

Bob Montgomery


   
--- net.c.orig	2011-10-11 15:53:39.000000000 -0600
+++ net.c	2011-10-14 14:35:50.000000000 -0600
@@ -210,12 +210,19 @@ net_init(void)
 					MEMBER_OFFSET_INIT(inet_opt_dport, "inet_sock", "dport");
 					MEMBER_OFFSET_INIT(inet_opt_sport, "inet_sock", "sport");
 					MEMBER_OFFSET_INIT(inet_opt_num, "inet_sock", "num");
-				} else {
+				} else if (MEMBER_EXISTS("inet_sock", 
+						"inet_daddr")) {
 					MEMBER_OFFSET_INIT(inet_opt_daddr, "inet_sock", "inet_daddr");
 					MEMBER_OFFSET_INIT(inet_opt_rcv_saddr, "inet_sock", "inet_rcv_saddr");
 					MEMBER_OFFSET_INIT(inet_opt_dport, "inet_sock", "inet_dport");
 					MEMBER_OFFSET_INIT(inet_opt_sport, "inet_sock", "inet_sport");
 					MEMBER_OFFSET_INIT(inet_opt_num, "inet_sock", "inet_num");
+				} else { 
+					MEMBER_OFFSET_INIT(inet_opt_daddr, "sock_common", "skc_daddr");
+					MEMBER_OFFSET_INIT(inet_opt_rcv_saddr, "sock_common", "skc_rcv_saddr");
+					MEMBER_OFFSET_INIT(inet_opt_dport, "inet_sock", "inet_dport");
+					MEMBER_OFFSET_INIT(inet_opt_sport, "inet_sock", "inet_sport");
+					MEMBER_OFFSET_INIT(inet_opt_num, "inet_sock", "inet_num");
 				}
 			}	
 
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux