Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933376AbbENLk7 (ORCPT ); Thu, 14 May 2015 07:40:59 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:21370 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932434AbbENLjo (ORCPT ); Thu, 14 May 2015 07:39:44 -0400 From: Wang Long To: , , CC: , , , , , , , , , Subject: [RFC PATCH 06/17] tracing: Use trace_seq_used() and seq_buf_used() instead of len Date: Thu, 14 May 2015 11:34:53 +0000 Message-ID: <1431603304-162571-7-git-send-email-long.wanglong@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1431603304-162571-1-git-send-email-long.wanglong@huawei.com> References: <1431603304-162571-1-git-send-email-long.wanglong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.197.200] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.5554888B.0464,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 0a3c4162973894eac8be464ce8225f1f Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1440 Lines: 42 From: "Steven Rostedt (Red Hat)" commit 5ac48378414dccca735897c4d7f4e19987c8977c upstream. As the seq_buf->len will soon be +1 size when there's an overflow, we must use trace_seq_used() or seq_buf_used() methods to get the real length. This will prevent buffer overflow issues if just the len of the seq_buf descriptor is used to copy memory. Link: http://lkml.kernel.org/r/20141114121911.09ba3d38@gandalf.local.home Reported-by: Petr Mladek [wanglong: backport to 3.10 stable - only backport seq_buf related ] Signed-off-by: Wang Long Signed-off-by: Steven Rostedt --- kernel/trace/seq_buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c index 9ec5305..ce17f65 100644 --- a/kernel/trace/seq_buf.c +++ b/kernel/trace/seq_buf.c @@ -328,7 +328,7 @@ int seq_buf_to_user(struct seq_buf *s, char __user *ubuf, int cnt) if (s->len <= s->readpos) return -EBUSY; - len = s->len - s->readpos; + len = seq_buf_used(s) - s->readpos; if (cnt > len) cnt = len; ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt); -- 1.8.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/