Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2361398rwr; Fri, 21 Apr 2023 07:57:07 -0700 (PDT) X-Google-Smtp-Source: AKy350ax+g3oqPbTALcNthxfA9f8eqlZGher4r8k1bgwvOhZa3TmiEKWFQWCsG8FO+gRgUZNYCF+ X-Received: by 2002:a05:6a20:3942:b0:e3:763e:555 with SMTP id r2-20020a056a20394200b000e3763e0555mr7246632pzg.57.1682089026919; Fri, 21 Apr 2023 07:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682089026; cv=none; d=google.com; s=arc-20160816; b=WBfyqZh4sAqf45IFQ6Ozpbv8XCIH3xxaZXE9EsJJ29glT9zZYB0jNEt8MHEtLLPbt0 6UzFo8XiVRVfMPwfMwiHD0pk1SzVkHy1eauF5RViJn9pjgg/A+XF+0MGXHFBchvrAzlu 0BvqbxDK2iWlceY1H2CgruD5QStm61mev75xdlzXiRkdjn2y9JgYQDqhMyAkFM8z3KY3 onJGZpEllBKAZiU45iE9HxwxI8+xLE3GfztI6hUPhtCg46ot6psuA3GEQL/vE6DkOK49 ktaqvm7qidYl6Stx4FfQWyDvHUh4d/x622bSSCoGXQbHvf9Bw/iV/nSuzigP/3ttXHZQ L7jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=8B725ZBKfP0GpWx9JPfGFqkXbZvh/CpPapZ/L8/4CIg=; b=wWFdcSjP15o2CALqUr22xaiTFEmMOSWQ/hGjQ3F5d+xfM5hklnNwel9B48CXtwKhpJ ns6K58t26LXW5ClGtlbVeHsJA+20i0DaRvNIhy577vQzYjzwchPS1wLNkFsN+N6E/4j2 JMEiLhJsUEYAadax5QDlIRwr+pEI0wIotBg4jWLafxxbLMwGsbV7vT0LPmTtQI3g1UEB 54l4fXt0eZn+C2gg5tDkEqJoaCR0ye8jeIFnt9mCeFd9ne/6jj2Ha3KT2TtZYFY7qN4k 4uQ9cU1Ul3U3fMY7SjIwJNKOVnEALXXLRnM/ediZdYbPFnioPZrre2wCiS5c9Id2EE5n VrHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="vfAbBNK/"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q23-20020aa79837000000b0063b80f4bfa6si4477787pfl.132.2023.04.21.07.56.46; Fri, 21 Apr 2023 07:57:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="vfAbBNK/"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232635AbjDUOon (ORCPT + 99 others); Fri, 21 Apr 2023 10:44:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232904AbjDUOok (ORCPT ); Fri, 21 Apr 2023 10:44:40 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B252110D8 for ; Fri, 21 Apr 2023 07:44:14 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4edc63e066fso7030e87.1 for ; Fri, 21 Apr 2023 07:44:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682088212; x=1684680212; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=8B725ZBKfP0GpWx9JPfGFqkXbZvh/CpPapZ/L8/4CIg=; b=vfAbBNK/+7FEiarLloglLl9iO8FTuYu+DqjWSf1EILAEkpr/+RBkwZVWJpJiwz3O2w lZAFTrwKio3jZyQKQtc470ZsIRvz7dqV+4FYhWi+ycNv1Cmr61/d3PASWu3I4rsI267U SwhwivkYP4Lm+x6AKgkv6z5kMY17enk2SCRkaZZPatYuVT0jFFeKbnOjgjYPv5qodA5D kLYikZQKJmJjMUWj+y94YZ1pmg7HgNlPys+sI0FSrdXR23dGz6qhjYupAB8V2uamfuCo oiz3ci1vlDssHste7IM3UV+NolCsno7yAYGHFYCwiJWVOq9VRavVUbA9WMg+7hjTUesw hKKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682088212; x=1684680212; h=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=8B725ZBKfP0GpWx9JPfGFqkXbZvh/CpPapZ/L8/4CIg=; b=kUlLEQHjQZL6etOYwJ+6Ta1Hywfa291IP5pFhNzu+JG6G98IzjcNILd5jx/OH1S5RT 4J8yUOBD2hD3iHDahNSn7Ks8hLLLaE88Vnlfa6o9r+rpIuSZTWdBhqsuMCgBkikEmBPe 4vfXkqeoQ7vVTycUPm2DSR1r9IkfI+0LqJHXembDCjA44MrFjuWjihDFncfMLEAUitlb V3NHN1/KKPwuPrTpZIrck8VqBkMTzjdNOIswqjmkYGUm1Vw0VquRP06+pUxAnXP6UZsn PpJgxucvbXUjBAjmVtI3ls+6ua2ffklDr07dvGE0Rde6dNVRJiUHUZ5R1No2YoM7gtRw ZaQg== X-Gm-Message-State: AAQBX9con+WoSpD3xi35C+3lbYrLoc4rjDO091Y/ZKCNUurfc3SQjkcY G+U15FfFjpZdOTSWxnXr5Neqw/jvS44GpJ0gn/h7vA== X-Received: by 2002:a05:6512:1319:b0:4e9:d785:37cb with SMTP id x25-20020a056512131900b004e9d78537cbmr123998lfu.1.1682088211800; Fri, 21 Apr 2023 07:43:31 -0700 (PDT) MIME-Version: 1.0 References: <000000000000b9915d05f9d98bdd@google.com> In-Reply-To: <000000000000b9915d05f9d98bdd@google.com> From: Dmitry Vyukov Date: Fri, 21 Apr 2023 16:43:19 +0200 Message-ID: Subject: Re: [syzbot] [ext4?] [mm?] KCSAN: data-race in strscpy / strscpy (3) To: syzbot Cc: adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, llvm@lists.linux.dev, nathan@kernel.org, ndesaulniers@google.com, syzkaller-bugs@googlegroups.com, trix@redhat.com, tytso@mit.edu, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , martin.lau@linux.dev, bpf , KP Singh Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, 21 Apr 2023 at 16:33, syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit: 76f598ba7d8e Merge tag 'for-linus' of git://git.kernel.org.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=133bfbedc80000 > kernel config: https://syzkaller.appspot.com/x/.config?x=9c5d44636e91081b > dashboard link: https://syzkaller.appspot.com/bug?extid=c2de99a72baaa06d31f3 > compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2 > > Unfortunately, I don't have any reproducer for this issue yet. > > Downloadable assets: > disk image: https://storage.googleapis.com/syzbot-assets/a3654f5f77b9/disk-76f598ba.raw.xz > vmlinux: https://storage.googleapis.com/syzbot-assets/abfb4aaa5772/vmlinux-76f598ba.xz > kernel image: https://storage.googleapis.com/syzbot-assets/789fb5546551/bzImage-76f598ba.xz > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+c2de99a72baaa06d31f3@syzkaller.appspotmail.com +bpf maintainers If I am reading this correctly, this can cause a leak of kernel memory and/or crash via bpf_get_current_comm helper. strcpy() can temporary leave comm buffer non-0 terminated as it terminates it only after the copy: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/string.c?id=76f598ba7d8e2bfb4855b5298caedd5af0c374a8#n184 If bpf_get_current_comm() observes such non-0-terminated comm, it will start reading off bounds. > ================================================================== > BUG: KCSAN: data-race in strscpy / strscpy > > write to 0xffff88812ed8b730 of 8 bytes by task 16157 on cpu 1: > strscpy+0xa9/0x170 lib/string.c:165 > strscpy_pad+0x27/0x80 lib/string_helpers.c:835 > __set_task_comm+0x46/0x140 fs/exec.c:1232 > set_task_comm include/linux/sched.h:1984 [inline] > __kthread_create_on_node+0x2b2/0x320 kernel/kthread.c:474 > kthread_create_on_node+0x8a/0xb0 kernel/kthread.c:512 > ext4_run_lazyinit_thread fs/ext4/super.c:3848 [inline] > ext4_register_li_request+0x407/0x650 fs/ext4/super.c:3983 > __ext4_fill_super fs/ext4/super.c:5480 [inline] > ext4_fill_super+0x3f4a/0x43f0 fs/ext4/super.c:5637 > get_tree_bdev+0x2b1/0x3a0 fs/super.c:1303 > ext4_get_tree+0x1c/0x20 fs/ext4/super.c:5668 > vfs_get_tree+0x51/0x190 fs/super.c:1510 > do_new_mount+0x200/0x650 fs/namespace.c:3042 > path_mount+0x498/0xb40 fs/namespace.c:3372 > do_mount fs/namespace.c:3385 [inline] > __do_sys_mount fs/namespace.c:3594 [inline] > __se_sys_mount+0x27f/0x2d0 fs/namespace.c:3571 > __x64_sys_mount+0x67/0x80 fs/namespace.c:3571 > do_syscall_x64 arch/x86/entry/common.c:50 [inline] > do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 > entry_SYSCALL_64_after_hwframe+0x63/0xcd > > read to 0xffff88812ed8b733 of 1 bytes by task 16161 on cpu 0: > strscpy+0xde/0x170 lib/string.c:174 > ____bpf_get_current_comm kernel/bpf/helpers.c:260 [inline] > bpf_get_current_comm+0x45/0x70 kernel/bpf/helpers.c:252 > ___bpf_prog_run+0x281/0x3050 kernel/bpf/core.c:1822 > __bpf_prog_run32+0x74/0xa0 kernel/bpf/core.c:2043 > bpf_dispatcher_nop_func include/linux/bpf.h:1124 [inline] > __bpf_prog_run include/linux/filter.h:601 [inline] > bpf_prog_run include/linux/filter.h:608 [inline] > __bpf_trace_run kernel/trace/bpf_trace.c:2263 [inline] > bpf_trace_run4+0x9f/0x140 kernel/trace/bpf_trace.c:2304 > __traceiter_sched_switch+0x3a/0x50 include/trace/events/sched.h:222 > trace_sched_switch include/trace/events/sched.h:222 [inline] > __schedule+0x7e7/0x8e0 kernel/sched/core.c:6622 > schedule+0x51/0x80 kernel/sched/core.c:6701 > schedule_preempt_disabled+0x10/0x20 kernel/sched/core.c:6760 > kthread+0x11c/0x1e0 kernel/kthread.c:369 > ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 > > value changed: 0x72 -> 0x34 > > Reported by Kernel Concurrency Sanitizer on: > CPU: 0 PID: 16161 Comm: ext4lazyinit Not tainted 6.3.0-rc5-syzkaller-00022-g76f598ba7d8e #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/2023 > ================================================================== > > > --- > 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.