Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4093321imm; Tue, 29 May 2018 21:59:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJzfXKFCC4lqnoqMnDc891mrSCHrtOKseGI9GvErplHZQfYS00TriQwGNdnhixb3ec038Jh X-Received: by 2002:a62:f58b:: with SMTP id b11-v6mr1287776pfm.113.1527656385435; Tue, 29 May 2018 21:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527656385; cv=none; d=google.com; s=arc-20160816; b=ov6nIVJrJ7a+bb3gmZvZG+ijrzbg7rrAY/7u37nFR9nc0Rab+sD7UN+j6vcxdrGnkt lzS9o6vAnrjaAGMb4BHxjx9/DrZ4Q1iXkxLVKffXrZFw4yTOMPMP9z2VMtf1+jExKGVy kmilsXgY6+GY9hAGiurheC8fxawPQYMRf5N0jzkRZIwvuwLsAmPYZKSz24JkTmxSb24a TZ6itAml+HkqwWbW1xVWrVzi4gP0/1NpCVKSMasLBXyzZscXmu0qZZ2m9yK+TBdeMGMq lGANV4MjiJ7WWqGPnSrVN9uM61T8FzxRIKd2OhIdjVaT4zENfRlKlJNWM8CgyO8dU02r Z1fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:to:from:date:dkim-signature:arc-authentication-results; bh=VaRPIwH9xnK54WBPtZD5PPZFVBrBUYCP6hbrqj5nj+A=; b=mLINyylxWMcfz2DQVV1r6+z8CQCDNFOXg3am4te70NQbUB0SUynd+kCJO+uWOnPxTO YTAZLsgDfVS9iDcPU2yP7RuYha9eD5SfLOaBdposqJsW8Iw+gNAzUHc23csR5+cBK/FM 4IQbdI3Er4iyrqNfIyfSHMDwNCTBQ3TFfqsWSFOvPOxcLkJ0o93cnOyxz9RH5YDDCxGK h1Snsc+vdw8fPCLDRt0AbBdj9wL2Vr/+WL9qz0B2vNXL+IJrcpeQqwXGlGIgIHF6Q1ZB v9yHsGbYGnkWxQG6sG0OYYMo0fZ+OTqZbl/fM3sNkE0Bs77zvrwaoXQsNpiHj194itEa RwHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=c4X3bokF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 70-v6si35572199pfu.274.2018.05.29.21.59.31; Tue, 29 May 2018 21:59:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=c4X3bokF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753605AbeE3E6r (ORCPT + 99 others); Wed, 30 May 2018 00:58:47 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33467 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750913AbeE3E6p (ORCPT ); Wed, 30 May 2018 00:58:45 -0400 Received: by mail-pg0-f66.google.com with SMTP id e21-v6so7577068pgv.0; Tue, 29 May 2018 21:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:user-agent:mime-version; bh=VaRPIwH9xnK54WBPtZD5PPZFVBrBUYCP6hbrqj5nj+A=; b=c4X3bokFaQujULNbac866gJ2hJCbstPRBsFBxil6DGYP/6bRFNXwZC1qgirfPxYEM2 Vwnp+YUQ1JLOrGCzJXJx5N4IdusSYbv/+j1v/GYNpfKdHcwEhc8eqIBheIi20eak9UtD cgQioedR+98nryrGEBtg2XZmPjUIxGbM2EyPnzyyjWeR7PU7Xo/rsUOsfIj8D9BXypwN s7GD6efKI0D/psVw41FtMvmMTxgteR3cAMN9DFfXm4uzKPNVgfbkEULggx6Igi30L3wk rysonUCa4TynZH8172qGe6WfOwmVipxZMPqPXv85ah+3xb/QTFAvqr6ZO7k+8m75oham yx/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:user-agent :mime-version; bh=VaRPIwH9xnK54WBPtZD5PPZFVBrBUYCP6hbrqj5nj+A=; b=igXerILtA5htIOyQ9p87mn+vGFnUcan+5SQyHEEbsS6gxNnVU9yeqEenxmk9ypsNvs pL3yCtP0M+RO+iGHuRhERw2Wrqnl6k+VwoS2npglT9/YNWnipTsovA12/n3flXb4qpb8 gZgmmsIsnI1i8GT0beB+tB4OUmlsKzRhzyL1YlUixIFGOxo4/zjMBO3NM7DGy+3sww1t 1qXg2z265+QsL4JwZ6EKFRw3kkpQvX4LcoJZymqKi7VD3o/yFg2po/B+DJ0YSEMem7wh wT50RFtozJS4jJcHK3WDhuy7clxRbB0nouTo+ZPIDhzBOSwzTwoU5Mc529nS2Mapx3zP I7zA== X-Gm-Message-State: ALKqPwePJN9nHG1t22s2qmIV8WmTVAFpioHSOCWcYtQV9+0t6I85vQAh RH+0MR9AkoU/fI/9+8Ou5G4= X-Received: by 2002:a62:211c:: with SMTP id h28-v6mr1237068pfh.249.1527656324419; Tue, 29 May 2018 21:58:44 -0700 (PDT) Received: from localhost.localdomain ([2601:600:8080:1297::c4cf]) by smtp.gmail.com with ESMTPSA id m22-v6sm66320805pfg.20.2018.05.29.21.58.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 21:58:43 -0700 (PDT) Date: Wed, 30 May 2018 00:58:36 -0400 (EDT) From: Gerb Stralko X-X-Sender: stralko@localhost.localdomain To: aviadye@mellanox.com, davejwatson@fb.com, davem@davemloft.net, ilyal@mellanox.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: WARNING in iov_iter_revert Message-ID: User-Agent: Alpine 2.20 (LFD 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, I'm in the process of fixing this bug (https://syzkaller.appspot.com/bug?id=1339e0a805a4ddb11eaee6fb6b1bc905493ded77) However, there are a couple things I'm trying to wrap my head around to understand and fix this issue properly. I'm using the C reproducer from syzkaller[1] to trigger this issue which has been a huge help in learning the Linux kernel. First in tls_sw.c in tls_sw_sendmsg we having the following: `do_tcp_sendpages `tls_push_sg `tls_push_record returns -EPIPE (-32) because sk->sk_shudown is set. See do_tcp_sendpages in net/ipv4/tcp.c Do we need to check for -EPIPE before continuing in tls_sw.c after tls_push_record, for example: if (ret == -EAGAIN || ret == -EPIPE) ^^^^^^^^^^^^^^ goto send_end; If -EPIPE is valid and we don't need to check for that particular condition then calling iov_iter_revert might be wrong because of the second argument: ctx->sg_plaintext_size - orig_size Because that statement will evaluate to -1 because ctx->sg_plaintext_size has been set to zero from earlier when calling: `free_sg `tls_push_sg And orig_size is set to 1 from the beginning of the while loop: orig_size = ctx->sg_plaintext_size So calling iov_iter_revert with the second argument being -1 will trigger the warning in lib/iov_iter.c:iov_iter_revert: if (WARN_ON(unroll > MAX_RW_COUNT)) return; Am I correct in thinking EPIPE should be checked after returning from tls_push_record? Or do we need to do some sanity checks on sg_plaintext_size and orig_size before calling iov_iter_revert? Any help would be greatly appreciated. [1] https://syzkaller.appspot.com/text?tag=ReproC&x=141d5417800000 On Sunday, May 13, 2018 at 9:28:03 AM UTC-7, syzbot wrote: > > Hello, > > syzbot found the following crash on: > > HEAD commit: 427fbe89261d Merge branch 'next' of git://git.kernel.org/p.. > > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=16b33477800000 > kernel config: https://syzkaller.appspot.com/x/.config?x=fcce42b221691ff9 > dashboard link: > https://syzkaller.appspot.com/bug?extid=c226690f7b3126c5ee04 > compiler: gcc (GCC) 8.0.1 20180413 (experimental) > syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=144f1997800000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=141d5417800000 > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > Reported-by: syzbot+c22669...@syzkaller.appspotmail.com > > random: sshd: uninitialized urandom read (32 bytes read) > random: sshd: uninitialized urandom read (32 bytes read) > random: sshd: uninitialized urandom read (32 bytes read) > random: sshd: uninitialized urandom read (32 bytes read) > random: sshd: uninitialized urandom read (32 bytes read) > WARNING: CPU: 1 PID: 4542 at lib/iov_iter.c:857 > iov_iter_revert+0x2ee/0xaa0 > lib/iov_iter.c:857 > Kernel panic - not syncing: panic_on_warn set ... > > CPU: 1 PID: 4542 Comm: syz-executor650 Not tainted 4.17.0-rc4+ #44 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS > Google 01/01/2011 > Call Trace: > __dump_stack lib/dump_stack.c:77 [inline] > dump_stack+0x1b9/0x294 lib/dump_stack.c:113 > panic+0x22f/0x4de kernel/panic.c:184 > __warn.cold.8+0x163/0x1b3 kernel/panic.c:536 > report_bug+0x252/0x2d0 lib/bug.c:186 > fixup_bug arch/x86/kernel/traps.c:178 [inline] > do_error_trap+0x1de/0x490 arch/x86/kernel/traps.c:296 > do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:315 > invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:992 > RIP: 0010:iov_iter_revert+0x2ee/0xaa0 lib/iov_iter.c:857 > RSP: 0018:ffff8801ad1bf700 EFLAGS: 00010293 > RAX: ffff8801ac55e6c0 RBX: 00000000ffffffff RCX: ffffffff835104a1 > RDX: 0000000000000000 RSI: ffffffff8351074e RDI: 0000000000000007 > RBP: ffff8801ad1bf760 R08: ffff8801ac55e6c0 R09: ffffed003b5e46c2 > R10: 0000000000000003 R11: 0000000000000001 R12: 0000000000000001 > R13: ffff8801ad1bfd60 R14: 0000000000000011 R15: ffff8801ae9ac040 > tls_sw_sendmsg+0xf1c/0x12d0 net/tls/tls_sw.c:448 > inet_sendmsg+0x19f/0x690 net/ipv4/af_inet.c:798 > sock_sendmsg_nosec net/socket.c:629 [inline] > sock_sendmsg+0xd5/0x120 net/socket.c:639 > ___sys_sendmsg+0x805/0x940 net/socket.c:2117 > __sys_sendmsg+0x115/0x270 net/socket.c:2155 > __do_sys_sendmsg net/socket.c:2164 [inline] > __se_sys_sendmsg net/socket.c:2162 [inline] > __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2162 > do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287 > entry_SYSCALL_64_after_hwframe+0x49/0xbe > RIP: 0033:0x4403a9 > RSP: 002b:00007ffdcdfbd6c8 EFLAGS: 00000207 ORIG_RAX: 000000000000002e > RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004403a9 > RDX: 0000000000000000 RSI: 0000000020001340 RDI: 0000000000000003 > RBP: 00000000006ca018 R08: 000000000000001c R09: 000000000000001c > R10: 0000000020000180 R11: 0000000000000207 R12: 0000000000401cd0 > R13: 0000000000401d60 R14: 0000000000000000 R15: 0000000000000000 > Dumping ftrace buffer: > (ftrace buffer empty) > Kernel Offset: disabled > Rebooting in 86400 seconds.. > > > --- > This bug is generated by a bot. It may contain errors. > See https://goo.gl/tpsmEJ for more information about syzbot. > syzbot engineers can be reached at syzk...@googlegroups.com . > > > syzbot will keep track of this bug report. See: > https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with > syzbot. > syzbot can test patches for this bug, for details see: > https://goo.gl/tpsmEJ#testing-patches >