summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_sockbuf.c
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>2000-08-29 11:28:06 +0000
committergreen <green@FreeBSD.org>2000-08-29 11:28:06 +0000
commit0fa5ae2859837ce45dfa1d212731cbed7a6bf037 (patch)
treea0487072d9e3fda944c9970116207cd67e21e923 /sys/kern/uipc_sockbuf.c
parent0290d697a80874eccbc3e0228ae5f2acb2b7522c (diff)
downloadFreeBSD-src-0fa5ae2859837ce45dfa1d212731cbed7a6bf037.zip
FreeBSD-src-0fa5ae2859837ce45dfa1d212731cbed7a6bf037.tar.gz
Remove any possibility of hiwat-related race conditions by changing
the chgsbsize() call to use a "subject" pointer (&sb.sb_hiwat) and a u_long target to set it to. The whole thing is splnet(). This fixes a problem that jdp has been able to provoke.
Diffstat (limited to 'sys/kern/uipc_sockbuf.c')
-rw-r--r--sys/kern/uipc_sockbuf.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
index 3ff1a9c..542ef6e 100644
--- a/sys/kern/uipc_sockbuf.c
+++ b/sys/kern/uipc_sockbuf.c
@@ -420,7 +420,6 @@ sbreserve(sb, cc, so, p)
struct socket *so;
struct proc *p;
{
- rlim_t delta;
/*
* p will only be NULL when we're in an interrupt
@@ -428,8 +427,7 @@ sbreserve(sb, cc, so, p)
*/
if ((u_quad_t)cc > (u_quad_t)sb_max * MCLBYTES / (MSIZE + MCLBYTES))
return (0);
- delta = (rlim_t)cc - sb->sb_hiwat;
- if (p && !chgsbsize(so->so_cred->cr_uid, delta,
+ if (p && !chgsbsize(so->so_cred->cr_uid, &sb->sb_hiwat, cc,
p->p_rlimit[RLIMIT_SBSIZE].rlim_cur)) {
return (0);
}
@@ -450,8 +448,8 @@ sbrelease(sb, so)
{
sbflush(sb);
- (void)chgsbsize(so->so_cred->cr_uid, -(rlim_t)sb->sb_hiwat, RLIM_INFINITY);
- sb->sb_hiwat = sb->sb_mbmax = 0;
+ (void)chgsbsize(so->so_cred->cr_uid, &sb->sb_hiwat, 0, RLIM_INFINITY);
+ sb->sb_mbmax = 0;
}
/*
OpenPOWER on IntegriCloud