Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6376745rwb; Mon, 14 Nov 2022 19:38:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf6htOlKYcAcdx/Wocjp3pteU+Son7wLrSbuLoDKjd0aXcJOe4WXbic6e3uV6jmlV5shkofE X-Received: by 2002:a17:90b:3d3:b0:213:2411:50e7 with SMTP id go19-20020a17090b03d300b00213241150e7mr164309pjb.212.1668483527420; Mon, 14 Nov 2022 19:38:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668483527; cv=none; d=google.com; s=arc-20160816; b=Fua+gXpMioftrfk0fnnci6MGYoR0dyWz7bsYL2cRRItR9POR1u/As8JRv1N0E2NTIv kYdf67w+3/5JSvhr3N5BLpQpoNTjGxICVd+fdVM5oeMcNaWwTglV4oNY7/tvwwvlFzj6 cWl/8fWJeIy7nlvlCfqaK7rWLPqRuvWZ8OrwR4w6YVc54Lx0sLr6t2nhZ0znEIc4A5Pv fDo2EtJxsa/kSwBfJjx5Uko+RyEmB7L0P7im/RRXThAt9j+Fpx+J7v2eGWMG72168Ngd 8QzFVT9pCzzAzYTEq8tGN6A+0A1OfyzRSLqxTDnMQ9yvOXVwg/zzAMofi3X1WdYZQeWE Z1fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=RYv8PbYu2PHK0NjQFTHVtdcu8ZHP+IFS6J5Lg3l3r38=; b=xHuLgpDb8G6ffc5aFxiLW35Uq9DM4pOwO9mMnh6uFGl3Xr72TFXfzrFeKi6fZwabmL 1+ZuD+EXjv729H+31WDHuHMIUoUTXCXhqk7pmxcDNKpOnQO0fzFvhfEXvnlTMZsRmAzf c7uLSGLjcOFkjDVvXFP/C7MlTTa/pFNT0u1EjjNq1R2t4jmLEQ7FxqclDuh/dRGwEr1y 5MPDOFtNJwPk4fFBKqRY17NxsbQQ5gt+c6GPP+It/IabjqTOUPuhB7RgBPum2jyzWuLV 36f2YhdP8d/Yus/Guj4cOd9dsXqRzalPtqlrnd0faI5F1TQQ5RUCpG1P/4nuD2a2JkJg oHIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f14-20020a170902ce8e00b00186b1459953si12144749plg.382.2022.11.14.19.38.36; Mon, 14 Nov 2022 19:38:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231851AbiKOCdW (ORCPT + 88 others); Mon, 14 Nov 2022 21:33:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229967AbiKOCdU (ORCPT ); Mon, 14 Nov 2022 21:33:20 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC612FD27 for ; Mon, 14 Nov 2022 18:33:18 -0800 (PST) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NB9Fl4N0kzRpDv; Tue, 15 Nov 2022 10:32:59 +0800 (CST) Received: from huawei.com (10.67.174.53) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 15 Nov 2022 10:33:16 +0800 From: Liao Chang To: CC: , , Subject: [PATCH] jfs: Fix out-of-bounds access on dtSearch Date: Tue, 15 Nov 2022 10:30:09 +0800 Message-ID: <20221115023009.251044-1-liaochang1@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.53] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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-kernel@vger.kernel.org BUG: KASAN: slab-out-of-bounds in dtSearch+0x1d92/0x2000 Read of size 1 at addr ffff888134497f94 by task syz-executor.2/8793 CPU: 0 PID: 8793 Comm: syz-executor.2 Tainted: G W 6.0.0-07994-ge8bc52cb8df8 #9 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 Call Trace: dump_stack_lvl+0xcd/0x134 print_report.cold+0x2ba/0x719 kasan_report+0xb1/0x1e0 dtSearch+0x1d92/0x2000 jfs_lookup+0x17c/0x2f0 __lookup_slow+0x24c/0x460 walk_component+0x33f/0x5a0 link_path_walk.part.0.constprop.0+0x715/0xd80 path_lookupat+0x92/0x760 filename_lookup+0x1d2/0x590 user_path_at_empty+0x42/0x60 __x64_sys_chdir+0xb7/0x260 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The out-of-bounds access occurs in macro ciToUpper, which converts the unicode character in ciKey.name into uppercase, this upper operation will stop when it meets a terminal character(digit 0), so it needs to set the last character to zero to ensure upper can stop in valid range. Signed-off-by: Liao Chang --- fs/jfs/jfs_dtree.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c index 92b7c533407c..0c3af64abcfd 100644 --- a/fs/jfs/jfs_dtree.c +++ b/fs/jfs/jfs_dtree.c @@ -592,6 +592,7 @@ int dtSearch(struct inode *ip, struct component_name * key, ino_t * data, /* uppercase search key for c-i directory */ UniStrcpy(ciKey.name, key->name); ciKey.namlen = key->namlen; + ciKey.name[ciKey.namlen] = 0; /* only uppercase if case-insensitive support is on */ if ((JFS_SBI(sb)->mntflag & JFS_OS2) == JFS_OS2) { -- 2.17.1