From patchwork Mon Oct 16 23:49:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 153820 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3794196vqb; Mon, 16 Oct 2023 16:50:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRS9nE0TCv+AXEeFxjfxxZRendiWeowFdoDpuDLgPdudkEpbtOnvBKIHL7XVmsgoUVOAk1 X-Received: by 2002:a17:902:fb45:b0:1bb:83ec:832 with SMTP id lf5-20020a170902fb4500b001bb83ec0832mr747647plb.2.1697500217708; Mon, 16 Oct 2023 16:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697500217; cv=none; d=google.com; s=arc-20160816; b=ON67z1TNSBL1GfidlsKm0UQ7a9bSwQYcXGUy+iYh6rIZRlFDQd4hOFJNmBpUbT/AhK BgYFJFv0NRgmMda6AUofmAEIGLpcPWJEk5zQGSFTUckQ9EtJosl3qsFVDqDXWQs9XSKA rdWr7EFBvrZrwlsjAZFFBuFfLGgc2Idl8++HIE/gRCcfrSGwKA9Z9tqL/FtMKdtbWgK3 adEtbRB09jR7zJHV58u/dOfPRkTnsoISuu28/Bpa2cfI5dMn4IrteK8RrNR2znhCueKe 0GKOZM7kyjn37ucXoJq5nEOZiP0rGDFOp4a/3q/dSTGb0zmUvvP8obqBcyHdXt8tXiS1 w0HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:date:subject:cc:to:from:dkim-signature; bh=nFFCwWPerP8iVzwdmNNWC3weeMNWhF8MLTsK5BrF8Yc=; fh=EX3CX7YJIZjPu3jh6PSyP1rh6MzRfTjSH8Y8j9ZXjCQ=; b=K//qKi6jMx+LuVduDRPk9nhqlRxRUPBIOXgerzzdskxpD0gpzCdWsmk3AfMTP6B+9e ES9PHEgApSZIiWdziyANB0WBIELAjCx+x7WoVyZaIK+8+dYn7BNL7pTjxvkgbnsR6MeF ODY9XjZ1QaehTO38zpj1miXW0OEPNZGq7BPRPHE1nymlNQv/9b78NzJ1vY7ETE+25SWg dpLQfIKiEIYNcaj4SkXDH1hJ85aq9GosQtuy0ix1K9Csmvyxps8TIHmaHaS6stFWIucc TsqlvKwQr/dXXB6YdPePkNSW1kzx+njVSVklMxS/XgzMfm2D66AW0ODeK80IOUyQ5Aju nCzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JnkkJzN8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l5-20020a170903120500b001c4329b77bfsi492144plh.123.2023.10.16.16.50.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 16:50:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JnkkJzN8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1D3848042A93; Mon, 16 Oct 2023 16:50:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233890AbjJPXtw (ORCPT + 18 others); Mon, 16 Oct 2023 19:49:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232457AbjJPXtv (ORCPT ); Mon, 16 Oct 2023 19:49:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2292092 for ; Mon, 16 Oct 2023 16:49:50 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D5A4C433C8; Mon, 16 Oct 2023 23:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697500189; bh=ECcUrZRXKH1RGkNt+ZfqdBaP7v9kjaK8IQAhOGMboxU=; h=From:To:Cc:Subject:Date:From; b=JnkkJzN8aGirKUq5BDpIZSLbzMPHB8QZwfVNWJQpEjGbCfUBWUGKvjgAK3zz3krmm 29cZmHNz0RE4ormDoAPD2Ka2A4b3A+AHxhyJnK/iZwT6ej/7tTz1TC0xBv3/Z04/OX KBsuAAit69ALEcmK3W4Q1MlzqpkBUAlngCmNu7ydTmdJ+9ABhXnYT4YJQMVUwSWRbs kUddGaGB3F6WbCCzhmCkRNRg5dlnQOWeTMW+95g6FaEORBj5IHLwV4NMDsVIO0cW0W +TRQdikZ5YxESdA7DXMhc33Xbr2mAHuPhMPtLi2ppamMifJFanNacoBvlMlgv+4Aa0 2wklKTMweIGbg== From: "Masami Hiramatsu (Google)" To: Steven Rostedt Cc: "wuqiang . matt" , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mhiramat@kernel.org Subject: [PATCH] fprobe: Fix to ensure the number of active retprobes is not zero Date: Tue, 17 Oct 2023 08:49:45 +0900 Message-Id: <169750018550.186853.11198884812017796410.stgit@devnote2> X-Mailer: git-send-email 2.34.1 User-Agent: StGit/0.19 MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 16 Oct 2023 16:50:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779957988026139710 X-GMAIL-MSGID: 1779957988026139710 From: Masami Hiramatsu (Google) The number of active retprobes can be zero but it is not acceptable, so return EINVAL error if detected. Reported-by: wuqiang.matt Closes: https://lore.kernel.org/all/20231016222103.cb9f426edc60220eabd8aa6a@kernel.org/ Fixes: 5b0ab78998e3 ("fprobe: Add exit_handler support") Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/fprobe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c index 3b21f4063258..881f90f0cbcf 100644 --- a/kernel/trace/fprobe.c +++ b/kernel/trace/fprobe.c @@ -189,7 +189,7 @@ static int fprobe_init_rethook(struct fprobe *fp, int num) { int i, size; - if (num < 0) + if (num <= 0) return -EINVAL; if (!fp->exit_handler) { @@ -202,8 +202,8 @@ static int fprobe_init_rethook(struct fprobe *fp, int num) size = fp->nr_maxactive; else size = num * num_possible_cpus() * 2; - if (size < 0) - return -E2BIG; + if (size <= 0) + return -EINVAL; fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler); if (!fp->rethook)