Web lists-archives.com

net/bonding: stack-out-of-bounds in bond_enslave




Hi,

I've got the following error report while fuzzing the kernel with syzkaller.

On linux-next commit 4f7d029b9bf009fbee76bb10c0c4351a1870d2f3 (4.11-rc7).

A reproducer and .config are attached.

==================================================================
BUG: KASAN: stack-out-of-bounds in bond_enslave+0xe0a/0x4ef0 at addr
ffff8800666b7792
Write of size 16 by task a.out/3894
page:ffffea000199adc0 count:0 mapcount:0 mapping:          (null) index:0x0
flags: 0x100000000000000()
raw: 0100000000000000 0000000000000000 0000000000000000 00000000ffffffff
raw: 0000000000000000 ffffea000199ade0 0000000000000000 0000000000000000
page dumped because: kasan: bad access detected
CPU: 1 PID: 3894 Comm: a.out Not tainted 4.11.0-rc7+ #251
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:16
 dump_stack+0x292/0x398 lib/dump_stack.c:52
 kasan_report_error mm/kasan/report.c:212
 kasan_report+0x4d8/0x510 mm/kasan/report.c:347
 check_memory_region_inline mm/kasan/kasan.c:326
 check_memory_region+0x139/0x190 mm/kasan/kasan.c:333
 memcpy+0x37/0x50 mm/kasan/kasan.c:369
 bond_enslave+0xe0a/0x4ef0 drivers/net/bonding/bond_main.c:1491
 bond_do_ioctl+0xb5d/0xec0 drivers/net/bonding/bond_main.c:3449
 dev_ifsioc+0x53f/0x9f0 net/core/dev_ioctl.c:338
 dev_ioctl+0x249/0x1160 net/core/dev_ioctl.c:532
 sock_do_ioctl+0x94/0xb0 net/socket.c:913
 sock_ioctl+0x28f/0x440 net/socket.c:1004
 vfs_ioctl fs/ioctl.c:45
 do_vfs_ioctl+0x1bf/0x1780 fs/ioctl.c:685
 SYSC_ioctl fs/ioctl.c:700
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691
 entry_SYSCALL_64_fastpath+0x1f/0xc2 arch/x86/entry/entry_64.S:204
RIP: 0033:0x7fc764b31b79
RSP: 002b:00007ffc1d73aa58 EFLAGS: 00000206 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffc1d73abb0 RCX: 00007fc764b31b79
RDX: 00000000209eafd8 RSI: 0000008000008990 RDI: 0000000000000003
RBP: 00000000004004e0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000000
R13: 00007ffc1d73abb0 R14: 0000000000000000 R15: 0000000000000000
Memory state around the buggy address:
 ffff8800666b7680: f2 f2 00 f2 f2 f2 f2 f2 f2 f2 f8 f2 f2 f2 f2 f2
 ffff8800666b7700: f2 f2 00 f2 f2 f2 f2 f2 f2 f2 00 f2 f2 f2 f2 f2
>ffff8800666b7780: f2 f2 00 00 f2 f2 f3 f3 f3 f3 00 00 00 00 00 00
                               ^
 ffff8800666b7800: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 f2 f2 f2
 ffff8800666b7880: f2 f2 f2 f2 00 04 f2 f2 f2 f2 f2 f2 00 00 00 f2
==================================================================
// autogenerated by syzkaller (http://github.com/google/syzkaller)

#ifndef __NR_mmap
#define __NR_mmap 9
#endif
#ifndef __NR_socket
#define __NR_socket 41
#endif
#ifndef __NR_ioctl
#define __NR_ioctl 16
#endif

#define _GNU_SOURCE

#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>

#include <linux/capability.h>
#include <linux/if.h>
#include <linux/if_tun.h>
#include <linux/kvm.h>
#include <linux/sched.h>
#include <net/if_arp.h>

#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <pthread.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

static uintptr_t execute_syscall(int nr, uintptr_t a0, uintptr_t a1,
                                 uintptr_t a2, uintptr_t a3,
                                 uintptr_t a4, uintptr_t a5,
                                 uintptr_t a6, uintptr_t a7,
                                 uintptr_t a8)
{
  switch (nr) {
  default:
    return syscall(nr, a0, a1, a2, a3, a4, a5);
  }
}

long r[5];
void main()
{
  memset(r, -1, sizeof(r));
  r[0] = execute_syscall(__NR_mmap, 0x20000000ul, 0xffb000ul, 0x3ul,
                         0x32ul, 0xfffffffffffffffful, 0x0ul, 0, 0, 0);
  r[1] = execute_syscall(__NR_socket, 0x2ul, 0x1ul, 0x0ul, 0, 0, 0, 0,
                         0, 0);
  (memcpy((void*)0x209eafd8,
                    "\x62\x6f\x6e\x64\x30\x00\x00\x00\x00\x00\x00\x00"
                    "\x00\x00\x00\x00",
                    16));
  (memcpy((void*)0x209eafe8,
                    "\x69\x70\x36\x74\x6e\x6c\x30\x00\x00\x00\x00\x00"
                    "\x00\x00\x00\x00",
                    16));
  r[4] = execute_syscall(__NR_ioctl, r[1], 0x8000008990ul, 0x209eafd8ul,
                         0, 0, 0, 0, 0, 0);
}

Attachment: .config
Description: Binary data