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
Depends on:
Reported: 2019-05-13 16:52 UTC by Dmitry Chagin
Modified: 2020-10-16 09:59 UTC (History)
2 users (show)

See Also:


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

  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