Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp832001ybi; Fri, 12 Jul 2019 05:23:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZmFL+I17Ly7NCYmaXMutgBRJhFD9GWgukXCdmjKJwRgVL42kFpPSUeAxcM/CYUISA6IrX X-Received: by 2002:a17:90a:bd0b:: with SMTP id y11mr10906041pjr.141.1562934209118; Fri, 12 Jul 2019 05:23:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934209; cv=none; d=google.com; s=arc-20160816; b=AUppEyTkuOZsq/XKGkL1XFmJZ2Lt4/g7+5Lqqr18QdA2zurHXT0xVFTfwWoCkyfJKo l1Sp8RTiS1qldgrMTJezmnJ/9YYCUMYttOIuo2ShfL3pokTLuv6RpHY4b3vcyAGoc4Oi Hye50LGrVuTXopvk/b/s0KiqBLPDjnfqyBE0IZtZmZymuZFvoP21ZfSqzVtmERWwPH3m /eKUhZBEFWafAHM7pQAdqYCX8sQpPsZim79nAyPGBKGGpVI0dcHD2AJJufeLN3/IAitD 2bcwQxJyfTa0p4Yr4MZrON+qx3uYn6uACsBnSBbQecJSoGvqlcf0SiE4xi2zqearNxsp hk1A== 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=tiiuvB4JjRl+VCvz/jrLDIFNLMjJVb3AlP+A+PcFjkY=; b=nz8p4lERzLu0fwtj4IyA3hKi+70m6OvaRN6Xp3cArwYiB0QbHnrwylQSAbmKSGTE3v +5+vA2JDyuDXPleW48/drgeQLQ7AHRucxj2x53OkCmI7RMvcy51D2tfXBCvjIbSMXZe+ dPRlKOruaSdrzWNZYDV51wsjOINuDBuYe7QuG7H92JKX0Zuv2XbKCAsfFvgcvbv6rDXL udq+9awCUvnXFJeIsBRlnK2EWVrbqEaYl2iOizA2oessi6giiwJp3G8LTp6qaGlPKSth W21wYgcH9s/z4ZDKaTWhCmKdV4yL3yKTn2VvzXBsbccoaKQzm28mmDah6GkvbloMVTWq wKRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zTW8Eqre; 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 g9si7792993plm.207.2019.07.12.05.23.13; Fri, 12 Jul 2019 05:23:29 -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=zTW8Eqre; 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 S1727657AbfGLMVr (ORCPT + 99 others); Fri, 12 Jul 2019 08:21:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:56108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727648AbfGLMVo (ORCPT ); Fri, 12 Jul 2019 08:21:44 -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 9F1C220863; Fri, 12 Jul 2019 12:21:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934104; bh=kRN2inrFgQHTTGhs457CATNH+nhelTjE42VP17CFamw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zTW8Eqre3r0/VCdDz3KmDJ9UFd4l8ID6zqWPl/WV6I3coc6G9zhv6o5DhI2Fy660f yvd0uKMtbGv1ZLleGjm5vxXGiV9Ad0/WNvPwoI/eZF2GkNRu6743Is8osxQcShJIP4 UC6fgXdVVysTGBdkFG2dmZ0rrf4jBjlRWUvUw40g= 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.19 06/91] samples, bpf: fix to change the buffer size for read() Date: Fri, 12 Jul 2019 14:18:09 +0200 Message-Id: <20190712121621.767335632@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121621.422224300@linuxfoundation.org> References: <20190712121621.422224300@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 cf40a8284a38..5061a2ec4564 100644 --- a/samples/bpf/bpf_load.c +++ b/samples/bpf/bpf_load.c @@ -677,7 +677,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