Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2525510ybf; Mon, 2 Mar 2020 10:21:26 -0800 (PST) X-Google-Smtp-Source: ADFU+vu3Q7PTa0cMrlVMfYJfNKfJGHBIPXQ8K5Gwgee4RP88thmunKeFT+n3v3mW4FTbGYe4v+hJ X-Received: by 2002:a05:6808:2c4:: with SMTP id a4mr293158oid.176.1583173286752; Mon, 02 Mar 2020 10:21:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583173286; cv=none; d=google.com; s=arc-20160816; b=IWTQuAGbpsSlQaHOIUg1uqr0EnAb9AQ72iggS8X5pAIB3+wDtDGpG2X/7shuSEjNGt yrzc/S9TtevinFI8Af9QrtDEDjZkRV6T9uBZrALLkDPL2BaFMaqj0UwdnVb9HGnZF/IG YOXb3v4H3ulL/ge1FcLuYxjnVaNVG+DReOa6IHzbeCZiLfurTFJjIzFcIfGcD+iWxINd wzwoIPrZz5Trrdx338+Fmm/CTU39vIjpREKr84treS0+tjF2nsMqqhkSZlPmcG9I0TSz BwHcu5ABmJf/pBnoprplDERJp+tY/L/KXyub15FO3KumWtyEe3FCbYHLbwWNggNSrZQT C1sg== 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 :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=cBU8Ier2IxWlCcsZwrUrlK7su4p+SMh+cD7Y5IyZ64A=; b=lQx9xHiPNsOlTbrjLaA+iU5uYB6uKyBZRUznMMmaThun8j9OQixFXmrs/6QOYs/1Eb AtemSlkV1t7Y3rvGf0UypAtADnCjPJDrtsakw24kyZQQS0JdvsxJW4QUsuBYjgr6ZM0X 2I5oF2mXQdZ5FVG0rpSJtMqWYzD0WGuFbgMgpWOeo+qaELzfdwPSWp7zdyHoLyRJY3I6 Mk1qV7eWtOpYuFjXN5Yyi+4bYW7UTZY05ARSyi50j5/8ajQbidqkfnTA7+eiEOaLvaeq wRAxCRmkiBeLGFJE4qwVlhHfeeLC6eRFVmqnUSz4rgp8I4j5FEVjVV2y7+q5nMV07AQd wgkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=cTMcQkR3; 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 p22si6782469otq.132.2020.03.02.10.21.14; Mon, 02 Mar 2020 10:21:26 -0800 (PST) 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=@lca.pw header.s=google header.b=cTMcQkR3; 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 S1727314AbgCBSVE (ORCPT + 99 others); Mon, 2 Mar 2020 13:21:04 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:34943 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726997AbgCBSVE (ORCPT ); Mon, 2 Mar 2020 13:21:04 -0500 Received: by mail-qt1-f196.google.com with SMTP id 88so724021qtc.2 for ; Mon, 02 Mar 2020 10:21:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=cBU8Ier2IxWlCcsZwrUrlK7su4p+SMh+cD7Y5IyZ64A=; b=cTMcQkR3vGvRQ81Eymbom4SohmSCDuLKOlpswzIzxRg7cUz+Xl1WeaE1A/nB8xIhsC ctOReOn74txQaY9oSZJero0a+zTz/5o1ilV2jBBX8PxAIuo7vNn8RoZ7TidKIFGtaAhE yppR5z6kl9vvFnkJ5oiE1j6pVZMfnWq6FxLZekhr0t2Tc0xbPiXgc0iqjEfhTYyYAUix eklu/MYfBxMuyMFNd5/t5vVC+PsX4NdglP5wInh7e0gbOyLorI20pHQinDgkIOKHygBB kZlPrDdzOoj1JoURXL98OwMItanNX09kp8bxgqwRrhX4GOdlxBF+8MQTaYiXbz7UJ3Kk GpKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=cBU8Ier2IxWlCcsZwrUrlK7su4p+SMh+cD7Y5IyZ64A=; b=lywUUhcEJRMZVbp4slvQLOmJkLJLHYfNuG4xqWUG/GKH14ATZglp5kbcZNHNVzckfC udpMxh74tKeaaO7WkviDW9rSpcp/CzAHV0rpbldoGdaJLlmjz8j0e4ymBBfAOHv+js1G wxMXXRpdk14YtnJcR701cH7K6qIGjnUqmqQ3I7D29yXkWg5BqchWkYVrRvwyfl0Co3iz yowCrvRUtFsHM4O5g66p/Q3CVYyApc6RpQVjobtatvSFWbjbaxMDMMMd+Bg2Qt+bY7Si 53bSdpQJbhrg+gaiPqXXvWuVx+vakijYoDwhyk6/sGFXmKCFbQJaxpp0/cZhiAvZq5L/ aodA== X-Gm-Message-State: ANhLgQ1VjyFqW1uAtkZsthWwadDkOrxM5UqqqVaKgDyV3EX0qkbfban2 7lxdxsS+FgjKkYne7GG/ercXFEXrUm8= X-Received: by 2002:ac8:4c86:: with SMTP id j6mr933934qtv.139.1583173262521; Mon, 02 Mar 2020 10:21:02 -0800 (PST) Received: from dhcp-41-57.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id f19sm2681250qtp.46.2020.03.02.10.21.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Mar 2020 10:21:01 -0800 (PST) Message-ID: <1583173259.7365.142.camel@lca.pw> Subject: Re: + seq_read-info-message-about-buggy-next-functions.patch added to -mm tree From: Qian Cai To: linux-kernel@vger.kernel.org, dave@stgolabs.net, longman@redhat.com, manfred@colorfullife.com, mingo@redhat.com, mm-commits@vger.kernel.org, neilb@suse.com, oberpar@linux.ibm.com, rostedt@goodmis.org, viro@zeniv.linux.org.uk, vvs@virtuozzo.com Cc: akpm@linux-foundation.org Date: Mon, 02 Mar 2020 13:20:59 -0500 In-Reply-To: <20200226035621.4NlNn738T%akpm@linux-foundation.org> References: <20200226035621.4NlNn738T%akpm@linux-foundation.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6 (3.22.6-10.el7) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-02-25 at 19:56 -0800, Andrew Morton wrote: > ------------------------------------------------------ > From: Vasily Averin > Subject: fs/seq_file.c: seq_read(): add info message about buggy .next functions > > Patch series "seq_file .next functions should increase position index". > > In Aug 2018 NeilBrown noticed commit 1f4aace60b0e ("fs/seq_file.c: > simplify seq_file iteration code and interface") > > "Some ->next functions do not increment *pos when they return NULL... > Note that such ->next functions are buggy and should be fixed. A simple > demonstration is dd if=/proc/swaps bs=1000 skip=1 Choose any block size > larger than the size of /proc/swaps. This will always show the whole last > line of /proc/swaps" > > Described problem is still actual. If you make lseek into middle of last > output line following read will output end of last line and whole last > line once again. > > $ dd if=/proc/swaps bs=1 # usual output > Filename Type Size Used Priority > /dev/dm-0 partition 4194812 97536 -2 > 104+0 records in > 104+0 records out > 104 bytes copied > > $ dd if=/proc/swaps bs=40 skip=1 # last line was generated twice > dd: /proc/swaps: cannot skip to specified offset > v/dm-0 partition 4194812 97536 -2 > /dev/dm-0 partition 4194812 97536 -2 > 3+1 records in > 3+1 records out > 131 bytes copied > > There are lot of other affected files, I've found 30+ including > /proc/net/ip_tables_matches and /proc/sysvipc/* > > I've sent patches into maillists of affected subsystems already, this > patch-set fixes the problem in files related to pstore, tracing, gcov, > sysvipc and other subsystems processed via linux-kernel@ mailing list > directly > > https://bugzilla.kernel.org/show_bug.cgi?id=206283 > > > This patch (of 4): > > Add debug code to seq_read() to detect missed or out-of-tree incorrect > .next seq_file functions. This patch spams the console like crazy while reading sysfs, # dmesg | grep 'buggy seq_file' | wc -l 4204 [ 9505.321981] LTP: starting read_all_proc (read_all -d /proc -q -r 10) [ 9508.222934] buggy seq_file .next function xt_match_seq_next [x_tables] did not updated position index [ 9508.223319] buggy seq_file .next function xt_match_seq_next [x_tables] did not updated position index [ 9508.223654] buggy seq_file .next function xt_match_seq_next [x_tables] did not updated position index [ 9508.223994] buggy seq_file .next function xt_match_seq_next [x_tables] did not updated position index [ 9508.224337] buggy seq_file .next function xt_match_seq_next [x_tables] did not updated position index ... > > https://bugzilla.kernel.org/show_bug.cgi?id=206283 > Link: http://lkml.kernel.org/r/244674e5-760c-86bd-d08a-047042881748@virtuozzo.com > Link: http://lkml.kernel.org/r/7c24087c-e280-e580-5b0c-0cdaeb14cd18@virtuozzo.com > Signed-off-by: Vasily Averin > Cc: NeilBrown > Cc: Al Viro > Cc: Steven Rostedt > Cc: Davidlohr Bueso > Cc: Ingo Molnar > Cc: Manfred Spraul > Cc: Peter Oberparleiter > Cc: Waiman Long > Signed-off-by: Andrew Morton > --- > > fs/seq_file.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > --- a/fs/seq_file.c~seq_read-info-message-about-buggy-next-functions > +++ a/fs/seq_file.c > @@ -256,9 +256,12 @@ Fill: > loff_t pos = m->index; > > p = m->op->next(m, p, &m->index); > - if (pos == m->index) > - /* Buggy ->next function */ > + if (pos == m->index) { > + pr_info("buggy seq_file .next function %ps " > + "did not updated position index\n", > + m->op->next); > m->index++; > + } > if (!p || IS_ERR(p)) { > err = PTR_ERR(p); > break; > _ > > Patches currently in -mm which might be from vvs@virtuozzo.com are > > seq_read-info-message-about-buggy-next-functions.patch > pstore_ftrace_seq_next-should-increase-position-index.patch > gcov_seq_next-should-increase-position-index.patch > sysvipc_find_ipc-should-increase-position-index.patch >