Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/filemon filemon_ioctl: check fd for write permission



details:   https://anonhg.NetBSD.org/src/rev/206ae433fe43
branches:  trunk
changeset: 464977:206ae433fe43
user:      sjg <sjg%NetBSD.org@localhost>
date:      Wed Oct 30 18:35:06 2019 +0000

description:
filemon_ioctl: check fd for write permission

Reviewed by: christos
Reported by: ivansprundel

diffstat:

 sys/dev/filemon/filemon.c |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (30 lines):

diff -r 17cbc0b547b9 -r 206ae433fe43 sys/dev/filemon/filemon.c
--- a/sys/dev/filemon/filemon.c Wed Oct 30 17:06:57 2019 +0000
+++ b/sys/dev/filemon/filemon.c Wed Oct 30 18:35:06 2019 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: filemon.c,v 1.30 2018/06/06 01:49:08 maya Exp $ */
+/*      $NetBSD: filemon.c,v 1.31 2019/10/30 18:35:06 sjg Exp $ */
 /*
  * Copyright (c) 2010, Juniper Networks, Inc.
  *
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.30 2018/06/06 01:49:08 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.31 2019/10/30 18:35:06 sjg Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -315,6 +315,11 @@
                        error = EBADF;
                        break;
                }
+               if ((filemon->fm_fp->f_flag & FWRITE) == 0) {
+                       closef(filemon->fm_fp);
+                       filemon->fm_fp = NULL;
+                       return (EBADF);
+               }
                /* Write the file header. */
                filemon_comment(filemon);
                break;



Home | Main Index | Thread Index | Old Index