Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1697722ybi; Wed, 17 Jul 2019 20:19:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqyS1aQFZNe3g2cL8CNpcYci+KrbZ9B61z8aZ5276oR4X3uMBuI41Gk61EyU2RLlRxd1Dc0j X-Received: by 2002:a17:90a:fa07:: with SMTP id cm7mr47076654pjb.138.1563419974086; Wed, 17 Jul 2019 20:19:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563419974; cv=none; d=google.com; s=arc-20160816; b=j7oQmmBEddC+GoGQHtvCbsQKASIGMxkYEw1eu+w3jov/WhYbsrh05KAwzXeR0q0j0P OL+Yu+rtNk8tLMCQiyqBzfXke1B5CA2dhPq+ehUe3+tBc32DGj6XEOlmi8U5SBBwDm0+ gV9EIB+zwZOITxy5j0+GAeiFEintweY3CxzXv0vowMLU3Zo3Abek7XEIxYAt/FnVFZIc 3n7ADGJi8EuYKHkK5mj1rom75E118mS9AT010+mLhlMx0gmJ6wl22M1NEEllZ//St+UL iTdVpR6AEVsA/wX2Qe7aL6o1YgKlCybgOTvVroBoltlyKhY+VIZsATU4dv2Mv60GI1cD ZOsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4pUxpdkUwbhl1z30QMDpEw7LCFNEuwFbWAzfnfWU+zw=; b=q6//+/d4SStlmTg7MK9duFTH2h6AltxbrYERffQ/IHAQBtISAvOkgw7SDgmpJpq33Y A76kP6Yri9Bxv8UGvT+JchvOrsyV0y2ec5QJqSE9sa5qFb3oERUrOYQ+8pjbrlEcABEm nQeJl5MUxyvtZIQExLP5F2cj5OSakcu9x8E3iKrqmSOCSFRQcc0Qj5maq9lMg1JIj9BK MhY53xjr7Mmx/Rlf6QFQjqbZikrv8btZTUfeem+e24WfBuPeLLiFKmDeFiqP+vbBrNer nVTEfOHZRXYcbeagnbbGW3ER4s8+cr7ZqdI+7TUwTnH4V5dH2Z30TMJ16HYxo6pM9Dxa zdqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QAqnKPF7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 131si89221pfu.165.2019.07.17.20.19.17; Wed, 17 Jul 2019 20:19:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QAqnKPF7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391248AbfGRDO1 (ORCPT + 99 others); Wed, 17 Jul 2019 23:14:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:50364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391785AbfGRDOZ (ORCPT ); Wed, 17 Jul 2019 23:14:25 -0400 Received: from localhost (115.42.148.210.bf.2iij.net [210.148.42.115]) (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 14D2C2077C; Thu, 18 Jul 2019 03:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563419665; bh=FcQUE7w0lHt6GVDBbJ2pJHhFetTDLXlz6COaz+h+mhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QAqnKPF7AQSG+3d8n3jxT5yXMJDuTcPNGUSzaBHiCD05xs6h7MwdAPC2a3U63AvsC +5YHLk5Rbz4BdLGtspTseDbdlml6N1/SwTWc5gaE7eCurM1OkQPIkZdgFoWgds0xvb cFHh0zo9E28apvuVARWi/6HOaISdk+YQd1I6+G+8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chang-Hsien Tsai , Daniel Borkmann , Sasha Levin Subject: [PATCH 4.4 02/40] samples, bpf: fix to change the buffer size for read() Date: Thu, 18 Jul 2019 12:01:58 +0900 Message-Id: <20190718030040.246578146@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030039.676518610@linuxfoundation.org> References: <20190718030039.676518610@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit f7c2d64bac1be2ff32f8e4f500c6e5429c1003e0 ] If the trace for read is larger than 4096, the return value sz will be 4096. This results in off-by-one error on buf: static char buf[4096]; ssize_t sz; sz = read(trace_fd, buf, sizeof(buf)); if (sz > 0) { buf[sz] = 0; puts(buf); } Signed-off-by: Chang-Hsien Tsai Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- samples/bpf/bpf_load.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c index da86a8e0a95a..e836b5ff2060 100644 --- a/samples/bpf/bpf_load.c +++ b/samples/bpf/bpf_load.c @@ -336,7 +336,7 @@ void read_trace_pipe(void) static char buf[4096]; ssize_t sz; - sz = read(trace_fd, buf, sizeof(buf)); + sz = read(trace_fd, buf, sizeof(buf) - 1); if (sz > 0) { buf[sz] = 0; puts(buf); -- 2.20.1