Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6926344ybi; Thu, 1 Aug 2019 00:28:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWe40XSWsMgMiGzo85z+kY0ouaAnjHSO+NZv1TVlsI8trNYJAFi2amVQ/rhUFQGDtGzlcE X-Received: by 2002:a17:90a:220a:: with SMTP id c10mr7072094pje.33.1564644503005; Thu, 01 Aug 2019 00:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564644502; cv=none; d=google.com; s=arc-20160816; b=mF+NxBcHzlDL3ysIV3olSjmLiM/6vQOmRoJkv2Gu9ROnSZO/eT8CuYbPeA2F3AM8hU 2tRCPH69deO6ukO1tE/2NMwdy7CiuYwU/Erul2x7CKkFi/bBsAVW0eVNIhDVDB4QAFhy ZAgBiSgxOZPchn/PPIkvbgfjilMPXJWgQ9mJQxgRnBgRnfQwlJNpCrWmd4yN23kzFfdG T4+IUVt+axeupkvTyWAp9oZAOMqohtLkcTIWQsb5C6EiteVMleofhX1llXWfFhrM8H6b 3T7a5VXAuZ4wuLWjQB8+s4xWapMPf31/hbQhZbrOXIXl0YS0/2M18yenE3SjHitFk202 4XuA== 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 :content-language:mime-version:user-agent:date:message-id :organization:cc:to:subject:from; bh=CtqNoQtz91hwBlSzDS8kkgEAusjunj1ry+QwTlX2+Jo=; b=Dob0cwYMQfDaTBo2ybSaBhhP2Wfzhg9oDx3xAmZZM8eW6OBwQKztygiSYL2XKMGRP6 rp1sv9fXDkQBmVQtP75EMuA0vWupTLXqx+AmQBbTtBmh0qV2NW5Dgbezhvl7pu1rvqn8 ezYZVG78nX9FDqVFUTkavqyVmOn8WDssTlXNBlA/qsL5QKDn1fbJt4DJMQGoCLG1f3BN pzUhBJe+FVwJuqG2w1ECQVlOiodB3hNXFjaRpCrN1xwhTn7ePkemyQ1wWgqf3MX7zKr7 ErOj9wiLnVJxDEscIyAseQZlj/p1ajKtX1108g8jTe2cwhbgX2c6b03oc5P7vWP67fZm 9ecA== ARC-Authentication-Results: i=1; mx.google.com; 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 f12si36299824pfq.187.2019.08.01.00.28.07; Thu, 01 Aug 2019 00:28:22 -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; 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 S1729580AbfHAGRE convert rfc822-to-8bit (ORCPT + 99 others); Thu, 1 Aug 2019 02:17:04 -0400 Received: from mx1.mail.vl.ru ([80.92.161.250]:55790 "EHLO mx1.mail.vl.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728372AbfHAGRE (ORCPT ); Thu, 1 Aug 2019 02:17:04 -0400 Received: from localhost (unknown [127.0.0.1]) by mx1.mail.vl.ru (Postfix) with ESMTP id D4EEC1860D6E; Thu, 1 Aug 2019 06:16:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at mail.vl.ru Received: from mx1.mail.vl.ru ([127.0.0.1]) by localhost (smtp1.srv.loc [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aH4rQ_CGdhjD; Thu, 1 Aug 2019 16:16:58 +1000 (+10) Received: from [10.125.1.12] (unknown [109.126.62.18]) (Authenticated sender: turchanov@vl.ru) by mx1.mail.vl.ru (Postfix) with ESMTPSA id A4324184BFDD; Thu, 1 Aug 2019 16:16:58 +1000 (+10) From: Sergei Turchanov Subject: [BUG] lseek on /proc/meminfo is broken in 4.19.59 To: Alexander Viro , linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Organization: FarPost Message-ID: <3bd775ab-9e31-c6b3-374e-7a9982a9a8cd@farpost.com> Date: Thu, 1 Aug 2019 16:16:58 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! (I sent this e-mail two weeks ago with no feedback. Does anyone care? Wrong mailing list? Anything....?) Seeking (to an offset within file size) in /proc/meminfo is broken in 4.19.59. It does seek to a desired position, but reading from that position returns the remainder of file and then a whole copy of file. This doesn't happen with /proc/vmstat or /proc/self/maps for example. Seeking did work correctly in kernel 4.14.47. So it seems something broke in the way. Background: this kind of access pattern (seeking to /proc/meminfo) is used by libvirt-lxc fuse driver for virtualized view of /proc/meminfo. So that /proc/meminfo is broken in guests when running kernel 4.19.x. $ ./test /proc/meminfo 0        # Works as expected MemTotal:       394907728 kB MemFree:        173738328 kB ... DirectMap2M:    13062144 kB DirectMap1G:    390070272 kB ----------------------------------------------------------------------- $ ./test 1024                   # returns a copy of file after the remainder Will seek to 1024 Data read at offset 1024 gePages:         0 kB ShmemHugePages:        0 kB ShmemPmdMapped:        0 kB HugePages_Total:       0 HugePages_Free:        0 HugePages_Rsvd:        0 HugePages_Surp:        0 Hugepagesize:       2048 kB Hugetlb:               0 kB DirectMap4k:      245204 kB DirectMap2M:    13062144 kB DirectMap1G:    390070272 kB MemTotal:       394907728 kB MemFree:        173738328 kB MemAvailable:   379989680 kB Buffers:          355812 kB Cached:         207216224 kB ... DirectMap2M:    13062144 kB DirectMap1G:    390070272 kB As you see, after "DirectMap1G:" line, a whole copy of /proc/meminfo returned by "read". Test program: #include #include #include #include #include #include #define SIZE 1024 char buf[SIZE + 1]; int main(int argc, char *argv[]) {     int     fd;     ssize_t rd;     off_t   ofs = 0;     if (argc < 2) {         printf("Usage: test []\n");         exit(1);     }     if (-1 == (fd = open(argv[1], O_RDONLY))) {         perror("open failed");         exit(1);     }     if (argc > 2) {         ofs = atol(argv[2]);     }     printf("Will seek to %ld\n", ofs);     if (-1 == (lseek(fd, ofs, SEEK_SET))) {         perror("lseek failed");         exit(1);     }     for (;; ofs += rd) {         printf("\n\nData read at offset %ld\n", ofs);         if (-1 == (rd = read(fd, buf, SIZE))) {             perror("read failed");             exit(1);         }         buf[rd] = '\0';         printf(buf);         if (rd < SIZE) {             break;         }     }     return 0; }