Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys raw_detach: rawpcb may be embedded, free using the real ...
details: https://anonhg.NetBSD.org/src/rev/750dbb409ed5
branches: trunk
changeset: 796138:750dbb409ed5
user: rmind <rmind%NetBSD.org@localhost>
date: Wed May 21 20:43:56 2014 +0000
description:
raw_detach: rawpcb may be embedded, free using the real size (saved in rcb).
diffstat:
sys/net/raw_cb.c | 11 ++++++-----
sys/net/raw_cb.h | 6 ++++--
sys/net/rtsock.c | 5 +++--
sys/netipsec/keysock.c | 5 +++--
4 files changed, 16 insertions(+), 11 deletions(-)
diffs (127 lines):
diff -r 7db9ce2bb17d -r 750dbb409ed5 sys/net/raw_cb.c
--- a/sys/net/raw_cb.c Wed May 21 19:33:51 2014 +0000
+++ b/sys/net/raw_cb.c Wed May 21 20:43:56 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: raw_cb.c,v 1.21 2014/05/19 02:51:24 rmind Exp $ */
+/* $NetBSD: raw_cb.c,v 1.22 2014/05/21 20:43:56 rmind Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_cb.c,v 1.21 2014/05/19 02:51:24 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_cb.c,v 1.22 2014/05/21 20:43:56 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -100,18 +100,19 @@
raw_detach(struct socket *so)
{
struct rawcb *rp = sotorawcb(so);
+ const size_t rcb_len = rp->rcb_len;
KASSERT(rp != NULL);
KASSERT(solocked(so));
KASSERT(so->so_lock == softnet_lock); /* XXX */
- LIST_REMOVE(rp, rcb_list); /* remove last reference */
+ /* Remove the last reference. */
+ LIST_REMOVE(rp, rcb_list);
so->so_pcb = NULL;
/* Note: sofree() drops the socket's lock. */
sofree(so);
- kmem_free(rp, sizeof(*rp));
-
+ kmem_free(rp, rcb_len);
mutex_enter(softnet_lock);
}
diff -r 7db9ce2bb17d -r 750dbb409ed5 sys/net/raw_cb.h
--- a/sys/net/raw_cb.h Wed May 21 19:33:51 2014 +0000
+++ b/sys/net/raw_cb.h Wed May 21 20:43:56 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: raw_cb.h,v 1.21 2014/05/19 02:51:24 rmind Exp $ */
+/* $NetBSD: raw_cb.h,v 1.22 2014/05/21 20:43:56 rmind Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -34,6 +34,8 @@
#ifndef _NET_RAW_CB_H_
#define _NET_RAW_CB_H_
+#ifdef _KERNEL
+
/*
* Raw protocol interface control block. Used
* to tie a socket to the generic raw interface.
@@ -44,6 +46,7 @@
struct sockaddr *rcb_faddr; /* destination address */
struct sockaddr *rcb_laddr; /* socket's address */
struct sockproto rcb_proto; /* protocol family, protocol */
+ size_t rcb_len;
};
#define sotorawcb(so) ((struct rawcb *)(so)->so_pcb)
@@ -54,7 +57,6 @@
#define RAWSNDQ 8192
#define RAWRCVQ 8192
-#ifdef _KERNEL
LIST_HEAD(rawcbhead, rawcb);
extern struct rawcbhead rawcb; /* head of list */
diff -r 7db9ce2bb17d -r 750dbb409ed5 sys/net/rtsock.c
--- a/sys/net/rtsock.c Wed May 21 19:33:51 2014 +0000
+++ b/sys/net/rtsock.c Wed May 21 20:43:56 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock.c,v 1.146 2014/05/20 19:04:00 rmind Exp $ */
+/* $NetBSD: rtsock.c,v 1.147 2014/05/21 20:43:56 rmind Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.146 2014/05/20 19:04:00 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.147 2014/05/21 20:43:56 rmind Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -184,6 +184,7 @@
KASSERT(sotorawcb(so) == NULL);
rp = kmem_zalloc(sizeof(*rp), KM_SLEEP);
+ rp->rcb_len = sizeof(*rp);
so->so_pcb = rp;
s = splsoftnet();
diff -r 7db9ce2bb17d -r 750dbb409ed5 sys/netipsec/keysock.c
--- a/sys/netipsec/keysock.c Wed May 21 19:33:51 2014 +0000
+++ b/sys/netipsec/keysock.c Wed May 21 20:43:56 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: keysock.c,v 1.24 2014/05/20 19:04:00 rmind Exp $ */
+/* $NetBSD: keysock.c,v 1.25 2014/05/21 20:43:56 rmind Exp $ */
/* $FreeBSD: src/sys/netipsec/keysock.c,v 1.3.2.1 2003/01/24 05:11:36 sam Exp $ */
/* $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $ */
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.24 2014/05/20 19:04:00 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.25 2014/05/21 20:43:56 rmind Exp $");
#include "opt_ipsec.h"
@@ -631,6 +631,7 @@
KASSERT(sotorawcb(so) == NULL);
kp = kmem_zalloc(sizeof(*kp), KM_SLEEP);
+ kp->kp_raw.rcb_len = sizeof(*kp);
so->so_pcb = kp;
s = splsoftnet();
Home |
Main Index |
Thread Index |
Old Index