Module Name: src Committed By: hikaru Date: Fri Mar 27 07:18:11 UTC 2015
Modified Files: src/sys/kern: subr_tftproot.c src/sys/nfs: krpc_subr.c nfs_boot.c nfs_bootdhcp.c nfsdiskless.h Log Message: m_pullup() is called in rcvproc callback functions, so nfs_boot_sendrecv() should keep track of the head of mbuf chain. fixes kern/48746 To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/kern/subr_tftproot.c cvs rdiff -u -r1.38 -r1.39 src/sys/nfs/krpc_subr.c cvs rdiff -u -r1.81 -r1.82 src/sys/nfs/nfs_boot.c cvs rdiff -u -r1.52 -r1.53 src/sys/nfs/nfs_bootdhcp.c cvs rdiff -u -r1.30 -r1.31 src/sys/nfs/nfsdiskless.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/subr_tftproot.c diff -u src/sys/kern/subr_tftproot.c:1.13 src/sys/kern/subr_tftproot.c:1.14 --- src/sys/kern/subr_tftproot.c:1.13 Tue Aug 26 09:38:54 2014 +++ src/sys/kern/subr_tftproot.c Fri Mar 27 07:18:11 2015 @@ -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 @@ struct tftproot_handle { 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 @@ out: } 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 @@ tftproot_recv(struct mbuf *m, void *ctx) * 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; Index: src/sys/nfs/krpc_subr.c diff -u src/sys/nfs/krpc_subr.c:1.38 src/sys/nfs/krpc_subr.c:1.39 --- src/sys/nfs/krpc_subr.c:1.38 Fri Mar 6 19:03:30 2015 +++ src/sys/nfs/krpc_subr.c Fri Mar 27 07:18:11 2015 @@ -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 @@ struct rpc_reply { #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 @@ krpc_portmap(struct sockaddr_in *sin, u_ 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); } Index: src/sys/nfs/nfs_boot.c diff -u src/sys/nfs/nfs_boot.c:1.81 src/sys/nfs/nfs_boot.c:1.82 --- src/sys/nfs/nfs_boot.c:1.81 Fri Oct 25 20:46:29 2013 +++ src/sys/nfs/nfs_boot.c Fri Mar 27 07:18:11 2015 @@ -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 @@ int 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 @@ send_again: panic("nfs_boot_sendrecv: return size"); #endif - if ((*rcvproc)(m, context)) + if ((*rcvproc)(&m, context)) continue; if (rcv) Index: src/sys/nfs/nfs_bootdhcp.c diff -u src/sys/nfs/nfs_bootdhcp.c:1.52 src/sys/nfs/nfs_bootdhcp.c:1.53 --- src/sys/nfs/nfs_bootdhcp.c:1.52 Mon Oct 4 23:48:22 2010 +++ src/sys/nfs/nfs_bootdhcp.c Fri Mar 27 07:18:11 2015 @@ -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 @@ struct bootpcontext { }; 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 @@ bootpset(struct mbuf *m, void *context, } 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 @@ bootpcheck(struct mbuf *m, void *context * 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); Index: src/sys/nfs/nfsdiskless.h diff -u src/sys/nfs/nfsdiskless.h:1.30 src/sys/nfs/nfsdiskless.h:1.31 --- src/sys/nfs/nfsdiskless.h:1.30 Mon Oct 4 23:48:23 2010 +++ src/sys/nfs/nfsdiskless.h Fri Mar 27 07:18:11 2015 @@ -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_enbroadcast (struct socket 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 *);