Uploaded image for project: 'radsecproxy'
  1. radsecproxy
  2. RADSECPROXY-65

Possible bugs where threads are sharing memory without proper locking

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • radsecproxy-1.7
    • None
    • None
    • None

    Description

      Related to RADSECPROXY-64, the following seven instances of similar code should be analyzed.

      The following legend might be useful when deciphering this.
      (Except it isn't when rendered with proportional fonts.)

      processes:
        client radsecproxy server
      threads:
                        client writer [1] ------->|
                          clientconnreader [2] <----|
                        client reader [3] <--|

          |---------> client listener[4]
          |---------> server reader
          |<-------- server writer

      [1] one per server config (and transport)
      [2] for tls and tcp (tlsclientrd, tcpclientrd)
      [3] for udp and dtls (initextraudp, initextradtls)
      [4] one per client config (and transport)

      1 - main thread sharing server config structs with clientwr threads

      int radsecproxy_main(int argc, char **argv) {
      ...
      if (pthread_create(&srvconf->servers->clientth, &pthread_attr, clientwr,
      (void *)(srvconf->servers)))

      2 - server reader threads (through radsrv()) sharing server config
        structs with clientwr threads

      struct list *createsubrealmservers(struct realm *realm, struct list *srvconfs) {
      ...
      if (pthread_create(&clientth, &pthread_attr, clientwr, (void *)(srvconf->servers))) {


      3 - client writer threads sharing server pointer with new
        clientconnreader threads (i.e. tlsclientrd() and tcpclientrd())

      void *clientwr(void *arg) {
          struct server *server = (struct server *)arg;
          ...
      if (pthread_create(&clientrdth, &pthread_attr, conf->pdef->clientconnreader, (void *)server)) {


      4 - tcp server reader threads sharing client struct with tcp server writer

      void tcpserverrd(struct client *client) {
      ...
          if (pthread_create(&tcpserverwrth, &pthread_attr, tcpserverwr, (void *)client)) {


      5 - dtls listener sharing 'params' with new server writer thread

      void *udpdtlsserverrd(void *arg) {
      ...
      params = malloc(sizeof(struct dtlsservernewparams));
              ...
      if (!pthread_create(&dtlsserverth, &pthread_attr, dtlsservernew, (void *)params)) {
              ...
      free(params->sesscache);
      ...
      void *dtlsservernew(void *arg) {
          struct dtlsservernewparams *params = (struct dtlsservernewparams *)arg;



      6, 7 - [d]tls server reader sharing client struct with new server writer
        thread (example form dtls.c)

      void dtlsserverrd(struct client *client) {
      ...
          if (pthread_create(&dtlsserverwrth, &pthread_attr, dtlsserverwr, (void *)client)) {
      ...
      void *dtlsserverwr(void *arg) {
      ...
          struct client *client = (struct client *)arg;
      ...
      cnt = SSL_write(client->ssl, reply->replybuf, RADLEN(reply->replybuf));

      Attachments

        Activity

          People

            linus Linus Nordberg
            linus Linus Nordberg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: