From patchwork Mon May 22 20:33:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 97606 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1708661vqo; Mon, 22 May 2023 13:44:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7QRAMweO5gxTy12Oup2gLk7BQaq5ZJFt/PFMxFDjIY369Ehha1o01Rhn6XycFZVrQyCr97 X-Received: by 2002:a17:902:f689:b0:1a0:7156:f8d1 with SMTP id l9-20020a170902f68900b001a07156f8d1mr14728428plg.19.1684788275124; Mon, 22 May 2023 13:44:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684788275; cv=none; d=google.com; s=arc-20160816; b=v6efFKz6I6mueFNk9+/Y2DlHEw9VuB4VdppR6xToUWxzjPWZXWyOWtGKgfEvJXkpRJ 12DlCSsKfJOyJgLR//NgIiAdrEBSWM2BlGjpn3zDOWR4dgjt4dMMoarCycnY5H1PwwRJ 8Wer5q8Us7CuA7zfoD6X+epLBNIGw7vk/NLtnGhxcdbrdYPz/CtwvCCxclw/ootaiv3b 4JwFHb5DnK5zTH8gDvjtFpyXxjKCr9MA6LgFKQE59oVlbCwP6PH+v5UozDEdAfhzGnjN ZpQcwfMLlW6ksvHWN0w5pRw8+jPDOxRiBi8TmlliUWbGfAZKGaFh7JhOB6fDRLMfJtXT 31XQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V9sqN52AFdCDJbEYI+OOp4eJ+ldK2Sa5VtE0bull/EE=; b=cMogs1E9T86svKyeNNmwmXwVKhFfCKsZKWwYWM6IyNX1E+sNSmdAqEFuOrEUaX1ZpT KfxoceKc0IAuMXgSVZT7LPZ5YcR2ykY6zxNYnuuPsvvHU9B6YsE2JwW/swvgZK723P5f QVrOOv8INbwzvleE/67pBYHLhl2UtI90yhHf/TDnhVfjl0qLSiEd+U8azKWupTYKjlHg Mdsw651kVnTvUJSqxpdEY3nEGOF7MdHZxqGjEwNdoB4UQunRROSmB/5gec152qta+FNl vfr2/K3NkTxrbUS8dfhT0e9VJJuqAzCnZLPjk3SgyUk5zN9wVaK4DWYQEhf/m0lYraw7 ma8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RvIIl7Jw; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020a1709027e8f00b001adf26a9390si4984446pla.191.2023.05.22.13.44.23; Mon, 22 May 2023 13:44:35 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RvIIl7Jw; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234814AbjEVUgc (ORCPT + 99 others); Mon, 22 May 2023 16:36:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234895AbjEVUgU (ORCPT ); Mon, 22 May 2023 16:36:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAD7E19D; Mon, 22 May 2023 13:35:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 30AFD62BD6; Mon, 22 May 2023 20:35:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AD92C433D2; Mon, 22 May 2023 20:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684787752; bh=0nQ8xIPSPhBIr1gc3+npYhNke4IXHy+5EM39FqGHhHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RvIIl7JwcJq1f1lT50bQTaPuLv0NZy78hJqb4UTvWapPNbd41FW80wvaW4pH0aAOo 4TFqg8491i9Zl3rQRFtYXMLVrUEjAIN2Sus2yH0U8HOELjOAhTmZZlj6/RVSV3KFvt Xe9iqVfgcL67vJ4LphGTNfl2Ao1Ub0EQ7bS13b2S6nILe6dKwQjN4s3A5ifjdgD6B8 HKSBErLqGZ2KGI5RO4zGnfoSCGGwg236gdTcm9UFy3mIkKjxjyKFjwyOA5VTnN1Ir6 STLK7od7jNeP4m7FYg/VWUGu+uTiQw4V/Ub1n/8uiGlC7+KimKstqJvqYoDpmxE5EM cl8yPMWAoz3Ag== From: Jiri Olsa To: stable@vger.kernel.org Cc: Christoph Hellwig , John Fastabend , linux-mm@kvack.org, bpf@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Masami Hiramatsu , Tsahee Zidenberg , Andrii Nakryiko , Daniel Borkmann , Thomas Gleixner , =?utf-8?q?Mah=C3=A9_Tardy?= , linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH stable 5.4 8/8] bpf: bpf_probe_read_kernel_str() has to return amount of data read on success Date: Mon, 22 May 2023 22:33:52 +0200 Message-Id: <20230522203352.738576-9-jolsa@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230522203352.738576-1-jolsa@kernel.org> References: <20230522203352.738576-1-jolsa@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766628550305630047?= X-GMAIL-MSGID: =?utf-8?q?1766628550305630047?= From: Andrii Nakryiko commit 02553b91da5deb63c8562b47529b09b734659af0 upstream. During recent refactorings, bpf_probe_read_kernel_str() started returning 0 on success, instead of amount of data successfully read. This majorly breaks applications relying on bpf_probe_read_kernel_str() and bpf_probe_read_str() and their results. Fix this by returning actual number of bytes read. Fixes: 8d92db5c04d1 ("bpf: rework the compat kernel probe handling") Signed-off-by: Andrii Nakryiko Signed-off-by: Daniel Borkmann Reviewed-by: Christoph Hellwig Acked-by: John Fastabend Link: https://lore.kernel.org/bpf/20200616050432.1902042-1-andriin@fb.com --- kernel/trace/bpf_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index a46256f99229..c4c825dcdef8 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -198,7 +198,7 @@ bpf_probe_read_kernel_str_common(void *dst, u32 size, const void *unsafe_ptr) if (unlikely(ret < 0)) goto fail; - return 0; + return ret; fail: memset(dst, 0, size); return ret;