Print this page
9042 multiples of tty streams modules cause weirdness
Reviewed by: Randy Fishel <randyf@sibernet.com>
Reviewed by: Carlos Neira <cneirabustos@gmail.com>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/streamio.c
          +++ new/usr/src/uts/common/os/streamio.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  22   22  /*        All Rights Reserved   */
  23   23  
  24   24  
  25   25  /*
  26   26   * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  27   27   * Copyright 2017 Joyent, Inc.
       28 + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
  28   29   */
  29   30  
  30   31  #include <sys/types.h>
  31   32  #include <sys/sysmacros.h>
  32   33  #include <sys/param.h>
  33   34  #include <sys/errno.h>
  34   35  #include <sys/signal.h>
  35   36  #include <sys/stat.h>
  36   37  #include <sys/proc.h>
  37   38  #include <sys/cred.h>
↓ open down ↓ 3738 lines elided ↑ open up ↑
3776 3777                  if (error)
3777 3778                          return ((error == ENAMETOOLONG) ? EINVAL : EFAULT);
3778 3779  
3779 3780                  if ((fp = fmodsw_find(mname, FMODSW_HOLD | FMODSW_LOAD)) ==
3780 3781                      NULL)
3781 3782                          return (EINVAL);
3782 3783  
3783 3784                  TRACE_2(TR_FAC_STREAMS_FR, TR_I_PUSH,
3784 3785                      "I_PUSH:fp %p stp %p", fp, stp);
3785 3786  
     3787 +                /*
     3788 +                 * If the module is flagged as single-instance, then check
     3789 +                 * to see if the module is already pushed. If it is, return
     3790 +                 * as if the push was successful.
     3791 +                 */
     3792 +                if (fp->f_qflag & _QSINGLE_INSTANCE) {
     3793 +                        queue_t *q;
     3794 +
     3795 +                        claimstr(stp->sd_wrq);
     3796 +                        for (q = stp->sd_wrq->q_next; q; q = q->q_next) {
     3797 +                                if (q->q_flag & QREADR) {
     3798 +                                        q = NULL;
     3799 +                                        break;
     3800 +                                }
     3801 +                                if (strcmp(mname, Q2NAME(q)) == 0)
     3802 +                                        break;
     3803 +                        }
     3804 +                        releasestr(stp->sd_wrq);
     3805 +                        if (q != NULL) {
     3806 +                                fmodsw_rele(fp);
     3807 +                                return (0);
     3808 +                        }
     3809 +                }
     3810 +
3786 3811                  if (error = strstartplumb(stp, flag, cmd)) {
3787 3812                          fmodsw_rele(fp);
3788 3813                          return (error);
3789 3814                  }
3790 3815  
3791 3816                  /*
3792 3817                   * See if any more modules can be pushed on this stream.
3793 3818                   * Note that this check must be done after strstartplumb()
3794 3819                   * since otherwise multiple threads issuing I_PUSHes on
3795 3820                   * the same stream will be able to exceed nstrpush.
↓ open down ↓ 4831 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX