Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9942490ybi; Wed, 24 Jul 2019 12:45:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNEJ/mWu3NWD3hklqaVHMFObOnd9ii46KiaaANGIUV48wD4Xu/cO8X/lifG+lZULEW7lmA X-Received: by 2002:aa7:93bb:: with SMTP id x27mr13328356pff.10.1563997518948; Wed, 24 Jul 2019 12:45:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563997518; cv=none; d=google.com; s=arc-20160816; b=0Yp8kGs4NZeMDiJ6u2fkPb7hgD0XjNYq/tfMw/58Ehvf9jYNGuHxUN7Wd4iHQwxhS7 qg5b4weyIZ7VqMe8UyxWLrqcdzmIBesHP+l0nEis/s9T+KlxCri6ksefgWwHFpu4rHUg 7TCbTiZVHSijRQUsOJbNl4FT8D6V8guK0QlBd7NsIQaMeoECShqa0QUp9dXNJHm82+0n 1vCBM32tfM1iSiyKKgC9Rsz5TyhLge9bVeqXd+bb3UL9A62uuRVKa3vOFEAGtS3QJM6Z bf3b0rENEUjwD9U3awpu7KBSTEk8oQMzMiR0H2B9EbvU+tBB52kweyfngSWSRNgRR1Wc 81+w== 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=eKxps0x+9Fafjx12B6Dg8WAKa+axeIwCdK5wE11ePcw=; b=R27nL5Z1S+xjWxmuAXL32zRCP42SK7hembkliMKJnBZjncgv/nprXrfv/h3ZX8fXBx eGcfVevbMW0hC91hhMth6lx73rBNvDITSuBqA4j4E65w0gJze+jg+F9Ukbux4S/MsjeV 4vUDQH+9pA1JECFEQi9q/wn1EiNbcwv7Dg6+elMYpiiIq4gNyDo5U9nPxi3o1JMiKSEQ TL1omsGfJ+QQphm67xzQTypFEjN8aQ2xyndFWKyFPxEBjIH7PyQTVd381UX/ov4LrnqV dSy2TqxMBuLY7tjqipAvl1M5aALvAvmW4J5hLt+PbOcl5XXvHJ7cS+pG+0KQHv9uRnr4 8hLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TB4F+VnJ; 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 be3si15108918plb.383.2019.07.24.12.45.04; Wed, 24 Jul 2019 12:45:18 -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=TB4F+VnJ; 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 S2390377AbfGXTmf (ORCPT + 99 others); Wed, 24 Jul 2019 15:42:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:44282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390034AbfGXTme (ORCPT ); Wed, 24 Jul 2019 15:42:34 -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 C09CD20665; Wed, 24 Jul 2019 19:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997353; bh=RHYioeNC3dV2V+H2e0J3LjQcp19XulmQk7E8pbneulw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TB4F+VnJ/WymhuRQr3EBM4ZIvBad9VzTtpIOHMPHsoSDNAElWjrEZItytyJWkdgp+ mpcBJO8lT4rXa1FvO4E8knTZyWrrGJ6ZDtYtUHIKCYFK9dbc7gMCD/PYIg2kjsKikE zeTBmZbbyFeIKZjCIOMIfuwkGBucMhIOPI8aquwY= 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.2 407/413] blkcg: update blkcg_print_stat() to handle larger outputs Date: Wed, 24 Jul 2019 21:21:38 +0200 Message-Id: <20190724191803.727475960@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 @@ -1006,8 +1006,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); + } } }