Source-Changes-HG archive

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

[src/trunk]: src/sys m_pullup() is called in rcvproc callback functions,



details:   https://anonhg.NetBSD.org/src/rev/7a9aee0b9965
branches:  trunk
changeset: 336917:7a9aee0b9965
user:      hikaru <hikaru%NetBSD.org@localhost>
date:      Fri Mar 27 07:18:11 2015 +0000

description:
m_pullup() is called in rcvproc callback functions,
so nfs_boot_sendrecv() should keep track of the head of mbuf chain.
fixes kern/48746

diffstat:

 sys/kern/subr_tftproot.c |  11 ++++++-----
 sys/nfs/krpc_subr.c      |  11 ++++++-----
 sys/nfs/nfs_boot.c       |   8 ++++----
 sys/nfs/nfs_bootdhcp.c   |  11 ++++++-----
 sys/nfs/nfsdiskless.h    |   4 ++--
 5 files changed, 24 insertions(+), 21 deletions(-)

diffs (198 lines):

diff -r c7abb7748b6a -r 7a9aee0b9965 sys/kern/subr_tftproot.c
--- a/sys/kern/subr_tftproot.c  Fri Mar 27 06:57:21 2015 +0000
+++ b/sys/kern/subr_tftproot.c  Fri Mar 27 07:18:11 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_tftproot.c,v 1.13 2014/08/26 09:38:54 manu Exp $ */
+/*     $NetBSD: subr_tftproot.c,v 1.14 2015/03/27 07:18:11 hikaru Exp $ */
 
 /*-
  * Copyright (c) 2007 Emmanuel Dreyfus, all rights reserved.
@@ -39,7 +39,7 @@
 #include "opt_md.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_tftproot.c,v 1.13 2014/08/26 09:38:54 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_tftproot.c,v 1.14 2015/03/27 07:18:11 hikaru Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -118,7 +118,7 @@
 int tftproot_dhcpboot(device_t);
 
 static int tftproot_getfile(struct tftproot_handle *, struct lwp *);
-static int tftproot_recv(struct mbuf *, void *);
+static int tftproot_recv(struct mbuf **, void *);
 
 int
 tftproot_dhcpboot(device_t bootdv)
@@ -350,10 +350,11 @@
 }
 
 static int
-tftproot_recv(struct mbuf *m, void *ctx)
+tftproot_recv(struct mbuf **mp, void *ctx)
 {
        struct tftproot_handle *trh = ctx;
        struct tftphdr *tftp;
+       struct mbuf *m = *mp;
        size_t newlen;
        size_t hdrlen = sizeof(*tftp) - sizeof(tftp->th_data);
 
@@ -380,7 +381,7 @@
         * Examine the TFTP header
         */
        if (m->m_len > sizeof(*tftp)) {
-               if ((m = m_pullup(m, sizeof(*tftp))) == NULL) {
+               if ((m = *mp = m_pullup(m, sizeof(*tftp))) == NULL) {
                        DPRINTF(("%s():%d m_pullup failed\n",
                            __func__, __LINE__));
                        return -1;
diff -r c7abb7748b6a -r 7a9aee0b9965 sys/nfs/krpc_subr.c
--- a/sys/nfs/krpc_subr.c       Fri Mar 27 06:57:21 2015 +0000
+++ b/sys/nfs/krpc_subr.c       Fri Mar 27 07:18:11 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: krpc_subr.c,v 1.38 2015/03/06 19:03:30 maxv Exp $      */
+/*     $NetBSD: krpc_subr.c,v 1.39 2015/03/27 07:18:11 hikaru Exp $    */
 
 /*
  * Copyright (c) 1995 Gordon Ross, Adam Glass
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: krpc_subr.c,v 1.38 2015/03/06 19:03:30 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: krpc_subr.c,v 1.39 2015/03/27 07:18:11 hikaru Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -124,7 +124,7 @@
 
 #define MIN_REPLY_HDR 16       /* xid, dir, astat, errno */
 
-static int krpccheck(struct mbuf*, void*);
+static int krpccheck(struct mbuf**, void*);
 
 /*
  * Call portmap to lookup a port number for a particular rpc program
@@ -183,15 +183,16 @@
        return 0;
 }
 
-static int krpccheck(struct mbuf *m, void *context)
+static int krpccheck(struct mbuf **mp, void *context)
 {
        struct rpc_reply *reply;
+       struct mbuf *m = *mp;
 
        /* Does the reply contain at least a header? */
        if (m->m_pkthdr.len < MIN_REPLY_HDR)
                return(-1);
        if (m->m_len < sizeof(struct rpc_reply)) {
-               m = m_pullup(m, sizeof(struct rpc_reply));
+               m = *mp = m_pullup(m, sizeof(struct rpc_reply));
                if (m == NULL)
                        return(-1);
        }
diff -r c7abb7748b6a -r 7a9aee0b9965 sys/nfs/nfs_boot.c
--- a/sys/nfs/nfs_boot.c        Fri Mar 27 06:57:21 2015 +0000
+++ b/sys/nfs/nfs_boot.c        Fri Mar 27 07:18:11 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_boot.c,v 1.81 2013/10/25 20:46:29 martin Exp $     */
+/*     $NetBSD: nfs_boot.c,v 1.82 2015/03/27 07:18:11 hikaru Exp $     */
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v 1.81 2013/10/25 20:46:29 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_boot.c,v 1.82 2015/03/27 07:18:11 hikaru Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -432,7 +432,7 @@
 nfs_boot_sendrecv(struct socket *so, struct mbuf *nam,
                int (*sndproc)(struct mbuf *, void *, int),
                struct mbuf *snd,
-               int (*rcvproc)(struct mbuf *, void *),
+               int (*rcvproc)(struct mbuf **, void *),
                struct mbuf **rcv, struct mbuf **from_p,
                void *context, struct lwp *lwp)
 {
@@ -510,7 +510,7 @@
                        panic("nfs_boot_sendrecv: return size");
 #endif
 
-               if ((*rcvproc)(m, context))
+               if ((*rcvproc)(&m, context))
                        continue;
 
                if (rcv)
diff -r c7abb7748b6a -r 7a9aee0b9965 sys/nfs/nfs_bootdhcp.c
--- a/sys/nfs/nfs_bootdhcp.c    Fri Mar 27 06:57:21 2015 +0000
+++ b/sys/nfs/nfs_bootdhcp.c    Fri Mar 27 07:18:11 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_bootdhcp.c,v 1.52 2010/10/04 23:48:22 cyber Exp $  */
+/*     $NetBSD: nfs_bootdhcp.c,v 1.53 2015/03/27 07:18:11 hikaru Exp $ */
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_bootdhcp.c,v 1.52 2010/10/04 23:48:22 cyber Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_bootdhcp.c,v 1.53 2015/03/27 07:18:11 hikaru Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs_boot.h"
@@ -302,7 +302,7 @@
 };
 
 static int bootpset (struct mbuf*, void*, int);
-static int bootpcheck (struct mbuf*, void*);
+static int bootpcheck (struct mbuf**, void*);
 
 static int
 bootpset(struct mbuf *m, void *context, int waited)
@@ -318,10 +318,11 @@
 }
 
 static int
-bootpcheck(struct mbuf *m, void *context)
+bootpcheck(struct mbuf **mp, void *context)
 {
        struct bootp *bootp;
        struct bootpcontext *bpc = context;
+       struct mbuf *m = *mp;
        u_int tag, len;
        u_char *p, *limit;
 
@@ -343,7 +344,7 @@
         * don't make first checks more expensive than necessary
         */
        if (m->m_len < offsetof(struct bootp, bp_sname)) {
-               m = m_pullup(m, offsetof(struct bootp, bp_sname));
+               m = *mp = m_pullup(m, offsetof(struct bootp, bp_sname));
                if (m == NULL) {
                        DPRINTF(("bootpcheck: m_pullup failed\n"));
                        return (-1);
diff -r c7abb7748b6a -r 7a9aee0b9965 sys/nfs/nfsdiskless.h
--- a/sys/nfs/nfsdiskless.h     Fri Mar 27 06:57:21 2015 +0000
+++ b/sys/nfs/nfsdiskless.h     Fri Mar 27 07:18:11 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfsdiskless.h,v 1.30 2010/10/04 23:48:23 cyber Exp $   */
+/*     $NetBSD: nfsdiskless.h,v 1.31 2015/03/27 07:18:11 hikaru Exp $  */
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
 int nfs_boot_sobind_ipport (struct socket *, uint16_t, struct lwp *);
 int nfs_boot_sendrecv (struct socket *, struct mbuf *,
                           int (*)(struct mbuf*, void*, int), struct mbuf*,
-                          int (*)(struct mbuf*, void*), struct mbuf**,
+                          int (*)(struct mbuf**, void*), struct mbuf**,
                           struct mbuf**, void*, struct lwp *);
 
 int nfs_bootdhcp  (struct nfs_diskless *, struct lwp *, int *);



Home | Main Index | Thread Index | Old Index