From patchwork Thu Jun 8 01:15:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunliming X-Patchwork-Id: 13271506 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8706FC7EE25 for ; Thu, 8 Jun 2023 01:16:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233007AbjFHBQR (ORCPT ); Wed, 7 Jun 2023 21:16:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230450AbjFHBQQ (ORCPT ); Wed, 7 Jun 2023 21:16:16 -0400 Received: from mail-oo1-f66.google.com (mail-oo1-f66.google.com [209.85.161.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EBA8269F; Wed, 7 Jun 2023 18:16:15 -0700 (PDT) Received: by mail-oo1-f66.google.com with SMTP id 006d021491bc7-55554c33bf3so51039eaf.2; Wed, 07 Jun 2023 18:16:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686186975; x=1688778975; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nSpPic4HmJs/C9WMNII22r3kQ6JIvpVttYGRAz80e/M=; b=G2HoSEpik4AGUwYRQeiNsZKaUNfkn5gfZY6ln8/e3LBjQX2cBrEI4IHeAZFLyXP3Wx HbriVl+7F7yKCEPDUD6S+ioX2MJPNaPv3XBtecojbFR/bQ86t6xPMe8c7izQ5SnJAfK/ 5Ra6G2oBW7V/O9D3rKH8UlVXjaZWREx33LsGzgBD3s4mlze7U/iULSYAqrF7hpDIxiwH BT4vSX71Xpz/5DF/r3D7x+nMYBoiK6OkeA6KNwt66/Cy63/44wrb93nocowZ1+vtyJUc nJnCTkbEkFwh7IX8+s1cNGRrICkQboyH4jn5qilRH9R1WDbDs+MEn/IuKOPDXRN/GZEb KggA== X-Gm-Message-State: AC+VfDw8ZCqulo+p58dHmC1etfuMg5+RocJsVtXWyOgqBbFXrnOKmJk3 AzzKNjiDWurHV1anPBY92A== X-Google-Smtp-Source: ACHHUZ760c+feJm6WKUkGQL2e9fQmx+JBuG5W14oQD67qrskXStPD/G2KG06FrTroLk4iF821MAOSg== X-Received: by 2002:a54:4588:0:b0:39b:8f0c:3936 with SMTP id z8-20020a544588000000b0039b8f0c3936mr6769371oib.27.1686186974893; Wed, 07 Jun 2023 18:16:14 -0700 (PDT) Received: from localhost.localdomain ([116.128.244.169]) by smtp.gmail.com with ESMTPSA id g11-20020a17090a128b00b00250334d97dasm1906691pja.31.2023.06.07.18.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 18:16:14 -0700 (PDT) From: sunliming To: mhiramat@kernel.org, beaub@linux.microsoft.com, rostedt@goodmis.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kelulanainsley@gmail.com, sunliming Subject: [PATCH 1/3] tracing/user_events: Fix incorrect return value for writing operation when events are disabled Date: Thu, 8 Jun 2023 09:15:52 +0800 Message-Id: <20230608011554.1181097-2-sunliming@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230608011554.1181097-1-sunliming@kylinos.cn> References: <20230608011554.1181097-1-sunliming@kylinos.cn> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org The writing operation return the count of writes whether events are enabled or disabled. This is incorrect when events are disabled. Fix this by just return -EFAULT when events are disabled. Signed-off-by: sunliming --- kernel/trace/trace_events_user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index 1ac5ba5685ed..970bac0503fd 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -1957,7 +1957,8 @@ static ssize_t user_events_write_core(struct file *file, struct iov_iter *i) if (unlikely(faulted)) return -EFAULT; - } + } else + return -EFAULT; return ret; } From patchwork Thu Jun 8 01:15:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunliming X-Patchwork-Id: 13271507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC66BC7EE43 for ; Thu, 8 Jun 2023 01:16:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233018AbjFHBQV (ORCPT ); Wed, 7 Jun 2023 21:16:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232938AbjFHBQU (ORCPT ); Wed, 7 Jun 2023 21:16:20 -0400 Received: from mail-ot1-f67.google.com (mail-ot1-f67.google.com [209.85.210.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3020426AE; Wed, 7 Jun 2023 18:16:19 -0700 (PDT) Received: by mail-ot1-f67.google.com with SMTP id 46e09a7af769-6b15e510630so9185a34.3; Wed, 07 Jun 2023 18:16:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686186978; x=1688778978; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UwLBYM4w/H7KoFqtcB4hQtAsyswAe46iM2ztf4QLeWA=; b=SVoi7ONSm0KEOIywoGdSt60Fu+adCINiQYTPpjolgTvrBdR5fRuj/rFbDhSQ+tRdb3 oIjW77aChg+svgMdfVOANg/nLuNNe3QQUeR2R77oDoI8WAernbgIggSVoKpqbDeArxkI rIRDSv2qyMCaY6ByYwJPonQL4nu4Yy2VPB07+SyhTbBW5qE/ZktNKVibElP9M++Bd0dr +l2mc4trt2tvmhihds9knUoVoF895fP6/sk/tlEkQDaCAwd6Wm4VzsKq736SnbKBv7N3 fgQumcbGGCZ+6Mt0cHq5cyZmxIXv0c8ertWur0ekeuGch9itlEfR3FEQLrLhgZRje4Qj zFew== X-Gm-Message-State: AC+VfDw0E063ABOrqSXBgGiEoo58ye8cj7XskffQsNqVeMgEwPNfuntU BGmbdb8dn5o3wB+k57ZVfCEaG0bBrfMoH1kbIQ== X-Google-Smtp-Source: ACHHUZ63GHNTFPNP/gU4BnqOw+kQHX/Nrp1lXVFKeRXb/X1XodjnI3tOO9Nezjf3Iym9k6CGxyoinw== X-Received: by 2002:a05:6830:1451:b0:6b2:ad27:fcae with SMTP id w17-20020a056830145100b006b2ad27fcaemr1731168otp.29.1686186978451; Wed, 07 Jun 2023 18:16:18 -0700 (PDT) Received: from localhost.localdomain ([116.128.244.169]) by smtp.gmail.com with ESMTPSA id g11-20020a17090a128b00b00250334d97dasm1906691pja.31.2023.06.07.18.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 18:16:18 -0700 (PDT) From: sunliming To: mhiramat@kernel.org, beaub@linux.microsoft.com, rostedt@goodmis.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kelulanainsley@gmail.com, sunliming Subject: [PATCH 2/3] selftests/user_events: Enable the event before write_fault test in ftrace self-test Date: Thu, 8 Jun 2023 09:15:53 +0800 Message-Id: <20230608011554.1181097-3-sunliming@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230608011554.1181097-1-sunliming@kylinos.cn> References: <20230608011554.1181097-1-sunliming@kylinos.cn> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org The user_event has not be enabled in write_fault test in ftrace self-test, Just enable it. Signed-off-by: sunliming --- tools/testing/selftests/user_events/ftrace_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/user_events/ftrace_test.c b/tools/testing/selftests/user_events/ftrace_test.c index abfb49558a26..d33bd31425db 100644 --- a/tools/testing/selftests/user_events/ftrace_test.c +++ b/tools/testing/selftests/user_events/ftrace_test.c @@ -373,6 +373,10 @@ TEST_F(user, write_fault) { ASSERT_EQ(0, ioctl(self->data_fd, DIAG_IOCSREG, ®)); ASSERT_EQ(0, reg.write_index); + /* Enable event */ + self->enable_fd = open(enable_file, O_RDWR); + ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1"))) + /* Write should work normally */ ASSERT_NE(-1, writev(self->data_fd, (const struct iovec *)io, 2)); From patchwork Thu Jun 8 01:15:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunliming X-Patchwork-Id: 13271508 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E610AC7EE25 for ; Thu, 8 Jun 2023 01:16:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233143AbjFHBQ3 (ORCPT ); Wed, 7 Jun 2023 21:16:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233158AbjFHBQ0 (ORCPT ); Wed, 7 Jun 2023 21:16:26 -0400 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58DD726AE; Wed, 7 Jun 2023 18:16:22 -0700 (PDT) Received: by mail-pj1-f65.google.com with SMTP id 98e67ed59e1d1-256766a1c43so34154a91.1; Wed, 07 Jun 2023 18:16:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686186982; x=1688778982; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4fjZocQuLj2YEu+oxrRPhJbmjewTJfCmZq5g1FLSCZg=; b=P+4Dm75tmNxsfJSCwrBUJY0zB9KiieawRmiA2LFkOL5uoFE1xNqB6YpnTGpplIky2e 0O6ANUn/oX0HDKufycEe4b/XvmGevWnKZYrXMwyN9pqDwtAtqAPWpvyoDHFgPXmncBvZ KgeN+VMKCPlw7AogKxwWp3tFyO501ZvUMLmSPF5ZW7Jq5ItVEasDHibe4GgUJ1AwFgyD py270dOzzo6UN4MKT6YVW1zZaa5sMtVMO6ZoKKIYomWTv/iPo92WwrNNphHqnho4Yns8 D8gQE+0FDZzfcSlg3kQe3tRahTTTTWGG9sJQYRc26+sDC0hwN8v6qVF53R/eWZSsB4+1 d0KA== X-Gm-Message-State: AC+VfDxaRQwvUmaSpw6PSkh2YEDm3FpKb3ueb7ibpx0uDeSTxAHk0emO yg3UBPOcnRSg6Kn/PlIrZA== X-Google-Smtp-Source: ACHHUZ5QvjEgG6Q8wAbgsgYjwXcFIa3cbvGL6K23v78TkeyNYGSc8+d804DIT9DZNEJ7ivrFsCrBqA== X-Received: by 2002:a17:90b:e8a:b0:255:f693:cf91 with SMTP id fv10-20020a17090b0e8a00b00255f693cf91mr3490612pjb.30.1686186981761; Wed, 07 Jun 2023 18:16:21 -0700 (PDT) Received: from localhost.localdomain ([116.128.244.169]) by smtp.gmail.com with ESMTPSA id g11-20020a17090a128b00b00250334d97dasm1906691pja.31.2023.06.07.18.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 18:16:21 -0700 (PDT) From: sunliming To: mhiramat@kernel.org, beaub@linux.microsoft.com, rostedt@goodmis.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kelulanainsley@gmail.com, sunliming Subject: [PATCH 3/3] selftests/user_events: Add test cases when event is disabled Date: Thu, 8 Jun 2023 09:15:54 +0800 Message-Id: <20230608011554.1181097-4-sunliming@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230608011554.1181097-1-sunliming@kylinos.cn> References: <20230608011554.1181097-1-sunliming@kylinos.cn> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org When user_events are disabled, it's write operation should be fail. Add this test cases. Signed-off-by: sunliming --- tools/testing/selftests/user_events/ftrace_test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/user_events/ftrace_test.c b/tools/testing/selftests/user_events/ftrace_test.c index d33bd31425db..d3240a97f23d 100644 --- a/tools/testing/selftests/user_events/ftrace_test.c +++ b/tools/testing/selftests/user_events/ftrace_test.c @@ -297,6 +297,9 @@ TEST_F(user, write_events) { io[0].iov_base = ®.write_index; io[0].iov_len = sizeof(reg.write_index); + /* Write should fail when event is not enabled */ + ASSERT_EQ(-1, writev(self->data_fd, (const struct iovec *)io, 3)); + /* Enable event */ self->enable_fd = open(enable_file, O_RDWR); ASSERT_NE(-1, write(self->enable_fd, "1", sizeof("1")))