Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1815763rwb; Mon, 7 Nov 2022 06:11:38 -0800 (PST) X-Google-Smtp-Source: AMsMyM7c/fjsa6YNhU022Esrqa5gXzk+A6mBSulLhAvu26aBVET95NYrdz+nREweILhQe+C29M4v X-Received: by 2002:a05:6a00:1916:b0:56d:4c7e:7790 with SMTP id y22-20020a056a00191600b0056d4c7e7790mr43129774pfi.32.1667830298680; Mon, 07 Nov 2022 06:11:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667830298; cv=none; d=google.com; s=arc-20160816; b=zNDRZJ42dA8RGqHeMYU9JNChujl2Z/j3PoG5LRjq56RH64PtBEVod7indOBx+cNr7u +c5+ZBjGmriNQIann3v/h7zGso0w4d1kHnyi22ic00iXGPWdN0BYEW3J8H9JcI9zm911 BvLi5uaASyJde1h1XH1LGLxpixZFMRHDY/xwM83WAD8qc4CqK7g3dRMEuHBJv13DcNvr prgprv11rOWJlbG1+9fG5xoFjN6HiBVwAvXO76AJENiSzqAf2p/Ev+fYJUb8YJYAYfPi INhvdKvnhHlt4bBx3eKf3XMttcvcVKFwS1p0jH43QKQ9jRdwOKGcy7M4SLLIa73qKhMK jE/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=YfiQrrff0GzCl9ZAWleIbyg070L8NqRvsHG9RAn2Avs=; b=RYw2zZ/e569oPqRg4vIsZoZ/4oDo2GDuTx10tqE4QvlCalhyy34Gdb2mujI81vvqvA Dr7lCnU2mZmH8M8/nK/0xFV4FacLojpdW2nhCItQFid16VZlsZ4JPoNATTlWfdp89uXY ZyRTUxaDySEv7BKGeykCSjFN6ckosuuIiWz0k8NwV9Wm5CxFkX978F58uD4rwnoFohjg 4jufkceDSJjBcLRfLYV40XGU0xkDq0pHnr9B5rJYxF6S5g+zbPM82ZrDq12sWQi3kBpw xHOde/CsV3l+QtpiUYZz0Jb7bU5YRXtt9Vzj8IN+mbChEQcYO5h3ELegs5P/oqUWOPys UI4A== 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 nu6-20020a17090b1b0600b00212e4f02881si12251071pjb.177.2022.11.07.06.11.24; Mon, 07 Nov 2022 06:11:38 -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 S231600AbiKGNbq (ORCPT + 94 others); Mon, 7 Nov 2022 08:31:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231365AbiKGNbn (ORCPT ); Mon, 7 Nov 2022 08:31:43 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3AA01CB09 for ; Mon, 7 Nov 2022 05:31:41 -0800 (PST) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N5XB04tKZzJnXT; Mon, 7 Nov 2022 21:28:40 +0800 (CST) Received: from [10.174.176.230] (10.174.176.230) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 7 Nov 2022 21:31:39 +0800 Message-ID: Date: Mon, 7 Nov 2022 21:31:38 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.0 Subject: Re: [PATCH 1/2] tracing: kprobe: Fix potential null-ptr-deref on trace_event_file in kprobe_event_gen_test_exit() To: "Masami Hiramatsu (Google)" CC: , , References: <20221107071617.21644-1-shangxiaojing@huawei.com> <20221107071617.21644-2-shangxiaojing@huawei.com> <20221107222540.1701bb267fd523fbafbbdee8@kernel.org> From: shangxiaojing In-Reply-To: <20221107222540.1701bb267fd523fbafbbdee8@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.230] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 On 2022/11/7 21:25, Masami Hiramatsu (Google) wrote: > On Mon, 7 Nov 2022 15:16:16 +0800 > Shang XiaoJing wrote: > >> When trace_get_event_file() failed, gen_kretprobe_test will be assigned >> as the error code. If module kprobe_event_gen_test is removed now, the >> null pointer dereference will happen in kprobe_event_gen_test_exit(). >> Check if gen_kprobe_test or gen_kretprobe_test is error code or NULL >> before dereference them. >> >> BUG: kernel NULL pointer dereference, address: 0000000000000012 >> PGD 0 P4D 0 >> Oops: 0000 [#1] SMP PTI >> CPU: 3 PID: 2210 Comm: modprobe Not tainted >> 6.1.0-rc1-00171-g2159299a3b74-dirty #217 >> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS >> rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 >> RIP: 0010:kprobe_event_gen_test_exit+0x1c/0xb5 [kprobe_event_gen_test] >> Code: Unable to access opcode bytes at 0xffffffff9ffffff2. >> RSP: 0018:ffffc900015bfeb8 EFLAGS: 00010246 >> RAX: ffffffffffffffea RBX: ffffffffa0002080 RCX: 0000000000000000 >> RDX: ffffffffa0001054 RSI: ffffffffa0001064 RDI: ffffffffdfc6349c >> RBP: ffffffffa0000000 R08: 0000000000000004 R09: 00000000001e95c0 >> R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000800 >> R13: ffffffffa0002420 R14: 0000000000000000 R15: 0000000000000000 >> FS: 00007f56b75be540(0000) GS:ffff88813bc00000(0000) >> knlGS:0000000000000000 >> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 >> CR2: ffffffff9ffffff2 CR3: 000000010874a006 CR4: 0000000000330ee0 >> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 >> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 >> Call Trace: >> >> __x64_sys_delete_module+0x206/0x380 >> ? lockdep_hardirqs_on_prepare+0xd8/0x190 >> ? syscall_enter_from_user_mode+0x1c/0x50 >> do_syscall_64+0x3f/0x90 >> entry_SYSCALL_64_after_hwframe+0x63/0xcd >> >> Fixes: 64836248dda2 ("tracing: Add kprobe event command generation test module") > > Ah, indeed. If anything wrong in the test code and if the > gen_kprobe_test/gen_kretprobe_test is not initialized, this > can happen. > > Cc: stable@vger.kernel.org > Acked-by: Masami Hiramatsu (Google) > > Thank you! > Thanks for the review, will add the Tag in v2. Thanks, -- Shang XiaoJing