Fix detection of EOF in kern_physio(). If bio_length was clipped by

the excess code in g_io_check(), bio_resid is also truncated by
g_io_deliver().  As result, bufdonebio() assigns truncated value to
the buffer b_resid field.

Use the residual bio_completed to calculate buffer b_resid from
b_bcount in bufdonebio(), instead of bio_resid, calculated from
bio_length in g_io_deliver().

The issue is seemingly caused by the code rearrange into g_io_check(),
which is not present in stable/10.  The change still looks as the
useful change to have in 10 nevertheless.

Reported by:	Stefan Hegnauer <stefan.hegnauer@gmx.ch>
Tested by:	pho, Stefan Hegnauer <stefan.hegnauer@gmx.ch>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2013-12-10 21:15:18 +00:00
parent 641ed4622f
commit b4aa4fed2b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=259200

View File

@ -3679,7 +3679,6 @@ bufdonebio(struct bio *bip)
bp = bip->bio_caller2;
bp->b_resid = bp->b_bcount - bip->bio_completed;
bp->b_resid = bip->bio_resid; /* XXX: remove */
bp->b_ioflags = bip->bio_flags;
bp->b_error = bip->bio_error;
if (bp->b_error)