From patchwork Mon Aug 17 15:14:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 266395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0BB6C433E1 for ; Mon, 17 Aug 2020 16:02:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B122620729 for ; Mon, 17 Aug 2020 16:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680161; bh=fawSJcfUm9T8ngtROovH+G7OVNYMfbyCkgJlVlGEZDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=SjhglxyH0AjL+xAmNo3F0ixJrwGurZBwgpO4vmCsePRXgfXS3bzu7KwprSZS1lXRa +6pLbMKyUrjzalKIdQyR0a3W8vqd6LgbRTLRRMsp680SS5GOBjP+FvHiWQnmrqPWDf uM1tlzJZwu4RXPhgiov01FHXiK684/cdWB/udyY0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388209AbgHQQCj (ORCPT ); Mon, 17 Aug 2020 12:02:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:50074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388203AbgHQQCf (ORCPT ); Mon, 17 Aug 2020 12:02:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A60B2206FA; Mon, 17 Aug 2020 16:02:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680155; bh=fawSJcfUm9T8ngtROovH+G7OVNYMfbyCkgJlVlGEZDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WuB3okpNh2qJOXgAcf27CXBP2Qh3V+oYxq8EK5sWGrWju1Vm7MT/mVRevb3C/QYiO FmwvRqir18eYd7ZtpLYglWGPXC+IN2zEsBi9A/GU9314QZM+AZKferF65q3vhzImWG UKrzUAvKWmmAvxso3pGHAFjT+jrtlkiXKKvXIk84= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenbo Zhang , Daniel Borkmann , Andrii Nakryiko , Sasha Levin Subject: [PATCH 5.4 074/270] bpf: Fix fds_example SIGSEGV error Date: Mon, 17 Aug 2020 17:14:35 +0200 Message-Id: <20200817143759.443952233@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Wenbo Zhang [ Upstream commit eef8a42d6ce087d1c81c960ae0d14f955b742feb ] The `BPF_LOG_BUF_SIZE`'s value is `UINT32_MAX >> 8`, so define an array with it on stack caused an overflow. Signed-off-by: Wenbo Zhang Signed-off-by: Daniel Borkmann Acked-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20200710092035.28919-1-ethercflow@gmail.com Signed-off-by: Sasha Levin --- samples/bpf/fds_example.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/bpf/fds_example.c b/samples/bpf/fds_example.c index 2d4b717726b64..34b3fca788e8d 100644 --- a/samples/bpf/fds_example.c +++ b/samples/bpf/fds_example.c @@ -30,6 +30,8 @@ #define BPF_M_MAP 1 #define BPF_M_PROG 2 +char bpf_log_buf[BPF_LOG_BUF_SIZE]; + static void usage(void) { printf("Usage: fds_example [...]\n"); @@ -57,7 +59,6 @@ static int bpf_prog_create(const char *object) BPF_EXIT_INSN(), }; size_t insns_cnt = sizeof(insns) / sizeof(struct bpf_insn); - char bpf_log_buf[BPF_LOG_BUF_SIZE]; struct bpf_object *obj; int prog_fd;