Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern sys/kern: Avoid fp->f_offset without the object (he...
details: https://anonhg.NetBSD.org/src/rev/71951e5d29be
branches: trunk
changeset: 1023496:71951e5d29be
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Sep 11 10:09:13 2021 +0000
description:
sys/kern: Avoid fp->f_offset without the object (here, vnode) lock.
diffstat:
sys/kern/sys_descrip.c | 9 ++++++---
sys/kern/vfs_vnops.c | 7 ++++---
2 files changed, 10 insertions(+), 6 deletions(-)
diffs (62 lines):
diff -r 625e8e22399e -r 71951e5d29be sys/kern/sys_descrip.c
--- a/sys/kern/sys_descrip.c Sat Sep 11 10:08:55 2021 +0000
+++ b/sys/kern/sys_descrip.c Sat Sep 11 10:09:13 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_descrip.c,v 1.37 2020/02/23 15:46:41 ad Exp $ */
+/* $NetBSD: sys_descrip.c,v 1.38 2021/09/11 10:09:13 riastradh Exp $ */
/*-
* Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.37 2020/02/23 15:46:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.38 2021/09/11 10:09:13 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -243,8 +243,11 @@
return error;
vp = fp->f_vnode;
- if (fl->l_whence == SEEK_CUR)
+ if (fl->l_whence == SEEK_CUR) {
+ vn_lock(vp, LK_SHARED | LK_RETRY);
fl->l_start += fp->f_offset;
+ VOP_UNLOCK(vp);
+ }
flg = F_POSIX;
p = curproc;
diff -r 625e8e22399e -r 71951e5d29be sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c Sat Sep 11 10:08:55 2021 +0000
+++ b/sys/kern/vfs_vnops.c Sat Sep 11 10:09:13 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnops.c,v 1.222 2021/09/11 10:08:55 riastradh Exp $ */
+/* $NetBSD: vfs_vnops.c,v 1.223 2021/09/11 10:09:13 riastradh Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.222 2021/09/11 10:08:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.223 2021/09/11 10:09:13 riastradh Exp $");
#include "veriexec.h"
@@ -817,10 +817,11 @@
if (com == FIONREAD) {
vn_lock(vp, LK_SHARED | LK_RETRY);
error = VOP_GETATTR(vp, &vattr, kauth_cred_get());
+ if (error == 0)
+ *(int *)data = vattr.va_size - fp->f_offset;
VOP_UNLOCK(vp);
if (error)
return (error);
- *(int *)data = vattr.va_size - fp->f_offset;
return (0);
}
if ((com == FIONWRITE) || (com == FIONSPACE)) {
Home |
Main Index |
Thread Index |
Old Index