Thu Apr 23 09:40:08 2020 UTC ()
pass b_flags B_PHYS and B_RAW when setting up the buf for underlying device

should fix misfired KASSERT() in xbd(4)


(jdolecek)
diff -r1.276 -r1.277 src/sys/dev/vnd.c

cvs diff -r1.276 -r1.277 src/sys/dev/vnd.c (expand / switch to unified diff)

--- src/sys/dev/vnd.c 2020/04/13 08:05:02 1.276
+++ src/sys/dev/vnd.c 2020/04/23 09:40:08 1.277
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: vnd.c,v 1.276 2020/04/13 08:05:02 maxv Exp $ */ 1/* $NetBSD: vnd.c,v 1.277 2020/04/23 09:40:08 jdolecek Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996, 1997, 1998, 2008, 2020 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1998, 2008, 2020 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe. 8 * by Jason R. Thorpe.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -81,27 +81,27 @@ @@ -81,27 +81,27 @@
81 * systems where the block-level operations are not implemented for 81 * systems where the block-level operations are not implemented for
82 * whatever reason. 82 * whatever reason.
83 * 83 *
84 * NOTE 2: There is a security issue involved with this driver. 84 * NOTE 2: There is a security issue involved with this driver.
85 * Once mounted all access to the contents of the "mapped" file via 85 * Once mounted all access to the contents of the "mapped" file via
86 * the special file is controlled by the permissions on the special 86 * the special file is controlled by the permissions on the special
87 * file, the protection of the mapped file is ignored (effectively, 87 * file, the protection of the mapped file is ignored (effectively,
88 * by using root credentials in all transactions). 88 * by using root credentials in all transactions).
89 * 89 *
90 * NOTE 3: Doesn't interact with leases, should it? 90 * NOTE 3: Doesn't interact with leases, should it?
91 */ 91 */
92 92
93#include <sys/cdefs.h> 93#include <sys/cdefs.h>
94__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.276 2020/04/13 08:05:02 maxv Exp $"); 94__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.277 2020/04/23 09:40:08 jdolecek Exp $");
95 95
96#if defined(_KERNEL_OPT) 96#if defined(_KERNEL_OPT)
97#include "opt_vnd.h" 97#include "opt_vnd.h"
98#include "opt_compat_netbsd.h" 98#include "opt_compat_netbsd.h"
99#endif 99#endif
100 100
101#include <sys/param.h> 101#include <sys/param.h>
102#include <sys/systm.h> 102#include <sys/systm.h>
103#include <sys/namei.h> 103#include <sys/namei.h>
104#include <sys/proc.h> 104#include <sys/proc.h>
105#include <sys/kthread.h> 105#include <sys/kthread.h>
106#include <sys/errno.h> 106#include <sys/errno.h>
107#include <sys/buf.h> 107#include <sys/buf.h>
@@ -714,27 +714,27 @@ vndthread(void *arg) @@ -714,27 +714,27 @@ vndthread(void *arg)
714 714
715 s = splbio(); 715 s = splbio();
716 while (vnd->sc_active >= vnd->sc_maxactive) { 716 while (vnd->sc_active >= vnd->sc_maxactive) {
717 tsleep(&vnd->sc_tab, PRIBIO, "vndac", 0); 717 tsleep(&vnd->sc_tab, PRIBIO, "vndac", 0);
718 } 718 }
719 vnd->sc_active++; 719 vnd->sc_active++;
720 splx(s); 720 splx(s);
721 721
722 /* Instrumentation. */ 722 /* Instrumentation. */
723 disk_busy(&vnd->sc_dkdev); 723 disk_busy(&vnd->sc_dkdev);
724 724
725 bp = &vnx->vx_buf; 725 bp = &vnx->vx_buf;
726 buf_init(bp); 726 buf_init(bp);
727 bp->b_flags = (obp->b_flags & B_READ); 727 bp->b_flags = (obp->b_flags & (B_READ | B_PHYS | B_RAW));
728 bp->b_oflags = obp->b_oflags; 728 bp->b_oflags = obp->b_oflags;
729 bp->b_cflags = obp->b_cflags; 729 bp->b_cflags = obp->b_cflags;
730 bp->b_iodone = vndiodone; 730 bp->b_iodone = vndiodone;
731 bp->b_private = obp; 731 bp->b_private = obp;
732 bp->b_vp = vnd->sc_vp; 732 bp->b_vp = vnd->sc_vp;
733 bp->b_objlock = bp->b_vp->v_interlock; 733 bp->b_objlock = bp->b_vp->v_interlock;
734 bp->b_data = obp->b_data; 734 bp->b_data = obp->b_data;
735 bp->b_bcount = obp->b_bcount; 735 bp->b_bcount = obp->b_bcount;
736 BIO_COPYPRIO(bp, obp); 736 BIO_COPYPRIO(bp, obp);
737 737
738 /* Make sure the request succeeds while suspending this fs. */ 738 /* Make sure the request succeeds while suspending this fs. */
739 fstrans_start_lazy(vnd->sc_vp->v_mount); 739 fstrans_start_lazy(vnd->sc_vp->v_mount);
740 740