Bug 237883 - pseudofs truncates pfs_read output to MAXPHYS
Summary: pseudofs truncates pfs_read output to MAXPHYS
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Dmitry Chagin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-13 16:52 UTC by Dmitry Chagin
Modified: 2021-05-01 00:39 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Chagin freebsd_committer 2019-05-13 16:52:25 UTC
pfs_read() code:

        buflen = uio->uio_offset + uio->uio_resid;
        if (buflen > MAXPHYS)
                buflen = MAXPHYS;

        sb = sbuf_new(sb, NULL, buflen + 1, 0);
        if (sb == NULL) {
                error = EIO;
                goto ret;
        }

strange code, I need to redo it to autoextend
Comment 1 Dmitry Chagin freebsd_committer 2019-05-13 16:53:24 UTC
grab it, not to forget
Comment 2 Conrad Meyer freebsd_committer 2019-05-13 17:29:52 UTC
It doesn't seem like pfs_read's locking needs a fixed sized buffer, but perhaps something internal to pn_fill() writes to the sbuf under non-sleepable lock.

The uiomove() below in pfs_read() checks for len <= IOSIZE_MAX rather than MAXPHYS, but that could be invoked on smaller chunks in a loop?
Comment 3 Dmitry Chagin freebsd_committer 2019-05-14 06:35:08 UTC
hi, I created this PR not to forget about the problem and I have not investigated it yet, but seems that you are right.
the best solution apparently use some constant which will be > MAXPHYS, may be IOMAX_SIZE or multiple MAXPHYS
Comment 4 commit-hook freebsd_committer 2020-10-16 09:59:09 UTC
A commit references this bug:

Author: trasz
Date: Fri Oct 16 09:58:11 UTC 2020
New revision: 366748
URL: https://svnweb.freebsd.org/changeset/base/366748

Log:
  Bump pseudofs size limit from 128kB to 1MB.  The old limit could result
  in process' memory maps being truncated.

  PR:		237883
  Submitted by:	dchagin
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D20575

Changes:
  head/sys/fs/pseudofs/pseudofs_vnops.c
Comment 5 commit-hook freebsd_committer 2021-05-01 00:39:41 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=72e1884f593f9b86c9ea4e74d02449f6678770dd

commit 72e1884f593f9b86c9ea4e74d02449f6678770dd
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2020-10-16 09:58:10 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-05-01 00:38:30 +0000

    Bump pseudofs size limit from 128kB to 1MB.

    PR:             237883

    (cherry picked from commit ce764cbd1c725c54966315949fe93eb3994c1b5e)

 sys/fs/pseudofs/pseudofs_vnops.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)