Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10530065ybi; Thu, 25 Jul 2019 01:00:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqycwVn/NsWyccDa1Vxk+R1Z4/33ud2AkbBH2Jdg1DAqSKulXKtMAy9gT15783Zwh/xKotRd X-Received: by 2002:a62:8246:: with SMTP id w67mr15736105pfd.226.1564041601647; Thu, 25 Jul 2019 01:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564041601; cv=none; d=google.com; s=arc-20160816; b=oV54Mdoxhl95p7oC02ZzyGEITjbx997Hc5S4WaOnpyLZV71868PZdPy2YSjCQzVun4 ++IbWIT4mjkFPrKmR8oMKJjrPc/sJll5PFxM1yIfLrlAsXG534Bp++onuDDnLCVcMLkU iWLv6qjoUFhXWFX5mPH/so9UesaCsksejWYWKKTZbMCZ2ksfdvvrWLs9sda9BT9Hs09R pmBNmuLtmIyLNVZmGyR1o1b9R3JKGFDNYx1NkhjWRN2svhiPI+uWJb1cDrV1Ei9NwbTM u7I198XijkCF1imtS4fZ36X9XBgx1nBZtESEEHj1slxH0OO7H/XfD1avlzgzoORJ0LOu F1kQ== 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=Pas4G+kSAqnyisZSHQ9eG99W7/vMTpD+lwqWHzSytvc=; b=uvU8+EOUPD/cAQnt/aiL3JbS/bM60KpGjy682fw+q57B0yXZ81j+sjRIkpSScSWZkx chU8YM18T6U/4Ph7q6jTW8zaWoQoaRW4akgUsjJ9M76bdrp+Wx4G5giGVkYQB9Zj7OZy RPqMF8dat9i6PLe02paW7t0YJh72M6WF8EzEFvMB5mAhFOlBWyayTFa0aXZo9yKJ10yG NnTMe2jO5uQWEktTk3vEPRa21NuDKCISDnzpEA8myZT2QJ0a1rfphqhZY+n2dGdPI6sZ OOrVMA/b44Lpr3lvFaLHzF5i4N2s1G+fMP+Q8tvPTz/vBChI1bm7EJgjS4jzDCC55EhX ckVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G004fKzu; 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 l14si17544300pga.567.2019.07.25.00.59.42; Thu, 25 Jul 2019 01:00:01 -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=G004fKzu; 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 S2392543AbfGXUJY (ORCPT + 99 others); Wed, 24 Jul 2019 16:09:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:48964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404989AbfGXUAn (ORCPT ); Wed, 24 Jul 2019 16:00:43 -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 A2F62205C9; Wed, 24 Jul 2019 20:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998443; bh=f9GvLwt0Ne5glBUpi3HIOx+1C4PY7x9yuu4XeqMRo38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G004fKzuVSvokJToAe0vq76yHtVvNx2wbvBwo/A/NqceiJZNHXYIJuu+yfC+zdWWh L+UUNTXcTNot/GhD8SUE9iykbBYtMVS5GTOauXmuXhp1yakfL4/F64lMwMWGbwd0Kd Y/8i6vW1VP3jcFAk9R/+KbKg6jK3BCocI8fW805s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tejun Heo , Josef Bacik , Jens Axboe Subject: [PATCH 5.1 367/371] blkcg: update blkcg_print_stat() to handle larger outputs Date: Wed, 24 Jul 2019 21:21:59 +0200 Message-Id: <20190724191751.893451048@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@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 From: Tejun Heo commit f539da82f2158916e154d206054e0efd5df7ab61 upstream. Depending on the number of devices, blkcg stats can go over the default seqfile buf size. seqfile normally retries with a larger buffer but since the ->pd_stat() addition, blkcg_print_stat() doesn't tell seqfile that overflow has happened and the output gets printed truncated. Fix it by calling seq_commit() w/ -1 on possible overflows. Signed-off-by: Tejun Heo Fixes: 903d23f0a354 ("blk-cgroup: allow controllers to output their own stats") Cc: stable@vger.kernel.org # v4.19+ Cc: Josef Bacik Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/blk-cgroup.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1005,8 +1005,12 @@ static int blkcg_print_stat(struct seq_f } next: if (has_stats) { - off += scnprintf(buf+off, size-off, "\n"); - seq_commit(sf, off); + if (off < size - 1) { + off += scnprintf(buf+off, size-off, "\n"); + seq_commit(sf, off); + } else { + seq_commit(sf, -1); + } } }