From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753186AbbIRJKr (ORCPT ); Fri, 18 Sep 2015 05:10:47 -0400 Received: from mga09.intel.com ([134.134.136.24]:48249 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752427AbbIRJKp (ORCPT ); Fri, 18 Sep 2015 05:10:45 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,552,1437462000"; d="scan'208";a="807944509" From: Andy Shevchenko To: Andrew Morton , linux-kernel@vger.kernel.org, Alexander Viro Cc: Andy Shevchenko Subject: [PATCH v2 1/1] fs/proc/array.c: set overflow flag in case of error Date: Fri, 18 Sep 2015 12:10:39 +0300 Message-Id: <1442567439-8707-1-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.5.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For now in task_name() we ignore the return code of string_escape_str() call. This is not good if buffer suddenly becomes not big enough. Do the proper error handling there. Signed-off-by: Andy Shevchenko --- fs/proc/array.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/proc/array.c b/fs/proc/array.c index f60f012..ff2ce1a 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -91,18 +91,18 @@ static inline void task_name(struct seq_file *m, struct task_struct *p) { char *buf; + size_t size; char tcomm[sizeof(p->comm)]; + int ret; get_task_comm(tcomm, p); seq_puts(m, "Name:\t"); - buf = m->buf + m->count; - /* Ignore error for now */ - buf += string_escape_str(tcomm, buf, m->size - m->count, - ESCAPE_SPACE | ESCAPE_SPECIAL, "\n\\"); + size = seq_get_buf(m, &buf); + ret = string_escape_str(tcomm, buf, size, ESCAPE_SPACE | ESCAPE_SPECIAL, "\n\\"); + seq_commit(m, ret < size ? ret : -1); - m->count = buf - m->buf; seq_putc(m, '\n'); } -- 2.5.1