Browse Source

Merge branch 'freebsd/current/master' into hardened/current/master

* freebsd/current/master:
  telnet: kill off remaining duplicate definition
  Handle integer overflows correctly when converting msecs and secs to ticks and vice versa. These issues were caught by recently added panic() calls on INVARIANTS systems.
  Re-apply r359399: telnet -fno-common fix
  Revert 359399: telnet -fno-common bits
  MFV r359401: OpenBSM: import ee79d73e8df5: auditreduce: add a zone filter
  telnet: remove some duplicate definitions, mark terminaltype extern
  sh: remove duplicate el definition
  zfs: fix -fno-common issues
  hdaa: remove verbosity from the normal driver operations.
  arch.7: update Default Tool Chain section
remotes/github/hardened/current/tmpfs_extattr
HardenedBSD Sync Service 4 months ago
parent
commit
7923c952b4
21 changed files with 215 additions and 137 deletions
  1. +0
    -2
      bin/sh/input.c
  2. +1
    -1
      cddl/contrib/opensolaris/cmd/zfs/zfs_util.h
  3. +2
    -0
      cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
  4. +1
    -1
      cddl/contrib/opensolaris/cmd/zpool/zpool_util.h
  5. +6
    -1
      contrib/openbsm/bin/auditreduce/auditreduce.1
  6. +30
    -1
      contrib/openbsm/bin/auditreduce/auditreduce.c
  7. +1
    -0
      contrib/openbsm/bin/auditreduce/auditreduce.h
  8. +33
    -29
      contrib/telnet/telnetd/ext.h
  9. +1
    -1
      contrib/telnet/telnetd/global.c
  10. +0
    -2
      contrib/telnet/telnetd/sys_term.c
  11. +0
    -1
      contrib/telnet/telnetd/telnetd.c
  12. +5
    -28
      share/man/man7/arch.7
  13. +1
    -11
      sys/dev/sound/pci/hda/hdac.c
  14. +2
    -2
      sys/netinet/sctp_cc_functions.c
  15. +0
    -10
      sys/netinet/sctp_constants.h
  16. +1
    -1
      sys/netinet/sctp_input.c
  17. +8
    -8
      sys/netinet/sctp_pcb.c
  18. +1
    -1
      sys/netinet/sctp_timer.c
  19. +17
    -15
      sys/netinet/sctp_usrreq.c
  20. +100
    -22
      sys/netinet/sctputil.c
  21. +5
    -0
      sys/netinet/sctputil.h

+ 0
- 2
bin/sh/input.c View File

@@ -102,8 +102,6 @@ static struct parsefile basepf = { /* top level input file */
static struct parsefile *parsefile = &basepf; /* current input file */
int whichprompt; /* 1 == PS1, 2 == PS2 */

EditLine *el; /* cookie for editline package */

static void pushfile(void);
static int preadfd(void);
static void popstring(void);


+ 1
- 1
cddl/contrib/opensolaris/cmd/zfs/zfs_util.h View File

@@ -33,7 +33,7 @@ extern "C" {

void * safe_malloc(size_t size);
void nomem(void);
libzfs_handle_t *g_zfs;
extern libzfs_handle_t *g_zfs;

#ifdef __cplusplus
}


+ 2
- 0
cddl/contrib/opensolaris/cmd/zpool/zpool_main.c View File

@@ -64,6 +64,8 @@

#include "statcommon.h"

libzfs_handle_t *g_zfs;

static int zpool_do_create(int, char **);
static int zpool_do_destroy(int, char **);



+ 1
- 1
cddl/contrib/opensolaris/cmd/zpool/zpool_util.h View File

@@ -64,7 +64,7 @@ void pool_list_free(zpool_list_t *);
int pool_list_count(zpool_list_t *);
void pool_list_remove(zpool_list_t *, zpool_handle_t *);

libzfs_handle_t *g_zfs;
extern libzfs_handle_t *g_zfs;

#ifdef __cplusplus
}


+ 6
- 1
contrib/openbsm/bin/auditreduce/auditreduce.1 View File

@@ -25,7 +25,7 @@
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd January 24, 2004
.Dd February 20, 2020
.Dt AUDITREDUCE 1
.Os
.Sh NAME
@@ -47,6 +47,7 @@
.Op Fl r Ar ruid
.Op Fl u Ar auid
.Op Fl v
.Op Fl z Ar zone
.Op Ar
.Sh DESCRIPTION
The
@@ -129,6 +130,10 @@ Select records with the given real user ID or name.
Select records with the given audit ID.
.It Fl v
Invert sense of matching, to select records that do not match.
.It Fl z Ar zone
Select records from the given zone(s).
.Ar zone
is a glob for zones to match.
.El
.Sh EXAMPLES
To select all records associated with effective user ID root from the audit


+ 30
- 1
contrib/openbsm/bin/auditreduce/auditreduce.c View File

@@ -62,6 +62,7 @@
#include <bsm/libbsm.h>

#include <err.h>
#include <fnmatch.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
@@ -94,6 +95,7 @@ static int p_egid; /* Effective group id. */
static int p_rgid; /* Real group id. */
static int p_ruid; /* Real user id. */
static int p_subid; /* Subject id. */
static const char *p_zone; /* Zone. */

/*
* Maintain a dynamically sized array of events for -m
@@ -114,6 +116,8 @@ static char *p_sockobj = NULL;

static uint32_t opttochk = 0;

static int select_zone(const char *zone, uint32_t *optchkd);

static void
parse_regexp(char *re_string)
{
@@ -186,6 +190,7 @@ usage(const char *msg)
fprintf(stderr, "\t-r <uid|name> : real user\n");
fprintf(stderr, "\t-u <uid|name> : audit user\n");
fprintf(stderr, "\t-v : select non-matching records\n");
fprintf(stderr, "\t-z <zone> : zone name\n");
exit(EX_USAGE);
}

@@ -492,6 +497,21 @@ select_subj32(tokenstr_t tok, uint32_t *optchkd)
return (1);
}

/*
* Check if the given zone matches the selection criteria.
*/
static int
select_zone(const char *zone, uint32_t *optchkd)
{

SETOPT((*optchkd), OPT_z);
if (ISOPTSET(opttochk, OPT_z) && p_zone != NULL) {
if (fnmatch(p_zone, zone, FNM_PATHNAME) != 0)
return (0);
}
return (1);
}

/*
* Read each record from the audit trail. Check if it is selected after
* passing through each of the options
@@ -559,6 +579,10 @@ select_records(FILE *fp)
tok_hdr32_copy, &optchkd);
break;

case AUT_ZONENAME:
selected = select_zone(tok.tt.zonename.zonename, &optchkd);
break;

default:
break;
}
@@ -629,7 +653,7 @@ main(int argc, char **argv)

converr = NULL;

while ((ch = getopt(argc, argv, "Aa:b:c:d:e:f:g:j:m:o:r:u:v")) != -1) {
while ((ch = getopt(argc, argv, "Aa:b:c:d:e:f:g:j:m:o:r:u:vz:")) != -1) {
switch(ch) {
case 'A':
SETOPT(opttochk, OPT_A);
@@ -783,6 +807,11 @@ main(int argc, char **argv)
SETOPT(opttochk, OPT_v);
break;

case 'z':
p_zone = optarg;
SETOPT(opttochk, OPT_z);
break;

case '?':
default:
usage("Unknown option");


+ 1
- 0
contrib/openbsm/bin/auditreduce/auditreduce.h View File

@@ -57,6 +57,7 @@ struct re_entry {
#define OPT_u 0x00010000
#define OPT_A 0x00020000
#define OPT_v 0x00040000
#define OPT_z 0x00080000

#define FILEOBJ "file"
#define MSGQIDOBJ "msgqid"


+ 33
- 29
contrib/telnet/telnetd/ext.h View File

@@ -30,53 +30,57 @@
* $FreeBSD$
*/

#ifndef EXTERN
#define EXTERN extern
#endif

/*
* Telnet server variable declarations
*/
extern char options[256];
extern char do_dont_resp[256];
extern char will_wont_resp[256];
extern int linemode; /* linemode on/off */
EXTERN char options[256];
EXTERN char do_dont_resp[256];
EXTERN char will_wont_resp[256];
EXTERN int linemode; /* linemode on/off */
#ifdef LINEMODE
extern int uselinemode; /* what linemode to use (on/off) */
extern int editmode; /* edit modes in use */
extern int useeditmode; /* edit modes to use */
extern int alwayslinemode; /* command line option */
extern int lmodetype; /* Client support for linemode */
EXTERN int uselinemode; /* what linemode to use (on/off) */
EXTERN int editmode; /* edit modes in use */
EXTERN int useeditmode; /* edit modes to use */
EXTERN int alwayslinemode; /* command line option */
EXTERN int lmodetype; /* Client support for linemode */
#endif /* LINEMODE */
extern int flowmode; /* current flow control state */
extern int restartany; /* restart output on any character state */
EXTERN int flowmode; /* current flow control state */
EXTERN int restartany; /* restart output on any character state */
#ifdef DIAGNOSTICS
extern int diagnostic; /* telnet diagnostic capabilities */
EXTERN int diagnostic; /* telnet diagnostic capabilities */
#endif /* DIAGNOSTICS */
#ifdef BFTPDAEMON
extern int bftpd; /* behave as bftp daemon */
EXTERN int bftpd; /* behave as bftp daemon */
#endif /* BFTPDAEMON */
#ifdef AUTHENTICATION
extern int auth_level;
EXTERN int auth_level;
#endif

extern slcfun slctab[NSLC + 1]; /* slc mapping table */
EXTERN slcfun slctab[NSLC + 1]; /* slc mapping table */

char *terminaltype;
EXTERN char *terminaltype;

/*
* I/O data buffers, pointers, and counters.
*/
extern char ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp;
EXTERN char ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp;

extern char netibuf[BUFSIZ], *netip;
EXTERN char netibuf[BUFSIZ], *netip;

extern char netobuf[BUFSIZ], *nfrontp, *nbackp;
extern char *neturg; /* one past last bye of urgent data */
EXTERN char netobuf[BUFSIZ], *nfrontp, *nbackp;
EXTERN char *neturg; /* one past last bye of urgent data */

extern int pcc, ncc;
EXTERN int pcc, ncc;

extern int pty, net;
extern char line[32];
extern int SYNCHing; /* we are in TELNET SYNCH mode */
EXTERN int pty, net;
EXTERN char line[32];
EXTERN int SYNCHing; /* we are in TELNET SYNCH mode */

extern void
EXTERN void
_termstat(void),
add_slc(char, char, cc_t),
check_slc(void),
@@ -133,7 +137,7 @@ extern void
tty_binaryin(int),
tty_binaryout(int);

extern int
EXTERN int
end_slc(unsigned char **),
getnpty(void),
#ifndef convex
@@ -158,7 +162,7 @@ extern int
tty_istrapsig(void),
tty_linemode(void);

extern void
EXTERN void
tty_rspeed(int),
tty_setecho(int),
tty_setedit(int),
@@ -177,7 +181,7 @@ void startslave(char *, int, char *);
#ifdef ENCRYPTION
extern void (*encrypt_output)(unsigned char *, int);
extern int (*decrypt_input)(int);
extern char *nclearto;
EXTERN char *nclearto;
#endif /* ENCRYPTION */


@@ -186,7 +190,7 @@ extern char *nclearto;
* the relationship between various variables.
*/

extern struct {
EXTERN struct {
int
system, /* what the current time is */
echotoggle, /* last time user entered echo character */


+ 1
- 1
contrib/telnet/telnetd/global.c View File

@@ -44,5 +44,5 @@ __FBSDID("$FreeBSD$");
*/

#include "defs.h"
#define extern
#define EXTERN
#include "ext.h"

+ 0
- 2
contrib/telnet/telnetd/sys_term.c View File

@@ -376,8 +376,6 @@ spcset(int func, cc_t *valp, cc_t **valpp)
*
* Returns the file descriptor of the opened pty.
*/
char line[32];

int
getpty(int *ptynum __unused)
{


+ 0
- 1
contrib/telnet/telnetd/telnetd.c View File

@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");

#ifdef AUTHENTICATION
#include <libtelnet/auth.h>
int auth_level = 0;
#endif
#ifdef ENCRYPTION
#include <libtelnet/encrypt.h>


+ 5
- 28
share/man/man7/arch.7 View File

@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd March 23, 2020
.Dd March 28, 2020
.Dt ARCH 7
.Os
.Sh NAME
@@ -287,36 +287,13 @@ is 8 bytes on all supported architectures except i386.
uses
.Xr clang 1
as the default compiler on all supported CPU architectures,
as well as ELF Tool Chain binary utilities such as
LLVM's
.Xr ld.lld 1
as the default linker, and
ELF Tool Chain binary utilities such as
.Xr objcopy 1
and
.Xr readelf 1 .
Most supported CPU architectures also use LLVM's
.Xr ld.lld 1
as the linker.
This table shows the default tool chain for each architecture.
.Bl -column -offset indent "Architecture" "Compiler" "Linker"
.It Sy Architecture Ta Sy Compiler Ta Sy Linker
.It aarch64 Ta Clang Ta lld
.It amd64 Ta Clang Ta lld
.It armv6 Ta Clang Ta lld
.It armv7 Ta Clang Ta lld
.It i386 Ta Clang Ta lld
.It mips Ta Clang Ta lld
.It mipsel Ta Clang Ta lld
.It mipselhf Ta Clang Ta lld
.It mipshf Ta Clang Ta lld
.It mipsn32 Ta Clang Ta lld
.It mips64 Ta Clang Ta lld
.It mips64el Ta Clang Ta lld
.It mips64elhf Ta Clang Ta lld
.It mips64hf Ta Clang Ta lld
.It powerpc Ta Clang Ta lld
.It powerpcspe Ta Clang Ta lld
.It powerpc64 Ta Clang Ta lld
.It riscv64 Ta Clang Ta lld
.It riscv64sf Ta Clang Ta lld
.El
.Ss MACHINE_ARCH vs MACHINE_CPUARCH vs MACHINE
.Dv MACHINE_CPUARCH
should be preferred in Makefiles when the generic


+ 1
- 11
sys/dev/sound/pci/hda/hdac.c View File

@@ -1413,21 +1413,11 @@ hdac_poll_reinit(struct hdac_softc *sc)
pollticks >>= 1;
if (pollticks > hz)
pollticks = hz;
if (pollticks < 1) {
HDA_BOOTVERBOSE(
device_printf(sc->dev,
"poll interval < 1 tick !\n");
);
if (pollticks < 1)
pollticks = 1;
}
if (min > pollticks)
min = pollticks;
}
HDA_BOOTVERBOSE(
device_printf(sc->dev,
"poll interval %d -> %d ticks\n",
sc->poll_ival, min);
);
sc->poll_ival = min;
if (min == 1000000)
callout_stop(&sc->poll_callout);


+ 2
- 2
sys/netinet/sctp_cc_functions.c View File

@@ -1914,7 +1914,7 @@ measure_rtt(struct sctp_nets *net)
if (net->fast_retran_ip == 0 && net->ssthresh < 0xFFFF && htcp_ccount(&net->cc_mod.htcp_ca) > 3) {
if (net->cc_mod.htcp_ca.maxRTT < net->cc_mod.htcp_ca.minRTT)
net->cc_mod.htcp_ca.maxRTT = net->cc_mod.htcp_ca.minRTT;
if (net->cc_mod.htcp_ca.maxRTT < srtt && srtt <= net->cc_mod.htcp_ca.maxRTT + MSEC_TO_TICKS(20))
if (net->cc_mod.htcp_ca.maxRTT < srtt && srtt <= net->cc_mod.htcp_ca.maxRTT + sctp_msecs_to_ticks(20))
net->cc_mod.htcp_ca.maxRTT = srtt;
}
}
@@ -1975,7 +1975,7 @@ htcp_beta_update(struct htcp *ca, uint32_t minRTT, uint32_t maxRTT)
}
}

if (ca->modeswitch && minRTT > (uint32_t)MSEC_TO_TICKS(10) && maxRTT) {
if (ca->modeswitch && minRTT > sctp_msecs_to_ticks(10) && maxRTT) {
ca->beta = (minRTT << 7) / maxRTT;
if (ca->beta < BETA_MIN)
ca->beta = BETA_MIN;


+ 0
- 10
sys/netinet/sctp_constants.h View File

@@ -577,16 +577,6 @@ __FBSDID("$FreeBSD$");
#define SCTP_ASOC_MAX_CHUNKS_ON_QUEUE 512


/* The conversion from time to ticks and vice versa is done by rounding
* upwards. This way we can test in the code the time to be positive and
* know that this corresponds to a positive number of ticks.
*/
#define MSEC_TO_TICKS(x) ((hz == 1000) ? x : ((((x) * hz) + 999) / 1000))
#define TICKS_TO_MSEC(x) ((hz == 1000) ? x : ((((x) * 1000) + (hz - 1)) / hz))

#define SEC_TO_TICKS(x) ((x) * hz)
#define TICKS_TO_SEC(x) (((x) + (hz - 1)) / hz)

/*
* Basically the minimum amount of time before I do a early FR. Making this
* value to low will cause duplicate retransmissions.


+ 1
- 1
sys/netinet/sctp_input.c View File

@@ -2600,7 +2600,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
*/
(void)SCTP_GETTIME_TIMEVAL(&now);
/* Expire time is in Ticks, so we convert to seconds */
time_expires.tv_sec = cookie->time_entered.tv_sec + TICKS_TO_SEC(cookie->cookie_life);
time_expires.tv_sec = cookie->time_entered.tv_sec + sctp_ticks_to_secs(cookie->cookie_life);
time_expires.tv_usec = cookie->time_entered.tv_usec;
if (timevalcmp(&now, &time_expires, >)) {
/* cookie is stale! */


+ 8
- 8
sys/netinet/sctp_pcb.c View File

@@ -2556,13 +2556,13 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id)
m = &inp->sctp_ep;

/* setup the base timeout information */
m->sctp_timeoutticks[SCTP_TIMER_SEND] = SEC_TO_TICKS(SCTP_SEND_SEC); /* needed ? */
m->sctp_timeoutticks[SCTP_TIMER_INIT] = SEC_TO_TICKS(SCTP_INIT_SEC); /* needed ? */
m->sctp_timeoutticks[SCTP_TIMER_RECV] = MSEC_TO_TICKS(SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default));
m->sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = MSEC_TO_TICKS(SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default));
m->sctp_timeoutticks[SCTP_TIMER_PMTU] = SEC_TO_TICKS(SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default));
m->sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN] = SEC_TO_TICKS(SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default));
m->sctp_timeoutticks[SCTP_TIMER_SIGNATURE] = SEC_TO_TICKS(SCTP_BASE_SYSCTL(sctp_secret_lifetime_default));
m->sctp_timeoutticks[SCTP_TIMER_SEND] = sctp_secs_to_ticks(SCTP_SEND_SEC); /* needed ? */
m->sctp_timeoutticks[SCTP_TIMER_INIT] = sctp_secs_to_ticks(SCTP_INIT_SEC); /* needed ? */
m->sctp_timeoutticks[SCTP_TIMER_RECV] = sctp_msecs_to_ticks(SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default));
m->sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = sctp_msecs_to_ticks(SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default));
m->sctp_timeoutticks[SCTP_TIMER_PMTU] = sctp_secs_to_ticks(SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default));
m->sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN] = sctp_secs_to_ticks(SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default));
m->sctp_timeoutticks[SCTP_TIMER_SIGNATURE] = sctp_secs_to_ticks(SCTP_BASE_SYSCTL(sctp_secret_lifetime_default));
/* all max/min max are in ms */
m->sctp_maxrto = SCTP_BASE_SYSCTL(sctp_rto_max_default);
m->sctp_minrto = SCTP_BASE_SYSCTL(sctp_rto_min_default);
@@ -2610,7 +2610,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id)
sctp_timer_start(SCTP_TIMER_TYPE_NEWCOOKIE, inp, NULL, NULL);

/* How long is a cookie good for ? */
m->def_cookie_life = MSEC_TO_TICKS(SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default));
m->def_cookie_life = sctp_msecs_to_ticks(SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default));
/*
* Initialize authentication parameters
*/


+ 1
- 1
sys/netinet/sctp_timer.c View File

@@ -1539,7 +1539,7 @@ sctp_autoclose_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
tim_touse = &asoc->time_last_sent;
}
/* Now has long enough transpired to autoclose? */
ticks_gone_by = SEC_TO_TICKS((uint32_t)(tn.tv_sec - tim_touse->tv_sec));
ticks_gone_by = sctp_secs_to_ticks((uint32_t)(tn.tv_sec - tim_touse->tv_sec));
if (ticks_gone_by >= asoc->sctp_autoclose_ticks) {
/*
* autoclose time has hit, call the output routine,


+ 17
- 15
sys/netinet/sctp_usrreq.c View File

@@ -1600,7 +1600,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
break;
case SCTP_AUTOCLOSE:
if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE))
val = TICKS_TO_SEC(inp->sctp_ep.auto_close_time);
val = sctp_ticks_to_secs(inp->sctp_ep.auto_close_time);
else
val = 0;
break;
@@ -2012,7 +2012,7 @@ flags_out:
((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
(sack->sack_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
sack->sack_delay = TICKS_TO_MSEC(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV]);
sack->sack_delay = sctp_ticks_to_msecs(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV]);
sack->sack_freq = inp->sctp_ep.sctp_sack_freq;
SCTP_INP_RUNLOCK(inp);
} else {
@@ -2493,7 +2493,7 @@ flags_out:
/* Use endpoint defaults */
SCTP_INP_RLOCK(inp);
paddrp->spp_pathmaxrxt = inp->sctp_ep.def_net_failure;
paddrp->spp_hbinterval = TICKS_TO_MSEC(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT]);
paddrp->spp_hbinterval = sctp_ticks_to_msecs(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT]);
paddrp->spp_assoc_id = SCTP_FUTURE_ASSOC;
/* get inp's default */
if (inp->sctp_ep.default_dscp & 0x01) {
@@ -2765,7 +2765,7 @@ flags_out:
SCTP_FIND_STCB(inp, stcb, sasoc->sasoc_assoc_id);

if (stcb) {
sasoc->sasoc_cookie_life = TICKS_TO_MSEC(stcb->asoc.cookie_life);
sasoc->sasoc_cookie_life = sctp_ticks_to_msecs(stcb->asoc.cookie_life);
sasoc->sasoc_asocmaxrxt = stcb->asoc.max_send_times;
sasoc->sasoc_number_peer_destinations = stcb->asoc.numnets;
sasoc->sasoc_peer_rwnd = stcb->asoc.peers_rwnd;
@@ -2777,7 +2777,7 @@ flags_out:
((inp->sctp_flags & SCTP_PCB_FLAGS_UDPTYPE) &&
(sasoc->sasoc_assoc_id == SCTP_FUTURE_ASSOC))) {
SCTP_INP_RLOCK(inp);
sasoc->sasoc_cookie_life = TICKS_TO_MSEC(inp->sctp_ep.def_cookie_life);
sasoc->sasoc_cookie_life = sctp_ticks_to_msecs(inp->sctp_ep.def_cookie_life);
sasoc->sasoc_asocmaxrxt = inp->sctp_ep.max_send_times;
sasoc->sasoc_number_peer_destinations = 0;
sasoc->sasoc_peer_rwnd = 0;
@@ -3855,7 +3855,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
* The value is in ticks. Note this does not effect
* old associations, only new ones.
*/
inp->sctp_ep.auto_close_time = SEC_TO_TICKS(*mopt);
inp->sctp_ep.auto_close_time = sctp_secs_to_ticks(*mopt);
break;
}
SCTP_INP_WLOCK(inp);
@@ -4252,10 +4252,12 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_CHECK_AND_CAST(sack, optval, struct sctp_sack_info, optsize);
SCTP_FIND_STCB(inp, stcb, sack->sack_assoc_id);
if (sack->sack_delay) {
if (sack->sack_delay > SCTP_MAX_SACK_DELAY)
sack->sack_delay = SCTP_MAX_SACK_DELAY;
if (MSEC_TO_TICKS(sack->sack_delay) < 1) {
sack->sack_delay = TICKS_TO_MSEC(1);
if (sack->sack_delay > SCTP_MAX_SACK_DELAY) {
error = EINVAL;
if (stcb != NULL) {
SCTP_TCB_UNLOCK(stcb);
}
break;
}
}
if (stcb) {
@@ -4274,7 +4276,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
(sack->sack_assoc_id == SCTP_ALL_ASSOC)))) {
SCTP_INP_WLOCK(inp);
if (sack->sack_delay) {
inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV] = MSEC_TO_TICKS(sack->sack_delay);
inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV] = sctp_msecs_to_ticks(sack->sack_delay);
}
if (sack->sack_freq) {
inp->sctp_ep.sctp_sack_freq = sack->sack_freq;
@@ -5637,14 +5639,14 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
else if (paddrp->spp_hbinterval != 0) {
if (paddrp->spp_hbinterval > SCTP_MAX_HB_INTERVAL)
paddrp->spp_hbinterval = SCTP_MAX_HB_INTERVAL;
inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = MSEC_TO_TICKS(paddrp->spp_hbinterval);
inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = sctp_msecs_to_ticks(paddrp->spp_hbinterval);
}

if (paddrp->spp_flags & SPP_HB_ENABLE) {
if (paddrp->spp_flags & SPP_HB_TIME_IS_ZERO) {
inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = 0;
} else if (paddrp->spp_hbinterval) {
inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = MSEC_TO_TICKS(paddrp->spp_hbinterval);
inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT] = sctp_msecs_to_ticks(paddrp->spp_hbinterval);
}
sctp_feature_off(inp, SCTP_PCB_FLAGS_DONOT_HEARTBEAT);
} else if (paddrp->spp_flags & SPP_HB_DISABLE) {
@@ -5759,7 +5761,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
if (sasoc->sasoc_asocmaxrxt)
stcb->asoc.max_send_times = sasoc->sasoc_asocmaxrxt;
if (sasoc->sasoc_cookie_life) {
stcb->asoc.cookie_life = MSEC_TO_TICKS(sasoc->sasoc_cookie_life);
stcb->asoc.cookie_life = sctp_msecs_to_ticks(sasoc->sasoc_cookie_life);
}
SCTP_TCB_UNLOCK(stcb);
} else {
@@ -5771,7 +5773,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
if (sasoc->sasoc_asocmaxrxt)
inp->sctp_ep.max_send_times = sasoc->sasoc_asocmaxrxt;
if (sasoc->sasoc_cookie_life) {
inp->sctp_ep.def_cookie_life = MSEC_TO_TICKS(sasoc->sasoc_cookie_life);
inp->sctp_ep.def_cookie_life = sctp_msecs_to_ticks(sasoc->sasoc_cookie_life);
}
SCTP_INP_WUNLOCK(inp);
} else {


+ 100
- 22
sys/netinet/sctputil.c View File

@@ -772,6 +772,80 @@ sctp_audit_log(uint8_t ev, uint8_t fd)

#endif

/*
* The conversion from time to ticks and vice versa is done by rounding
* upwards. This way we can test in the code the time to be positive and
* know that this corresponds to a positive number of ticks.
*/

uint32_t
sctp_msecs_to_ticks(uint32_t msecs)
{
uint64_t temp;
uint32_t ticks;

if (hz == 1000) {
ticks = msecs;
} else {
temp = (((uint64_t)msecs * hz) + 999) / 1000;
if (temp > UINT32_MAX) {
ticks = UINT32_MAX;
} else {
ticks = (uint32_t)temp;
}
}
return (ticks);
}

uint32_t
sctp_ticks_to_msecs(uint32_t ticks)
{
uint64_t temp;
uint32_t msecs;

if (hz == 1000) {
msecs = ticks;
} else {
temp = (((uint64_t)ticks * 1000) + (hz - 1)) / hz;
if (temp > UINT32_MAX) {
msecs = UINT32_MAX;
} else {
msecs = (uint32_t)temp;
}
}
return (msecs);
}

uint32_t
sctp_secs_to_ticks(uint32_t secs)
{
uint64_t temp;
uint32_t ticks;

temp = (uint64_t)secs * hz;
if (temp > UINT32_MAX) {
ticks = UINT32_MAX;
} else {
ticks = (uint32_t)temp;
}
return (ticks);
}

uint32_t
sctp_ticks_to_secs(uint32_t ticks)
{
uint64_t temp;
uint32_t secs;

temp = ((uint64_t)ticks + (hz - 1)) / hz;
if (temp > UINT32_MAX) {
secs = UINT32_MAX;
} else {
secs = (uint32_t)temp;
}
return (secs);
}

/*
* sctp_stop_timers_for_shutdown() should be called
* when entering the SHUTDOWN_SENT or SHUTDOWN_ACK_SENT
@@ -1065,7 +1139,7 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
SCTP_SET_STATE(stcb, SCTP_STATE_INUSE);
asoc->max_burst = inp->sctp_ep.max_burst;
asoc->fr_max_burst = inp->sctp_ep.fr_max_burst;
asoc->heart_beat_delay = TICKS_TO_MSEC(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT]);
asoc->heart_beat_delay = sctp_ticks_to_msecs(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_HEARTBEAT]);
asoc->cookie_life = inp->sctp_ep.def_cookie_life;
asoc->sctp_cmt_on_off = inp->sctp_cmt_on_off;
asoc->ecn_supported = inp->ecn_supported;
@@ -1151,7 +1225,7 @@ sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
asoc->context = inp->sctp_context;
asoc->local_strreset_support = inp->local_strreset_support;
asoc->def_send = inp->def_send;
asoc->delayed_ack = TICKS_TO_MSEC(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV]);
asoc->delayed_ack = sctp_ticks_to_msecs(inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_RECV]);
asoc->sack_freq = inp->sctp_ep.sctp_sack_freq;
asoc->pr_sctp_cnt = 0;
asoc->total_output_queue_size = 0;
@@ -2115,9 +2189,9 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
tmr = &net->rxt_timer;
if (net->RTO == 0) {
to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto);
} else {
to_ticks = MSEC_TO_TICKS(net->RTO);
to_ticks = sctp_msecs_to_ticks(net->RTO);
}
break;
case SCTP_TIMER_TYPE_INIT:
@@ -2135,9 +2209,9 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
tmr = &net->rxt_timer;
if (net->RTO == 0) {
to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto);
} else {
to_ticks = MSEC_TO_TICKS(net->RTO);
to_ticks = sctp_msecs_to_ticks(net->RTO);
}
break;
case SCTP_TIMER_TYPE_RECV:
@@ -2154,7 +2228,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
#endif
}
tmr = &stcb->asoc.dack_timer;
to_ticks = MSEC_TO_TICKS(stcb->asoc.delayed_ack);
to_ticks = sctp_msecs_to_ticks(stcb->asoc.delayed_ack);
break;
case SCTP_TIMER_TYPE_SHUTDOWN:
/* Here we use the RTO of the destination. */
@@ -2168,9 +2242,9 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
tmr = &net->rxt_timer;
if (net->RTO == 0) {
to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto);
} else {
to_ticks = MSEC_TO_TICKS(net->RTO);
to_ticks = sctp_msecs_to_ticks(net->RTO);
}
break;
case SCTP_TIMER_TYPE_HEARTBEAT:
@@ -2215,7 +2289,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
* Now we must convert the to_ticks that are now in ms to
* ticks.
*/
to_ticks = MSEC_TO_TICKS(to_ticks);
to_ticks = sctp_msecs_to_ticks(to_ticks);
break;
case SCTP_TIMER_TYPE_COOKIE:
/*
@@ -2233,9 +2307,9 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
tmr = &net->rxt_timer;
if (net->RTO == 0) {
to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto);
} else {
to_ticks = MSEC_TO_TICKS(net->RTO);
to_ticks = sctp_msecs_to_ticks(net->RTO);
}
break;
case SCTP_TIMER_TYPE_NEWCOOKIE:
@@ -2288,9 +2362,9 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
tmr = &net->rxt_timer;
if (net->RTO == 0) {
to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto);
} else {
to_ticks = MSEC_TO_TICKS(net->RTO);
to_ticks = sctp_msecs_to_ticks(net->RTO);
}
break;
case SCTP_TIMER_TYPE_ASCONF:
@@ -2308,9 +2382,9 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
tmr = &stcb->asoc.asconf_timer;
if (net->RTO == 0) {
to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto);
} else {
to_ticks = MSEC_TO_TICKS(net->RTO);
to_ticks = sctp_msecs_to_ticks(net->RTO);
}
break;
case SCTP_TIMER_TYPE_SHUTDOWNGUARD:
@@ -2328,7 +2402,11 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
tmr = &stcb->asoc.shut_guard_timer;
if (inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN] == 0) {
to_ticks = 5 * MSEC_TO_TICKS(stcb->asoc.maxrto);
if (stcb->asoc.maxrto < UINT32_MAX / 5) {
to_ticks = sctp_msecs_to_ticks(5 * stcb->asoc.maxrto);
} else {
to_ticks = sctp_msecs_to_ticks(UINT32_MAX);
}
} else {
to_ticks = inp->sctp_ep.sctp_timeoutticks[SCTP_TIMER_MAXSHUTDOWN];
}
@@ -2360,9 +2438,9 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}
tmr = &stcb->asoc.strreset_timer;
if (net->RTO == 0) {
to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto);
} else {
to_ticks = MSEC_TO_TICKS(net->RTO);
to_ticks = sctp_msecs_to_ticks(net->RTO);
}
break;
case SCTP_TIMER_TYPE_INPKILL:
@@ -2380,7 +2458,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
#endif
}
tmr = &inp->sctp_ep.signature_change;
to_ticks = MSEC_TO_TICKS(SCTP_INP_KILL_TIMEOUT);
to_ticks = sctp_msecs_to_ticks(SCTP_INP_KILL_TIMEOUT);
break;
case SCTP_TIMER_TYPE_ASOCKILL:
if ((inp == NULL) || (stcb == NULL) || (net != NULL)) {
@@ -2392,7 +2470,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
#endif
}
tmr = &stcb->asoc.strreset_timer;
to_ticks = MSEC_TO_TICKS(SCTP_ASOC_KILL_TIMEOUT);
to_ticks = sctp_msecs_to_ticks(SCTP_ASOC_KILL_TIMEOUT);
break;
case SCTP_TIMER_TYPE_ADDR_WQ:
if ((inp != NULL) || (stcb != NULL) || (net != NULL)) {
@@ -2417,7 +2495,7 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb,
#endif
}
tmr = &stcb->asoc.delete_prim_timer;
to_ticks = MSEC_TO_TICKS(stcb->asoc.initial_rto);
to_ticks = sctp_msecs_to_ticks(stcb->asoc.initial_rto);
break;
default:
#ifdef INVARIANTS


+ 5
- 0
sys/netinet/sctputil.h View File

@@ -392,5 +392,10 @@ void sctp_hc_set_mtu(union sctp_sockstore *, uint16_t, uint32_t);
uint32_t sctp_hc_get_mtu(union sctp_sockstore *, uint16_t);
void sctp_set_state(struct sctp_tcb *, int);
void sctp_add_substate(struct sctp_tcb *, int);
uint32_t sctp_ticks_to_msecs(uint32_t);
uint32_t sctp_msecs_to_ticks(uint32_t);
uint32_t sctp_ticks_to_secs(uint32_t);
uint32_t sctp_secs_to_ticks(uint32_t);

#endif /* _KERNEL */
#endif

Loading…
Cancel
Save