buffer pager: deref ucred immediately after read.

Ucred is passed to bread(9) so that non-local filesystems use proper
credentials.  But, since clean buffer might be cached unless
buf_pager_relbuf is not enabled, it makes credentials to have extra
reference until buffer is reclaimed.  Ucred reference would prevent
jail from destroying if creds are jailed.

Dereferencing the read credentials on the valid buffer avoid that, and
should be fine because the buffer is valid and does not need re-read.

PR:	238032
Reported by:	bz
Reproduced and tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D23775
This commit is contained in:
Konstantin Belousov 2020-03-05 15:52:34 +00:00
parent 0a052459e6
commit 695e0701a0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=358676

View File

@ -5187,6 +5187,10 @@ vfs_bio_getpages(struct vnode *vp, vm_page_t *ma, int count,
br_flags, &bp);
if (error != 0)
goto end_pages;
if (bp->b_rcred == curthread->td_ucred) {
crfree(bp->b_rcred);
bp->b_rcred = NOCRED;
}
if (LIST_EMPTY(&bp->b_dep)) {
/*
* Invalidation clears m->valid, but