DragonFly On-Line Manual Pages

Search: Section:  


TLS(2)                   DragonFly System Calls Manual                  TLS(2)

NAME

set_tls_area, get_tls_area -- kernel TLS (thread local storage) support

LIBRARY

Standard C Library (libc, -lc)

SYNOPSIS

#include <sys/tls.h> int set_tls_area(int which, struct tls_info *info, size_t infosize); int get_tls_area(int which, struct tls_info *info, size_t infosize);

DESCRIPTION

The set_tls_area() system call creates an entry for the TLS facility which representing thread local storage as specified by the info structure. A descriptor representing the facility is returned, or -1 if an error occurred. The facility may be cleared by specifying a NULL pointer and an infosize of 0. The get_tls_area() system call retrieves the requested TLS facility. A descriptor representing the facility is returned, or -1 if an error occurred. If you simply want the descriptor you may specify a NULL pointer and an infosize of 0. The returned descriptor and the TLS mechanism is machine-dependent. On IA32 three global segment descriptors are supported (0, 1, and 2) and the %gs load value is returned. The tls_info structure passed to set_tls_area() should first be zerod (to remain compatible with future extensions) and then initialized. struct tls_info { void *base; /* base address of TLS area */ int size; /* size of TLS area in bytes */ }; The actual implementation of the area is machine-dependent. If the kernel is unable to accommodate the supplied size it may create a larger area. If the kernel is unable to accommodate the supplied base address an error will be returned.

RETURN VALUES

A return value of 0 is returned on success, -1 on error.

EXAMPLES

/* * Pseudo example showing how the TLS system calls work on IA32. */ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <errno.h> #include <sys/tls.h> int X; static int getdata(int offset); int main(int ac, char **av) { int i; int gs; struct tls_info info; info.base = &X; info.size = sizeof(X); if ((gs = set_tls_area(0, &info, sizeof(info))) < 0) { perror("setarea"); exit(1); } printf("gs = %04x\n", gs); __asm __volatile("mov %0,%%gs" : : "g" (gs) ); if (get_tls_area(0, &info, sizeof(info)) < 0) { perror("getarea"); exit(1); } printf("%p/%d\n", info.base, info.size); X = 1; printf("should be 1: %d\n", getdata(0)); X = 2; printf("should be 2: %d\n", getdata(0)); printf("this should fault:\n"); fflush(stdout); getdata(4); return(0); } static int getdata(int offset) { int rv; __asm __volatile("movl %%gs:(%0),%%eax; movl %%eax,%1" : "+r" (offset) : "m" (rv) : "ax"); return (rv); }

ERRORS

[ERANGE] The specified facility index, which, is not supported. [EINVAL] An invalid parameter has been specified. [ENOENT] (get_tls_area) The specified facility has not been initialized with sys_set_tls_area().

SEE ALSO

umtx(2)

HISTORY

The set_tls_area(), and get_tls_area() function calls first appeared in DragonFly 1.1. DragonFly 5.5 February 21, 2005 DragonFly 5.5 TLS_CONFIG_SET_PROTOCOLS(3) DragonFly Library Functions Manual

NAME

tls_config_set_protocols, tls_config_parse_protocols, tls_config_set_alpn, tls_config_set_ciphers, tls_config_set_dheparams, tls_config_set_ecdhecurves, tls_config_prefer_ciphers_client, tls_config_prefer_ciphers_server - TLS protocol and cipher selection

SYNOPSIS

#include <tls.h> int tls_config_set_protocols(struct tls_config *config, uint32_t protocols); int tls_config_parse_protocols(uint32_t *protocols, const char *protostr); int tls_config_set_alpn(struct tls_config *config, const char *alpn); int tls_config_set_ciphers(struct tls_config *config, const char *ciphers); int tls_config_set_dheparams(struct tls_config *config, const char *params); int tls_config_set_ecdhecurves(struct tls_config *config, const char *curves); void tls_config_prefer_ciphers_client(struct tls_config *config); void tls_config_prefer_ciphers_server(struct tls_config *config);

DESCRIPTION

These functions modify a configuration by setting parameters. The configuration options apply to both clients and servers, unless noted otherwise. tls_config_set_protocols() specifies which versions of the TLS protocol may be used. Possible values are the bitwise OR of: TLS_PROTOCOL_TLSv1_0 TLS_PROTOCOL_TLSv1_1 TLS_PROTOCOL_TLSv1_2 TLS_PROTOCOL_TLSv1_3 Additionally, the values TLS_PROTOCOL_TLSv1 (TLSv1.0, TLSv1.1, TLSv1.2, TLSv1.3), TLS_PROTOCOLS_ALL (all supported protocols) and TLS_PROTOCOLS_DEFAULT (TLSv1.2 and TLSv1.3) may be used. The tls_config_parse_protocols() utility function parses a protocol string and returns the corresponding value via the protocols argument. This value can then be passed to the tls_config_set_protocols() function. The protocol string is a comma or colon separated list of keywords. Valid keywords are: tlsv1.0 tlsv1.1 tlsv1.2 tlsv1.3 all (all supported protocols) default (an alias for secure) legacy (an alias for all) secure (currently TLSv1.2 and TLSv1.3) If a value has a negative prefix (in the form of a leading exclamation mark) then it is removed from the list of available protocols, rather than being added to it. tls_config_set_alpn() sets the ALPN protocols that are supported. The alpn string is a comma separated list of protocols, in order of preference. tls_config_set_ciphers() sets the list of ciphers that may be used. Lists of ciphers are specified by name, and the permitted names are: secure (or alias default) compat legacy insecure (or alias all) Alternatively, libssl cipher strings can be specified. See the CIPHERS section of openssl(1) for further information. tls_config_set_dheparams() specifies the parameters that will be used during Diffie-Hellman Ephemeral (DHE) key exchange. Possible values are: none auto legacy In auto mode, the key size for the ephemeral key is automatically selected based on the size of the private key being used for signing. In legacy mode, 1024 bit ephemeral keys are used. The default value is none, which disables DHE key exchange. tls_config_set_ecdhecurves() specifies the names of the elliptic curves that may be used during Elliptic Curve Diffie-Hellman Ephemeral (ECDHE) key exchange. This is a comma separated list, given in order of preference. The special value of "default" will use the default curves (currently X25519, P-256 and P-384). This function replaces tls_config_set_ecdhecurve(), which is deprecated. tls_config_prefer_ciphers_client() prefers ciphers in the client's cipher list when selecting a cipher suite (server only). This is considered to be less secure than preferring the server's list. tls_config_prefer_ciphers_server() prefers ciphers in the server's cipher list when selecting a cipher suite (server only). This is considered to be more secure than preferring the client's list and is the default.

RETURN VALUES

These functions return 0 on success or -1 on error.

SEE ALSO

tls_config_ocsp_require_stapling(3), tls_config_set_session_id(3), tls_config_verify(3), tls_init(3), tls_load_file(3)

HISTORY

tls_config_set_ciphers() appeared in OpenBSD 5.6 and got its final name in OpenBSD 5.7. tls_config_set_protocols(), tls_config_parse_protocols(), tls_config_set_dheparams(), and tls_config_set_ecdhecurve() appeared in OpenBSD 5.7, tls_config_prefer_ciphers_client() and tls_config_prefer_ciphers_server() in OpenBSD 5.9, and tls_config_set_alpn() in OpenBSD 6.1.

AUTHORS

Joel Sing <jsing@openbsd.org> with contributions from Ted Unangst <tedu@openbsd.org> (tls_config_set_ciphers()) and Reyk Floeter <reyk@openbsd.org> (tls_config_set_ecdhecurve()) DragonFly 6.1-DEVELOPMENT January 2, 2021 DragonFly 6.1-DEVELOPMENT

Search: Section: