Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10428985ybi; Wed, 24 Jul 2019 23:03:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGL0ABMvWPTjKEImc8FLzkEITXvzkHJcQFax5jUUcBEftDA6LL/ImaFxxzp81Ygy4cfYnl X-Received: by 2002:a17:90a:376f:: with SMTP id u102mr91966287pjb.5.1564034621630; Wed, 24 Jul 2019 23:03:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034621; cv=none; d=google.com; s=arc-20160816; b=j8CRy0hVicP1XOz9hPhN6voeYguVge+aaOPsdrxN0GeqXFl4dpN4qQT8GEf4T1yXfs Es4vmYEu/jYh8XuegfJZ3ASCKXfFw+J4gzruIn90dYRQPCM1aPKKAyXhR5TVaWH93S7Q zZLjoOChGHC+FbpwRhvhXMk6GJLvm6la1iHCPLI6Ysvw2r7bcVDFbHlqjsQQYrlzuxoi eXQdn972v18k33Es85CtWN2TaXnJuaQA1s6pn3TXNz0r7/R2mFm5HGiPMih5BLuhL9qr pRpKqa5k0Qkm3k0lL6Om3ldagOhHWOdsZ/rAUucpkLatMlxmfx/c36KGno5dr+l8/gu/ 9Ntg== 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=QkIq0G1NAbnnMzNdTVBoqulrhBtUB+gKg3T9wrNyyzc=; b=obqpLeM5rOJ2EzxZkik4ONac7yTrztFeHqwXDNlG6n2NQr9PqulL752d3Fg6DkHUEM n90nT4H8i9lGOjre++I95nVP4hqKa/sUdPwehqHPYE/nrqUD3BNahuB9aHU4g5K+Knjn AlWGxufjT0UXOVpdGwOg/xnF6s0HqeBt7zfwrmzcie/HIHT9BpRkv4/h/F7s3UBoiLt+ 9zEd9Ytilvo4ih6eMpwLW1FG1FmMw7YeAgnks8YoRgMRq+ZP7EFTti7u6Xdgo65+Ze5m k833c2tTPrJXqk4i6P6iNanNq+r0O/O23Ltx5w5Mx4Xh96WU70z+Kw7848W+uKoXa/v1 NwJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bVv4fW8S; 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 f7si7431632pgs.210.2019.07.24.23.03.26; Wed, 24 Jul 2019 23:03:41 -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=bVv4fW8S; 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 S2391495AbfGYFqy (ORCPT + 99 others); Thu, 25 Jul 2019 01:46:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:34644 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729015AbfGYFqu (ORCPT ); Thu, 25 Jul 2019 01:46:50 -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 DE72422BEB; Thu, 25 Jul 2019 05:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033610; bh=OHY45QRpXu1HCZQbI71bkzY4SYnlrOcQiaYTULCw7/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bVv4fW8Sb3xB9/ZTwEBHAoW6e8THVw6tXHabmYnW7xauUhW8v+oKouuZD5NjkqBcr 7xgxjpLTXetygoPJ0Tb/5o088CBRGbFnuVEfXj8AEjxxOpRCSUM1X0OYYVe6ZmVczM cl/2+YwUCPNJREdm9fNVUlMqHdFCrNxJAMoo9k68= 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 4.19 268/271] blkcg: update blkcg_print_stat() to handle larger outputs Date: Wed, 24 Jul 2019 21:22:17 +0200 Message-Id: <20190724191718.218353974@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@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 @@ -1016,8 +1016,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); + } } }