Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp285540lqp; Thu, 21 Mar 2024 00:33:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWA5VLJVo7vCwR0OnsJgSMwjk61p9iZV2GcFDq7ZvyJYyf9m7dDl6IpLmta6fOwaZQNJ+W31dhiDx+erfzm0ZycDilPyFZbtCBYVXoSYQ== X-Google-Smtp-Source: AGHT+IEXdfFxgRScapluwHOUmppomKTA2x7wEqdL50wwpAtm8l1Mwjp+i+77UMwYKXZybRCzccQF X-Received: by 2002:a05:622a:5488:b0:42e:b90c:cffb with SMTP id ep8-20020a05622a548800b0042eb90ccffbmr25089618qtb.51.1711006413375; Thu, 21 Mar 2024 00:33:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711006413; cv=pass; d=google.com; s=arc-20160816; b=A/b02JZoQ90lKNfBee0QX9VCyX/+dpAWZfhRLyOXp/aQjV3X3dkGCrilFmY8T+7H7B oF4Q24VFkdpPagufRsqmsbygliTWkN2DsIm3vkljtm+eJsg5ZKXYOX9NLEwegchGyNsu ZJ6Es+5ps6YgSaiRSEMzjiKlFWKrQE+4kLAu/pCrA2DmZAvIbIZqxSmLM4B3rifsAJ2w SOvwDA4Hh6diFFEmZD3joewaw2fIbjp1iAgMaXPYnJw+/EP+8pTn31pVeYY+Y7ML1ID2 9EH41yv3CDcKyFy5fQN8LClerM6kQj0e/cGJRUGaBsN7XjFWCRqRuZp+gsAhoZTkTWrd hbsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=tG8H4iDFAc1t3qHbj1kNsgeA823fPcekBzV63RYaF6Y=; fh=nCR7vTgFXtUSK+rJA7V51ZJzg0AxQBHn81dWmLwupxI=; b=UGdomK419FodHc94mXD+yZjHHP4hFozs3bS1RVnNUhApmZgcbhRiFDNqUn6/i0SStN PEUNyDAQuy1NDcy/GU5DC4XnNe2+52a7aR894HokbJw5ZH+lfRvc2oJG+ziMaUcOKUgN RGcyX41lr9VKXKJLJZ0/+PVA2xm4jQKSPGhFhc/cDGrQA23u2v2d5+D7vxwes4e7MkOB 9QBoGxyDfXn6jFUliMudCYJRiuTqqeW5jy70TRBKGna2DyxhuciKYQ+H2362l9ICn4Ng XEQ6vfAMxuGzNPaVzkecvOM/vb7HUa5qSdpetyDztW5q2rQajAtgvz/mMg88361oeUt9 29ig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=H5iu9dpJ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-109730-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109730-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x12-20020ac85f0c000000b0042f24bbdb91si12571969qta.695.2024.03.21.00.33.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 00:33:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109730-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=H5iu9dpJ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-109730-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109730-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9978C1C2105F for ; Thu, 21 Mar 2024 07:33:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1193458124; Thu, 21 Mar 2024 07:33:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H5iu9dpJ" Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32D4D50249; Thu, 21 Mar 2024 07:33:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711006396; cv=none; b=G58VLFwVswb3bAr8bfX6O2ktQiLgDaKKFlcdnyVeNdQRXUGGDueyeiVBt8a3cGicIWuy1xt5o0E/gysuRlMfDcvQXLQWcp2k1rX7CtNv/1W4tjhSLhYSi8iswlEuBipG57QRmksjeSAwXcaSAQpYPDP7AaAu+7UpDd1DIva71Ys= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711006396; c=relaxed/simple; bh=lfzYv1h/czzT9o64k4FnzumtWG84f3GYHXjhGITWGuk=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ULDBPT+9SIu7dxDAZqehQCWtjNrrpYqHM3o4CKG0lVWRKJs6HynHxYleugqQPGTWugpf0X3eoEgPiJxqg6DIfb+ItsMcOppad2/tpurSjeMVTbfOeAinu1S/hlAA9uwMD4PFJgRryRLjO6R1BJR7BybVBO87/ETuHJpVhg1etn0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=H5iu9dpJ; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-512e39226efso556020e87.0; Thu, 21 Mar 2024 00:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711006392; x=1711611192; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=tG8H4iDFAc1t3qHbj1kNsgeA823fPcekBzV63RYaF6Y=; b=H5iu9dpJIKM4W0dQ1UDl4PQiT+epi4Pv9u8lY/B7zQg/2tMabFqNaYvM7aVktEcz0q 4EkPppBs3G0wN5AH12LqoXbvpRaQIf6JHW1+w3uBCJJ5D2gLJ+sLRKIHYoFaVm8qPC6Q dH6jipdhjTUP+EPDcFGJpvW+uJQ3jY8n7x3BgkEXPsCo43OLgSXxXT8+HAkvLjXR5u2Y va7XeaBY83ZT1UhJvYCy7AMyeUtIw2uM/rINP1bFwfS/nQ07Knb9MdSJiyhKpeTE4MDA C/K4KZmkyBxIKHCQPKZbdpQoxHwJxNiDp66QthCCzNxP826wuE2ypcAXSXiogPOafd3c a7RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711006392; x=1711611192; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tG8H4iDFAc1t3qHbj1kNsgeA823fPcekBzV63RYaF6Y=; b=LpMSPJKCT3LdLqKWpQevQng6nJeqNnDDrJxlPRu41cAHA0oWEZuqnJkKa3YOjg9p8R SOezB00xo9eBm3d+xXJn1Whe+nsZwQCIwYn3KdGE7ffseAcoC6Z0RN5IrnECDYty+dmP KxOcn7IcgkoxobDwaNf1kmRpYGYHJf4YaD0m1eO65pliEbAGMzgN2PaV3WlpLUmsXsg8 eqLZ0aWrNMbsCi4w6LXTTi7zOh26npaiMx+fLZrZR3622nUFbkTipUTWiojsh9JQzxVl 31wYisfOt2g1fRjkqUyL9rR1NHqPwY37//JE1eeA2GgW3sxl2YZk1MFLsGwCwhTdEDf9 5ZNg== X-Forwarded-Encrypted: i=1; AJvYcCUYy8feWioiBS2lv49ptXT8y0kZsE3ETHWzZatG7s+jVEjgLv3c5yBERrnt3Bi7agOMLb1PHV/9FbCZuQlc25CID+hKtJjB/cLfevFpbhowMyKwei8v70QyfagE5G3YVv4SGINe164K7v/BfCgQk1QuOvUK2AQpl+WS X-Gm-Message-State: AOJu0Yx/U1x1YQiL178qfjUoV8guYLeJAlmaTG0nfwCNpxIUzcOud5NC b8QWvma73FTdusNBgouvV3MeYkK2MCWfAvno5ScZDoub00mhAx7m6RS+vydS7FtrmZ0JU2R+qzV ivWUtfj1qaVgHRMPxo/aTBxPgNds= X-Received: by 2002:a19:8c5d:0:b0:513:a1eb:c084 with SMTP id i29-20020a198c5d000000b00513a1ebc084mr2105258lfj.7.1711006391935; Thu, 21 Mar 2024 00:33:11 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <0000000000003dc8e00614076ab6@google.com> In-Reply-To: <0000000000003dc8e00614076ab6@google.com> From: Alexei Starovoitov Date: Thu, 21 Mar 2024 00:33:00 -0700 Message-ID: Subject: stack access issue. Re: [syzbot] [bpf?] UBSAN: array-index-out-of-bounds in check_stack_range_initialized To: Andrei Matei Cc: Andrii Nakryiko , Alexei Starovoitov , bpf , Daniel Borkmann , Eddy Z , Hao Luo , John Fastabend , Jiri Olsa , KP Singh , LKML , Martin KaFai Lau , Network Development , Stanislav Fomichev , Song Liu , syzkaller-bugs , Yonghong Song Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Andrei, looks like the refactoring of stack access introduced a bug. See the reproducer below. positive offsets are not caught by check_stack_access_within_bounds(). So both slot and spi become negative and access stack[spi].slot_type[slot % BPF_REG_SIZE] returns garbage. On Tue, Mar 19, 2024 at 11:12=E2=80=AFAM syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit: 0740b6427e90 Merge branch 'bpf-arena-followups' > git tree: bpf > console+strace: https://syzkaller.appspot.com/x/log.txt?x=3D12fed76918000= 0 > kernel config: https://syzkaller.appspot.com/x/.config?x=3D6fb1be60a193d= 440 > dashboard link: https://syzkaller.appspot.com/bug?extid=3D33f4297b5f92764= 8741a > compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Deb= ian) 2.40 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=3D1763a479180= 000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=3D15c3871118000= 0 > > Downloadable assets: > disk image: https://storage.googleapis.com/syzbot-assets/c9e6e9f97566/dis= k-0740b642.raw.xz > vmlinux: https://storage.googleapis.com/syzbot-assets/78476a588b62/vmlinu= x-0740b642.xz > kernel image: https://storage.googleapis.com/syzbot-assets/50cd6fab9ead/b= zImage-0740b642.xz > > IMPORTANT: if you fix the issue, please add the following tag to the comm= it: > Reported-by: syzbot+33f4297b5f927648741a@syzkaller.appspotmail.com > > ------------[ cut here ]------------ > UBSAN: array-index-out-of-bounds in kernel/bpf/verifier.c:7190:12 > index -1 is out of range for type 'u8[8]' (aka 'unsigned char[8]') > CPU: 0 PID: 5071 Comm: syz-executor474 Not tainted 6.8.0-syzkaller-05226-= g0740b6427e90 #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS G= oogle 02/29/2024 > Call Trace: > > __dump_stack lib/dump_stack.c:88 [inline] > dump_stack_lvl+0x1e7/0x2e0 lib/dump_stack.c:106 > ubsan_epilogue lib/ubsan.c:217 [inline] > __ubsan_handle_out_of_bounds+0x121/0x150 lib/ubsan.c:415 > check_stack_range_initialized+0x1668/0x19a0 kernel/bpf/verifier.c:7190 > check_helper_mem_access+0x2eb/0xfa0 kernel/bpf/verifier.c:7294 > check_helper_call+0x263c/0x7220 kernel/bpf/verifier.c:10252 > do_check+0x9e29/0x10530 kernel/bpf/verifier.c:17801 > do_check_common+0x14bd/0x1dd0 kernel/bpf/verifier.c:20500 > do_check_main kernel/bpf/verifier.c:20591 [inline] > bpf_check+0x136ab/0x19010 kernel/bpf/verifier.c:21261 > bpf_prog_load+0x1667/0x20f0 kernel/bpf/syscall.c:2895 > __sys_bpf+0x4ee/0x810 kernel/bpf/syscall.c:5631 > __do_sys_bpf kernel/bpf/syscall.c:5738 [inline] > __se_sys_bpf kernel/bpf/syscall.c:5736 [inline] > __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5736 > do_syscall_64+0xfb/0x240 > entry_SYSCALL_64_after_hwframe+0x6d/0x75 > RIP: 0033:0x7f8416194629 > Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 48 89 f8 48 89 f= 7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff= ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 > RSP: 002b:00007ffdc6f0fdb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141 > RAX: ffffffffffffffda RBX: 00007ffdc6f0ff88 RCX: 00007f8416194629 > RDX: 0000000000000090 RSI: 00000000200000c0 RDI: 0000000000000005 > RBP: 00007f8416207610 R08: 0000000000000000 R09: 00007ffdc6f0ff88 > R10: 00000000fffffff8 R11: 0000000000000246 R12: 0000000000000001 > R13: 00007ffdc6f0ff78 R14: 0000000000000001 R15: 0000000000000001 > > ---[ end trace ]--- > > > --- > This report 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 syzkaller@googlegroups.com. > > syzbot will keep track of this issue. See: > https://goo.gl/tpsmEJ#status for how to communicate with syzbot. > > If the report is already addressed, let syzbot know by replying with: > #syz fix: exact-commit-title > > If you want syzbot to run the reproducer, reply with: > #syz test: git://repo/address.git branch-or-commit-hash > If you attach or paste a git patch, syzbot will apply it before testing. > > If you want to overwrite report's subsystems, reply with: > #syz set subsystems: new-subsystem > (See the list of subsystem names on the web dashboard) > > If the report is a duplicate of another one, reply with: > #syz dup: exact-subject-of-another-report > > If you want to undo deduplication, reply with: > #syz undup