)]}'
{
  "commit": "7ec318feeed10a64c0359ec4d10889cb4defa39a",
  "tree": "cd59086e204ef2d48634ef67d301310bdc374576",
  "parents": [
    "1cb483a5cc84b497afb51a6c5dfb5a38a0b67086"
  ],
  "author": {
    "name": "Eric Dumazet",
    "email": "edumazet@google.com",
    "time": "Tue Nov 07 15:15:04 2017 -0800"
  },
  "committer": {
    "name": "David S. Miller",
    "email": "davem@davemloft.net",
    "time": "Fri Nov 10 18:07:15 2017 +0900"
  },
  "message": "tcp: gso: avoid refcount_t warning from tcp_gso_segment()\n\nWhen a GSO skb of truesize O is segmented into 2 new skbs of truesize N1\nand N2, we want to transfer socket ownership to the new fresh skbs.\n\nIn order to avoid expensive atomic operations on a cache line subject to\ncache bouncing, we replace the sequence :\n\nrefcount_add(N1, \u0026sk-\u003esk_wmem_alloc);\nrefcount_add(N2, \u0026sk-\u003esk_wmem_alloc); // repeated by number of segments\n\nrefcount_sub(O, \u0026sk-\u003esk_wmem_alloc);\n\nby a single\n\nrefcount_add(sum_of(N) - O, \u0026sk-\u003esk_wmem_alloc);\n\nProblem is :\n\nIn some pathological cases, sum(N) - O might be a negative number, and\nsyzkaller bot was apparently able to trigger this trace [1]\n\natomic_t was ok with this construct, but we need to take care of the\nnegative delta with refcount_t\n\n[1]\nrefcount_t: saturated; leaking memory.\n------------[ cut here ]------------\nWARNING: CPU: 0 PID: 8404 at lib/refcount.c:77 refcount_add_not_zero+0x198/0x200 lib/refcount.c:77\nKernel panic - not syncing: panic_on_warn set ...\n\nCPU: 0 PID: 8404 Comm: syz-executor2 Not tainted 4.14.0-rc5-mm1+ #20\nHardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011\nCall Trace:\n __dump_stack lib/dump_stack.c:16 [inline]\n dump_stack+0x194/0x257 lib/dump_stack.c:52\n panic+0x1e4/0x41c kernel/panic.c:183\n __warn+0x1c4/0x1e0 kernel/panic.c:546\n report_bug+0x211/0x2d0 lib/bug.c:183\n fixup_bug+0x40/0x90 arch/x86/kernel/traps.c:177\n do_trap_no_signal arch/x86/kernel/traps.c:211 [inline]\n do_trap+0x260/0x390 arch/x86/kernel/traps.c:260\n do_error_trap+0x120/0x390 arch/x86/kernel/traps.c:297\n do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:310\n invalid_op+0x18/0x20 arch/x86/entry/entry_64.S:905\nRIP: 0010:refcount_add_not_zero+0x198/0x200 lib/refcount.c:77\nRSP: 0018:ffff8801c606e3a0 EFLAGS: 00010282\nRAX: 0000000000000026 RBX: 0000000000001401 RCX: 0000000000000000\nRDX: 0000000000000026 RSI: ffffc900036fc000 RDI: ffffed0038c0dc68\nRBP: ffff8801c606e430 R08: 0000000000000001 R09: 0000000000000000\nR10: ffff8801d97f5eba R11: 0000000000000000 R12: ffff8801d5acf73c\nR13: 1ffff10038c0dc75 R14: 00000000ffffffff R15: 00000000fffff72f\n refcount_add+0x1b/0x60 lib/refcount.c:101\n tcp_gso_segment+0x10d0/0x16b0 net/ipv4/tcp_offload.c:155\n tcp4_gso_segment+0xd4/0x310 net/ipv4/tcp_offload.c:51\n inet_gso_segment+0x60c/0x11c0 net/ipv4/af_inet.c:1271\n skb_mac_gso_segment+0x33f/0x660 net/core/dev.c:2749\n __skb_gso_segment+0x35f/0x7f0 net/core/dev.c:2821\n skb_gso_segment include/linux/netdevice.h:3971 [inline]\n validate_xmit_skb+0x4ba/0xb20 net/core/dev.c:3074\n __dev_queue_xmit+0xe49/0x2070 net/core/dev.c:3497\n dev_queue_xmit+0x17/0x20 net/core/dev.c:3538\n neigh_hh_output include/net/neighbour.h:471 [inline]\n neigh_output include/net/neighbour.h:479 [inline]\n ip_finish_output2+0xece/0x1460 net/ipv4/ip_output.c:229\n ip_finish_output+0x85e/0xd10 net/ipv4/ip_output.c:317\n NF_HOOK_COND include/linux/netfilter.h:238 [inline]\n ip_output+0x1cc/0x860 net/ipv4/ip_output.c:405\n dst_output include/net/dst.h:459 [inline]\n ip_local_out+0x95/0x160 net/ipv4/ip_output.c:124\n ip_queue_xmit+0x8c6/0x18e0 net/ipv4/ip_output.c:504\n tcp_transmit_skb+0x1ab7/0x3840 net/ipv4/tcp_output.c:1137\n tcp_write_xmit+0x663/0x4de0 net/ipv4/tcp_output.c:2341\n __tcp_push_pending_frames+0xa0/0x250 net/ipv4/tcp_output.c:2513\n tcp_push_pending_frames include/net/tcp.h:1722 [inline]\n tcp_data_snd_check net/ipv4/tcp_input.c:5050 [inline]\n tcp_rcv_established+0x8c7/0x18a0 net/ipv4/tcp_input.c:5497\n tcp_v4_do_rcv+0x2ab/0x7d0 net/ipv4/tcp_ipv4.c:1460\n sk_backlog_rcv include/net/sock.h:909 [inline]\n __release_sock+0x124/0x360 net/core/sock.c:2264\n release_sock+0xa4/0x2a0 net/core/sock.c:2776\n tcp_sendmsg+0x3a/0x50 net/ipv4/tcp.c:1462\n inet_sendmsg+0x11f/0x5e0 net/ipv4/af_inet.c:763\n sock_sendmsg_nosec net/socket.c:632 [inline]\n sock_sendmsg+0xca/0x110 net/socket.c:642\n ___sys_sendmsg+0x31c/0x890 net/socket.c:2048\n __sys_sendmmsg+0x1e6/0x5f0 net/socket.c:2138\n\nFixes: 14afee4b6092 (\"net: convert sock.sk_wmem_alloc from atomic_t to refcount_t\")\nSigned-off-by: Eric Dumazet \u003cedumazet@google.com\u003e\nReported-by: syzbot \u003csyzkaller@googlegroups.com\u003e\nSigned-off-by: David S. Miller \u003cdavem@davemloft.net\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "11f69bbf93072b7b4dbc3a0485c9f9e0b9ba30b3",
      "old_mode": 33188,
      "old_path": "net/ipv4/tcp_offload.c",
      "new_id": "b6a2aa1dcf56cbaa029b0ec6c5e512e33c90fff9",
      "new_mode": 33188,
      "new_path": "net/ipv4/tcp_offload.c"
    }
  ]
}
