From patchwork Tue Apr 14 06:17:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 11486835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6928315AB for ; Tue, 14 Apr 2020 06:20:33 +0000 (UTC) Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 465AE206E9 for ; Tue, 14 Apr 2020 06:20:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 465AE206E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=ocfs2-devel-bounces@oss.oracle.com Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03E6IYnK179170; Tue, 14 Apr 2020 06:20:18 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 30b5ar2d8h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Apr 2020 06:20:18 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03E6Guti192623; Tue, 14 Apr 2020 06:18:18 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userp3020.oracle.com with ESMTP id 30bqm0r2jk-1 (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO); Tue, 14 Apr 2020 06:18:18 +0000 Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1jOEtl-0008Hf-1N; Mon, 13 Apr 2020 23:18:17 -0700 Received: from aserp3030.oracle.com ([141.146.126.71]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1jOEtC-0008FR-MT for ocfs2-devel@oss.oracle.com; Mon, 13 Apr 2020 23:17:42 -0700 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03E6H5HL082744 for ; Tue, 14 Apr 2020 06:17:42 GMT Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by aserp3030.oracle.com with ESMTP id 30cta97t02-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 14 Apr 2020 06:17:42 +0000 Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03E64no1011252 for ; Tue, 14 Apr 2020 06:17:41 GMT Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) by userp2030.oracle.com with ESMTP id 30d6wj0pv7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Apr 2020 06:17:41 +0000 Received: from vvs-ws.sw.ru ([172.16.24.21]) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1jOEt1-0000qS-HE; Tue, 14 Apr 2020 09:17:31 +0300 From: Vasily Averin To: ocfs2-devel@oss.oracle.com References: <085dc97b-de01-1d95-799d-dc795eec7818@virtuozzo.com> Message-ID: <9994b940-bb66-3334-9a47-f821cc197e5d@virtuozzo.com> Date: Tue, 14 Apr 2020 09:17:30 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 In-Reply-To: <085dc97b-de01-1d95-799d-dc795eec7818@virtuozzo.com> Content-Language: en-US MIME-Version: 1.0 X-PDR: PASS X-Source-IP: 185.231.240.75 X-ServerName: relay.sw.ru X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 include:spf.protection.outlook.com ip4:89.145.166.222 ip4:185.231.240.0/23 include:aspmx.pardot.com ~all X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9590 signatures=668686 X-Proofpoint-Spam-Details: rule=tap_spam_policies_notspam policy=tap_spam_policies score=0 impostorscore=0 bulkscore=0 adultscore=0 malwarescore=0 priorityscore=115 clxscore=140 spamscore=0 suspectscore=2 lowpriorityscore=0 mlxlogscore=791 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140037 X-Spam: Clean X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=2 spamscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140050 Subject: [Ocfs2-devel] [PATCH v3 4/4] ocfs2: sc_seq_ops should properly handle position index X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9590 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140050 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9590 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 phishscore=0 spamscore=0 mlxlogscore=999 suspectscore=2 adultscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140050 Currently sc_seq_ops ignores position index argument, and it leads to incorrect output in case of read with offset. By design .start function should skip first *pos elements, and .next function must update position index unconditionally. Cc: stable@vger.kernel.org Fixes: 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code ...") Link: https://urldefense.com/v3/__https://bugzilla.kernel.org/show_bug.cgi?id=206283__;!!GqivPVa7Brio!MJIyl9g4rZXkCRJpUtfNR70zABIYk0zKHrl00gKDdYZpx41lpyanlE7z50esOWCIqgd95w$ Signed-off-by: Vasily Averin --- fs/ocfs2/cluster/netdebug.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c index 8ca8a407781b..832fd762e4ef 100644 --- a/fs/ocfs2/cluster/netdebug.c +++ b/fs/ocfs2/cluster/netdebug.c @@ -213,7 +213,8 @@ struct o2net_sock_debug { }; static struct o2net_sock_container - *next_sc(struct o2net_sock_container *sc_start) + *next_sc(struct o2net_sock_container *sc_start, + loff_t pos) { struct o2net_sock_container *sc, *ret = NULL; @@ -226,7 +227,7 @@ static struct o2net_sock_container break; /* use sc_page to detect real scs in the list */ - if (sc->sc_page != NULL) { + if ((sc->sc_page != NULL) && (pos-- == 0)) { ret = sc; break; } @@ -241,7 +242,7 @@ static void *sc_seq_start(struct seq_file *seq, loff_t *pos) struct o2net_sock_container *sc, *dummy_sc = sd->dbg_sock; spin_lock(&o2net_debug_lock); - sc = next_sc(dummy_sc); + sc = next_sc(dummy_sc, *pos); spin_unlock(&o2net_debug_lock); return sc; @@ -252,8 +253,9 @@ static void *sc_seq_next(struct seq_file *seq, void *v, loff_t *pos) struct o2net_sock_debug *sd = seq->private; struct o2net_sock_container *sc, *dummy_sc = sd->dbg_sock; + ++(*pos); spin_lock(&o2net_debug_lock); - sc = next_sc(dummy_sc); + sc = next_sc(dummy_sc, 0); list_del_init(&dummy_sc->sc_net_debug_item); if (sc) list_add(&dummy_sc->sc_net_debug_item, &sc->sc_net_debug_item); @@ -354,7 +356,7 @@ static int sc_seq_show(struct seq_file *seq, void *v) struct o2net_sock_container *sc, *dummy_sc = sd->dbg_sock; spin_lock(&o2net_debug_lock); - sc = next_sc(dummy_sc); + sc = next_sc(dummy_sc, 0); if (sc) { if (sd->dbg_ctxt == SHOW_SOCK_CONTAINERS)