Source-Changes-HG archive

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

[src/netbsd-7]: src/common Pull up following revision(s) (requested by sborri...



details:   https://anonhg.NetBSD.org/src/rev/520aca512ebd
branches:  netbsd-7
changeset: 445479:520aca512ebd
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Oct 30 19:49:07 2018 +0000

description:
Pull up following revision(s) (requested by sborrill in ticket #1645):

        common/include/prop/prop_dictionary.h: revision 1.16
        common/include/prop/prop_array.h: revision 1.15
        common/lib/libprop/prop_kern.c: revision 1.21
        common/lib/libprop/prop_copyin_ioctl.9: revision 1.12
        common/include/prop/prop_array.h: revision 1.16
        common/lib/libprop/prop_kern.c: revision 1.22 (patch)
        common/lib/libprop/prop_kern.c: revision 1.23 (patch)

add sized versions of the copyin ioctls.

 -

add sized versions of the copyin ioctls

 -

Update for the new *_size() functions recently added.  Mention the
implicit size limit (128KB) for the functions which do not take an
explicit limit argument.

 -

fix args

 -

missing brace

 -

call the proper size functions

diffstat:

 common/include/prop/prop_array.h       |   7 +++-
 common/include/prop/prop_dictionary.h  |   7 +++-
 common/lib/libprop/prop_copyin_ioctl.9 |  40 +++++++++++++++++++-
 common/lib/libprop/prop_kern.c         |  66 ++++++++++++++++++++++++---------
 4 files changed, 98 insertions(+), 22 deletions(-)

diffs (280 lines):

diff -r 35ac3f7e23b3 -r 520aca512ebd common/include/prop/prop_array.h
--- a/common/include/prop/prop_array.h  Tue Oct 30 19:29:39 2018 +0000
+++ b/common/include/prop/prop_array.h  Tue Oct 30 19:49:07 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: prop_array.h,v 1.13 2011/09/30 22:08:18 jym Exp $    */
+/*     $NetBSD: prop_array.h,v 1.13.22.1 2018/10/30 19:49:07 martin Exp $    */
 
 /*-
  * Copyright (c) 2006, 2009 The NetBSD Foundation, Inc.
@@ -79,9 +79,14 @@
                                        prop_array_t *);
 #elif defined(_KERNEL)
 int            prop_array_copyin(const struct plistref *, prop_array_t *);
+int            prop_array_copyin_size(const struct plistref *, prop_array_t *,
+                                      size_t);
 int            prop_array_copyout(struct plistref *, prop_array_t);
 int            prop_array_copyin_ioctl(const struct plistref *, const u_long,
                                        prop_array_t *);
+int            prop_array_copyin_ioctl_size(const struct plistref *,
+                                            const u_long, prop_array_t *,
+                                            size_t);
 int            prop_array_copyout_ioctl(struct plistref *, const u_long,
                                         prop_array_t);
 #endif
diff -r 35ac3f7e23b3 -r 520aca512ebd common/include/prop/prop_dictionary.h
--- a/common/include/prop/prop_dictionary.h     Tue Oct 30 19:29:39 2018 +0000
+++ b/common/include/prop/prop_dictionary.h     Tue Oct 30 19:49:07 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: prop_dictionary.h,v 1.14 2011/09/30 22:08:18 jym Exp $ */
+/*     $NetBSD: prop_dictionary.h,v 1.14.22.1 2018/10/30 19:49:07 martin Exp $ */
 
 /*-
  * Copyright (c) 2006, 2009 The NetBSD Foundation, Inc.
@@ -102,11 +102,16 @@
 #elif defined(_KERNEL)
 int            prop_dictionary_copyin(const struct plistref *,
                                       prop_dictionary_t *);
+int            prop_dictionary_copyin_size(const struct plistref *,
+                                           prop_dictionary_t *, size_t);
 int            prop_dictionary_copyout(struct plistref *,
                                       prop_dictionary_t);
 int            prop_dictionary_copyin_ioctl(const struct plistref *,
                                             const u_long,
                                             prop_dictionary_t *);
+int            prop_dictionary_copyin_ioctl_size(const struct plistref *,
+                                                 const u_long,
+                                                 prop_dictionary_t *, size_t);
 int            prop_dictionary_copyout_ioctl(struct plistref *,
                                              const u_long,
                                              prop_dictionary_t);
diff -r 35ac3f7e23b3 -r 520aca512ebd common/lib/libprop/prop_copyin_ioctl.9
--- a/common/lib/libprop/prop_copyin_ioctl.9    Tue Oct 30 19:29:39 2018 +0000
+++ b/common/lib/libprop/prop_copyin_ioctl.9    Tue Oct 30 19:49:07 2018 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: prop_copyin_ioctl.9,v 1.9 2011/01/20 10:47:33 wiz Exp $
+.\"    $NetBSD: prop_copyin_ioctl.9,v 1.9.26.1 2018/10/30 19:49:07 martin Exp $
 .\"
 .\" Copyright (c) 2006, 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 17, 2011
+.Dd January 29, 2017
 .Dt PROP_COPYIN_IOCTL 9
 .Os
 .Sh NAME
@@ -46,9 +46,15 @@
 .Fn prop_array_copyin_ioctl "const struct plistref *pref" \
     "const u_long cmd" "prop_array_t *arrayp"
 .Ft int
+.Fn prop_array_copyin_ioctl_size "const struct plistref *pref" \
+    "const u_long cmd" "prop_array_t *arrayp" "size_t lim"
+.Ft int
 .Fn prop_array_copyin "const struct plistref *pref" \
     "prop_array_t *arrayp"
 .Ft int
+.Fn prop_array_copyin_size "const struct plistref *pref" \
+    "prop_array_t *arrayp" "size_t lim"
+.Ft int
 .Fn prop_array_copyout_ioctl "struct plistref *pref" \
     "const u_long cmd" "prop_array_t array"
 .Ft int
@@ -58,9 +64,15 @@
 .Fn prop_dictionary_copyin_ioctl "const struct plistref *pref" \
     "const u_long cmd" "prop_dictionary_t *dictp"
 .Ft int
+.Fn prop_dictionary_copyin_ioctl_size "const struct plistref *pref" \
+    "const u_long cmd" "prop_dictionary_t *dictp" "size_t lim"
+.Ft int
 .Fn prop_dictionary_copyin "const struct plistref *pref" \
     "prop_dictionary_t *dictp"
 .Ft int
+.Fn prop_dictionary_copyin_size "const struct plistref *pref" \
+    "prop_dictionary_t *dictp" "size_t lim"
+.Ft int
 .Fn prop_dictionary_copyout_ioctl "struct plistref *pref" \
     "const u_long cmd" "prop_dictionary_t dict"
 .Ft int
@@ -68,9 +80,12 @@
     "prop_dictionary_t dict"
 .Sh DESCRIPTION
 The
+.Nm prop_array_ioctl ,
 .Nm prop_array_copyin_ioctl ,
+.Nm prop_array_copyin_ioctl_size ,
 .Nm prop_array_copyout_ioctl ,
 .Nm prop_dictionary_copyin_ioctl ,
+.Nm prop_dictionary_copyin_ioctl_size ,
 and
 .Nm prop_dictionary_copyout_ioctl
 functions implement the kernel side of a protocol for copying property lists
@@ -78,8 +93,10 @@
 .Xr ioctl 2 .
 The functions
 .Nm prop_array_copyin ,
+.Nm prop_array_copyin_size ,
 .Nm prop_array_copyout ,
 .Nm prop_dictionary_copyin ,
+.Nm prop_dictionary_copyin_size ,
 and
 .Nm prop_dictionary_copyout
 implement the kernel side of a protocol for copying property lists to the
@@ -90,6 +107,25 @@
 .Vt struct plistref .
 This structure encapsulates the reference to the property list in externalized
 form.
+.Pp
+The functions
+.Nm prop_array_copyin_ioctl_size ,
+.Nm prop_dictionary_copyin_ioctl_size ,
+.Nm prop_array_copyin_size ,
+and
+.Nm prop_dictionary_copyin_size ,
+take an explicit limit argument
+.Ar lim
+while
+.Nm prop_array_copyin_ioctl ,
+.Nm prop_dictionary_copyin_ioctl ,
+.Nm prop_array_copyin ,
+and
+.Nm prop_dictionary_copyin ,
+have an implicit size limit of 128KB.
+Attempts to transfer objects larger than the limit result in an
+.Er E2BIG
+return value.
 .Sh RETURN VALUES
 If successful, functions return zero.
 Otherwise, an error number will be returned to indicate the error.
diff -r 35ac3f7e23b3 -r 520aca512ebd common/lib/libprop/prop_kern.c
--- a/common/lib/libprop/prop_kern.c    Tue Oct 30 19:29:39 2018 +0000
+++ b/common/lib/libprop/prop_kern.c    Tue Oct 30 19:49:07 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: prop_kern.c,v 1.17.22.2 2015/05/16 18:02:14 snj Exp $  */
+/*     $NetBSD: prop_kern.c,v 1.17.22.3 2018/10/30 19:49:07 martin Exp $       */
 
 /*-
  * Copyright (c) 2006, 2009 The NetBSD Foundation, Inc.
@@ -401,13 +401,13 @@
 
 static int
 _prop_object_copyin(const struct plistref *pref, const prop_type_t type,
-                         prop_object_t *objp)
+                         prop_object_t *objp, size_t lim)
 {
        prop_object_t obj = NULL;
        char *buf;
        int error;
 
-       if (pref->pref_len >= prop_object_copyin_limit)
+       if (pref->pref_len >= lim)
                return EINVAL;
 
        /*
@@ -449,12 +449,12 @@
 
 static int
 _prop_object_copyin_ioctl(const struct plistref *pref, const prop_type_t type,
-                         const u_long cmd, prop_object_t *objp)
+                         const u_long cmd, prop_object_t *objp, size_t lim)
 {
        if ((cmd & IOC_IN) == 0)
                return (EFAULT);
 
-       return _prop_object_copyin(pref, type, objp);
+       return _prop_object_copyin(pref, type, objp, lim);
 }
 
 /*
@@ -462,10 +462,17 @@
  *     Copy in an array passed as a syscall arg.
  */
 int
+prop_array_copyin_size(const struct plistref *pref, prop_array_t *arrayp,
+       size_t lim)
+{
+       return _prop_object_copyin(pref, PROP_TYPE_ARRAY,
+           (prop_object_t *)arrayp, lim);
+}
+
+int
 prop_array_copyin(const struct plistref *pref, prop_array_t *arrayp)
 {
-       return (_prop_object_copyin(pref, PROP_TYPE_ARRAY,
-                                         (prop_object_t *)arrayp));
+       return prop_array_copyin_size(pref, arrayp, prop_object_copyin_limit);
 }
 
 /*
@@ -473,23 +480,38 @@
  *     Copy in a dictionary passed as a syscall arg.
  */
 int
+prop_dictionary_copyin_size(const struct plistref *pref,
+    prop_dictionary_t *dictp, size_t lim)
+{
+       return _prop_object_copyin(pref, PROP_TYPE_DICTIONARY,
+           (prop_object_t *)dictp, lim);
+}
+
+int
 prop_dictionary_copyin(const struct plistref *pref, prop_dictionary_t *dictp)
 {
-       return (_prop_object_copyin(pref, PROP_TYPE_DICTIONARY,
-                                         (prop_object_t *)dictp));
+       return prop_dictionary_copyin_size(pref, dictp,
+           prop_object_copyin_limit);
 }
 
-
 /*
  * prop_array_copyin_ioctl --
  *     Copy in an array send with an ioctl.
  */
 int
-prop_array_copyin_ioctl(const struct plistref *pref, const u_long cmd,
-                       prop_array_t *arrayp)
+prop_array_copyin_ioctl_size(const struct plistref *pref, const u_long cmd,
+    prop_array_t *arrayp, size_t lim)
 {
-       return (_prop_object_copyin_ioctl(pref, PROP_TYPE_ARRAY,
-                                         cmd, (prop_object_t *)arrayp));
+       return _prop_object_copyin_ioctl(pref, PROP_TYPE_ARRAY,
+           cmd, (prop_object_t *)arrayp, lim);
+}
+
+int
+prop_array_copyin_ioctl(const struct plistref *pref, const u_long cmd,
+    prop_array_t *arrayp)
+{
+       return prop_array_copyin_ioctl_size(pref, cmd, arrayp,
+           prop_object_copyin_limit);
 }
 
 /*
@@ -497,11 +519,19 @@
  *     Copy in a dictionary sent with an ioctl.
  */
 int
-prop_dictionary_copyin_ioctl(const struct plistref *pref, const u_long cmd,
-                            prop_dictionary_t *dictp)
+prop_dictionary_copyin_ioctl_size(const struct plistref *pref, const u_long cmd,
+    prop_dictionary_t *dictp, size_t lim)
 {
-       return (_prop_object_copyin_ioctl(pref, PROP_TYPE_DICTIONARY,
-                                         cmd, (prop_object_t *)dictp));
+       return _prop_object_copyin_ioctl(pref, PROP_TYPE_DICTIONARY,
+           cmd, (prop_object_t *)dictp, lim);
+}
+
+int
+prop_dictionary_copyin_ioctl(const struct plistref *pref, const u_long cmd,
+    prop_dictionary_t *dictp)
+{
+    return prop_dictionary_copyin_ioctl_size(pref, cmd, dictp,
+       prop_object_copyin_limit);
 }
 
 static int



Home | Main Index | Thread Index | Old Index