Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp645767ybh; Tue, 10 Mar 2020 05:47:26 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsSq55dw+jgOwt8UF29jd+LPa0HKx6PQCpB+Gmuu75VhbBhuZS9h2rDYlVteXDwhjqurMAk X-Received: by 2002:aca:5194:: with SMTP id f142mr1010374oib.100.1583844446051; Tue, 10 Mar 2020 05:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583844446; cv=none; d=google.com; s=arc-20160816; b=nNKrtF6OHtMQBBV1O7TuVicyPSWhkP2Pkm02dxPMu5Jn0sPw2LTzkIF5H5aZKHCoee nGJ9sKocwPZaCrlyAAdtHDvYIFEVdiOUHnqUkR5EOmHZ1cWd0cwLoOx6+h4VVSxhvghS TX6bhYoSTrPocbkWNOq1ZjPh7ae7FZEIqJiTkshGedbi6yoVLU0/3WKE877P4ABJcrqt Xtx4q/9oH/hvy/w+aRO3tryxYH79XDDDmfOFZUUrlIFJyAZQ2dtMa6jK1jCHaIC6My0k doU6O68C3AC/9TcU3niJBHRTItjsm1Qw7S2AAujgryuo3QoImGX3VaNVwyrg++z7ZmR4 lv6w== 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=ZYxAZODQ6qJl9EqjjPG3En3k+xf7APsYykNm9yoQpw4=; b=iSIxDlVQE8aIqI4l4/nflzIas8VEZ6aNaUf5p27qNDzQWaqOzFT5jFdzC7fZ/toTgb Jm7Grs2dUx8MmWhXWkd6eOWWMjPolGMWZOQ0sfS3bks9g7joSDxRBYrn+3KPvRB+VueU qOntijbPSCcERbf8A5cnrXkOuDdHQNxDCTJIVE7Ax3hQRyDb4C042Z7TNDbSMNLviSh5 KH7n/cVHTwBo3DhD3KFZkyDMjXmeo3Zx/MInOfFpCtWcg1Ia0DUyIDRgjpIKhOh2jlZc TaHVzKhIIdgJ8l6tRgsyeu0X+ppvS4Jwkr2Me5qYrCdi9cg3VFnZ29E3Yjq64g+ExlTg 5QQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OGRsfUXl; 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 c85si5132928oig.225.2020.03.10.05.47.14; Tue, 10 Mar 2020 05:47:26 -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=OGRsfUXl; 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 S1726845AbgCJMq3 (ORCPT + 99 others); Tue, 10 Mar 2020 08:46:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:49692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728020AbgCJMq1 (ORCPT ); Tue, 10 Mar 2020 08:46:27 -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 E46DD2468D; Tue, 10 Mar 2020 12:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583844386; bh=A//OTV3+t80o4DfPxG+5T9Nazx04EEHsGGsu+omI/XM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OGRsfUXlizfVjX6q4EdMlMUkgJeTRCDOvzjEdIQ91tTVNf9/hZf/KpbXHD3V1awT7 2Cs+JIASsxwCFBhU2uLHw8euzqNStoH5rs9xAfaeAANkXkwsOWQMz3Et+B5tixTllS IVN/HNxhd92jhBtG/OoYrXJyksbn01FVrNyhggzg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cornelia Huck , Christian Borntraeger , Vasily Averin , Vasily Gorbik , Sasha Levin Subject: [PATCH 4.9 61/88] s390/cio: cio_ignore_proc_seq_next should increase position index Date: Tue, 10 Mar 2020 13:39:09 +0100 Message-Id: <20200310123621.642063499@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310123606.543939933@linuxfoundation.org> References: <20200310123606.543939933@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: Vasily Averin [ Upstream commit 8b101a5e14f2161869636ff9cb4907b7749dc0c2 ] if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output. Link: https://bugzilla.kernel.org/show_bug.cgi?id=206283 Link: https://lore.kernel.org/r/d44c53a7-9bc1-15c7-6d4a-0c10cb9dffce@virtuozzo.com Reviewed-by: Cornelia Huck Signed-off-by: Christian Borntraeger Signed-off-by: Vasily Averin Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- drivers/s390/cio/blacklist.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c index 9082476b51db9..4e9f794176d35 100644 --- a/drivers/s390/cio/blacklist.c +++ b/drivers/s390/cio/blacklist.c @@ -302,8 +302,10 @@ static void * cio_ignore_proc_seq_next(struct seq_file *s, void *it, loff_t *offset) { struct ccwdev_iter *iter; + loff_t p = *offset; - if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1)) + (*offset)++; + if (p >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1)) return NULL; iter = it; if (iter->devno == __MAX_SUBCHANNEL) { @@ -313,7 +315,6 @@ cio_ignore_proc_seq_next(struct seq_file *s, void *it, loff_t *offset) return NULL; } else iter->devno++; - (*offset)++; return iter; } -- 2.20.1