1. 13 10月, 2018 2 次提交
  2. 13 7月, 2018 1 次提交
    • T
      uart: fix race between uart_put_char() and uart_shutdown() · a5ba1d95
      Tycho Andersen 提交于
      We have reports of the following crash:
      
          PID: 7 TASK: ffff88085c6d61c0 CPU: 1 COMMAND: "kworker/u25:0"
          #0 [ffff88085c6db710] machine_kexec at ffffffff81046239
          #1 [ffff88085c6db760] crash_kexec at ffffffff810fc248
          #2 [ffff88085c6db830] oops_end at ffffffff81008ae7
          #3 [ffff88085c6db860] no_context at ffffffff81050b8f
          #4 [ffff88085c6db8b0] __bad_area_nosemaphore at ffffffff81050d75
          #5 [ffff88085c6db900] bad_area_nosemaphore at ffffffff81050e83
          #6 [ffff88085c6db910] __do_page_fault at ffffffff8105132e
          #7 [ffff88085c6db9b0] do_page_fault at ffffffff8105152c
          #8 [ffff88085c6db9c0] page_fault at ffffffff81a3f122
          [exception RIP: uart_put_char+149]
          RIP: ffffffff814b67b5 RSP: ffff88085c6dba78 RFLAGS: 00010006
          RAX: 0000000000000292 RBX: ffffffff827c5120 RCX: 0000000000000081
          RDX: 0000000000000000 RSI: 000000000000005f RDI: ffffffff827c5120
          RBP: ffff88085c6dba98 R8: 000000000000012c R9: ffffffff822ea320
          R10: ffff88085fe4db04 R11: 0000000000000001 R12: ffff881059f9c000
          R13: 0000000000000001 R14: 000000000000005f R15: 0000000000000fba
          ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
          #9 [ffff88085c6dbaa0] tty_put_char at ffffffff81497544
          #10 [ffff88085c6dbac0] do_output_char at ffffffff8149c91c
          #11 [ffff88085c6dbae0] __process_echoes at ffffffff8149cb8b
          #12 [ffff88085c6dbb30] commit_echoes at ffffffff8149cdc2
          #13 [ffff88085c6dbb60] n_tty_receive_buf_fast at ffffffff8149e49b
          #14 [ffff88085c6dbbc0] __receive_buf at ffffffff8149ef5a
          #15 [ffff88085c6dbc20] n_tty_receive_buf_common at ffffffff8149f016
          #16 [ffff88085c6dbca0] n_tty_receive_buf2 at ffffffff8149f194
          #17 [ffff88085c6dbcb0] flush_to_ldisc at ffffffff814a238a
          #18 [ffff88085c6dbd50] process_one_work at ffffffff81090be2
          #19 [ffff88085c6dbe20] worker_thread at ffffffff81091b4d
          #20 [ffff88085c6dbeb0] kthread at ffffffff81096384
          #21 [ffff88085c6dbf50] ret_from_fork at ffffffff81a3d69f​
      
      after slogging through some dissasembly:
      
      ffffffff814b6720 <uart_put_char>:
      ffffffff814b6720:	55                   	push   %rbp
      ffffffff814b6721:	48 89 e5             	mov    %rsp,%rbp
      ffffffff814b6724:	48 83 ec 20          	sub    $0x20,%rsp
      ffffffff814b6728:	48 89 1c 24          	mov    %rbx,(%rsp)
      ffffffff814b672c:	4c 89 64 24 08       	mov    %r12,0x8(%rsp)
      ffffffff814b6731:	4c 89 6c 24 10       	mov    %r13,0x10(%rsp)
      ffffffff814b6736:	4c 89 74 24 18       	mov    %r14,0x18(%rsp)
      ffffffff814b673b:	e8 b0 8e 58 00       	callq  ffffffff81a3f5f0 <mcount>
      ffffffff814b6740:	4c 8b a7 88 02 00 00 	mov    0x288(%rdi),%r12
      ffffffff814b6747:	45 31 ed             	xor    %r13d,%r13d
      ffffffff814b674a:	41 89 f6             	mov    %esi,%r14d
      ffffffff814b674d:	49 83 bc 24 70 01 00 	cmpq   $0x0,0x170(%r12)
      ffffffff814b6754:	00 00
      ffffffff814b6756:	49 8b 9c 24 80 01 00 	mov    0x180(%r12),%rbx
      ffffffff814b675d:	00
      ffffffff814b675e:	74 2f                	je     ffffffff814b678f <uart_put_char+0x6f>
      ffffffff814b6760:	48 89 df             	mov    %rbx,%rdi
      ffffffff814b6763:	e8 a8 67 58 00       	callq  ffffffff81a3cf10 <_raw_spin_lock_irqsave>
      ffffffff814b6768:	41 8b 8c 24 78 01 00 	mov    0x178(%r12),%ecx
      ffffffff814b676f:	00
      ffffffff814b6770:	89 ca                	mov    %ecx,%edx
      ffffffff814b6772:	f7 d2                	not    %edx
      ffffffff814b6774:	41 03 94 24 7c 01 00 	add    0x17c(%r12),%edx
      ffffffff814b677b:	00
      ffffffff814b677c:	81 e2 ff 0f 00 00    	and    $0xfff,%edx
      ffffffff814b6782:	75 23                	jne    ffffffff814b67a7 <uart_put_char+0x87>
      ffffffff814b6784:	48 89 c6             	mov    %rax,%rsi
      ffffffff814b6787:	48 89 df             	mov    %rbx,%rdi
      ffffffff814b678a:	e8 e1 64 58 00       	callq  ffffffff81a3cc70 <_raw_spin_unlock_irqrestore>
      ffffffff814b678f:	44 89 e8             	mov    %r13d,%eax
      ffffffff814b6792:	48 8b 1c 24          	mov    (%rsp),%rbx
      ffffffff814b6796:	4c 8b 64 24 08       	mov    0x8(%rsp),%r12
      ffffffff814b679b:	4c 8b 6c 24 10       	mov    0x10(%rsp),%r13
      ffffffff814b67a0:	4c 8b 74 24 18       	mov    0x18(%rsp),%r14
      ffffffff814b67a5:	c9                   	leaveq
      ffffffff814b67a6:	c3                   	retq
      ffffffff814b67a7:	49 8b 94 24 70 01 00 	mov    0x170(%r12),%rdx
      ffffffff814b67ae:	00
      ffffffff814b67af:	48 63 c9             	movslq %ecx,%rcx
      ffffffff814b67b2:	41 b5 01             	mov    $0x1,%r13b
      ffffffff814b67b5:	44 88 34 0a          	mov    %r14b,(%rdx,%rcx,1)
      ffffffff814b67b9:	41 8b 94 24 78 01 00 	mov    0x178(%r12),%edx
      ffffffff814b67c0:	00
      ffffffff814b67c1:	83 c2 01             	add    $0x1,%edx
      ffffffff814b67c4:	81 e2 ff 0f 00 00    	and    $0xfff,%edx
      ffffffff814b67ca:	41 89 94 24 78 01 00 	mov    %edx,0x178(%r12)
      ffffffff814b67d1:	00
      ffffffff814b67d2:	eb b0                	jmp    ffffffff814b6784 <uart_put_char+0x64>
      ffffffff814b67d4:	66 66 66 2e 0f 1f 84 	data32 data32 nopw %cs:0x0(%rax,%rax,1)
      ffffffff814b67db:	00 00 00 00 00
      
      for our build, this is crashing at:
      
          circ->buf[circ->head] = c;
      
      Looking in uart_port_startup(), it seems that circ->buf (state->xmit.buf)
      protected by the "per-port mutex", which based on uart_port_check() is
      state->port.mutex. Indeed, the lock acquired in uart_put_char() is
      uport->lock, i.e. not the same lock.
      
      Anyway, since the lock is not acquired, if uart_shutdown() is called, the
      last chunk of that function may release state->xmit.buf before its assigned
      to null, and cause the race above.
      
      To fix it, let's lock uport->lock when allocating/deallocating
      state->xmit.buf in addition to the per-port mutex.
      
      v2: switch to locking uport->lock on allocation/deallocation instead of
          locking the per-port mutex in uart_put_char. Note that since
          uport->lock is a spin lock, we have to switch the allocation to
          GFP_ATOMIC.
      v3: move the allocation outside the lock, so we can switch back to
          GFP_KERNEL
      Signed-off-by: NTycho Andersen <tycho@tycho.ws>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a5ba1d95
  3. 13 6月, 2018 1 次提交
    • K
      treewide: kzalloc() -> kcalloc() · 6396bb22
      Kees Cook 提交于
      The kzalloc() function has a 2-factor argument form, kcalloc(). This
      patch replaces cases of:
      
              kzalloc(a * b, gfp)
      
      with:
              kcalloc(a * b, gfp)
      
      as well as handling cases of:
      
              kzalloc(a * b * c, gfp)
      
      with:
      
              kzalloc(array3_size(a, b, c), gfp)
      
      as it's slightly less ugly than:
      
              kzalloc_array(array_size(a, b), c, gfp)
      
      This does, however, attempt to ignore constant size factors like:
      
              kzalloc(4 * 1024, gfp)
      
      though any constants defined via macros get caught up in the conversion.
      
      Any factors with a sizeof() of "unsigned char", "char", and "u8" were
      dropped, since they're redundant.
      
      The Coccinelle script used for this was:
      
      // Fix redundant parens around sizeof().
      @@
      type TYPE;
      expression THING, E;
      @@
      
      (
        kzalloc(
      -	(sizeof(TYPE)) * E
      +	sizeof(TYPE) * E
        , ...)
      |
        kzalloc(
      -	(sizeof(THING)) * E
      +	sizeof(THING) * E
        , ...)
      )
      
      // Drop single-byte sizes and redundant parens.
      @@
      expression COUNT;
      typedef u8;
      typedef __u8;
      @@
      
      (
        kzalloc(
      -	sizeof(u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(__u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(char) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(unsigned char) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(u8) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(__u8) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(char) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(unsigned char) * COUNT
      +	COUNT
        , ...)
      )
      
      // 2-factor product with sizeof(type/expression) and identifier or constant.
      @@
      type TYPE;
      expression THING;
      identifier COUNT_ID;
      constant COUNT_CONST;
      @@
      
      (
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (COUNT_ID)
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * COUNT_ID
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * COUNT_CONST
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (COUNT_ID)
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * COUNT_ID
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * COUNT_CONST
      +	COUNT_CONST, sizeof(THING)
        , ...)
      )
      
      // 2-factor product, only identifiers.
      @@
      identifier SIZE, COUNT;
      @@
      
      - kzalloc
      + kcalloc
        (
      -	SIZE * COUNT
      +	COUNT, SIZE
        , ...)
      
      // 3-factor product with 1 sizeof(type) or sizeof(expression), with
      // redundant parens removed.
      @@
      expression THING;
      identifier STRIDE, COUNT;
      type TYPE;
      @@
      
      (
        kzalloc(
      -	sizeof(TYPE) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      )
      
      // 3-factor product with 2 sizeof(variable), with redundant parens removed.
      @@
      expression THING1, THING2;
      identifier COUNT;
      type TYPE1, TYPE2;
      @@
      
      (
        kzalloc(
      -	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kzalloc(
      -	sizeof(THING1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(THING1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      )
      
      // 3-factor product, only identifiers, with redundant parens removed.
      @@
      identifier STRIDE, SIZE, COUNT;
      @@
      
      (
        kzalloc(
      -	(COUNT) * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      )
      
      // Any remaining multi-factor products, first at least 3-factor products,
      // when they're not all constants...
      @@
      expression E1, E2, E3;
      constant C1, C2, C3;
      @@
      
      (
        kzalloc(C1 * C2 * C3, ...)
      |
        kzalloc(
      -	(E1) * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	(E1) * (E2) * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	(E1) * (E2) * (E3)
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	E1 * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      )
      
      // And then all remaining 2 factors products when they're not all constants,
      // keeping sizeof() as the second factor argument.
      @@
      expression THING, E1, E2;
      type TYPE;
      constant C1, C2, C3;
      @@
      
      (
        kzalloc(sizeof(THING) * C2, ...)
      |
        kzalloc(sizeof(TYPE) * C2, ...)
      |
        kzalloc(C1 * C2 * C3, ...)
      |
        kzalloc(C1 * C2, ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (E2)
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * E2
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (E2)
      +	E2, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * E2
      +	E2, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	(E1) * E2
      +	E1, E2
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	(E1) * (E2)
      +	E1, E2
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	E1 * E2
      +	E1, E2
        , ...)
      )
      Signed-off-by: NKees Cook <keescook@chromium.org>
      6396bb22
  4. 16 5月, 2018 1 次提交
  5. 23 4月, 2018 1 次提交
  6. 23 3月, 2018 1 次提交
  7. 28 2月, 2018 1 次提交
  8. 22 1月, 2018 1 次提交
    • S
      serial: core: mark port as initialized after successful IRQ change · 44117a1d
      Sebastian Andrzej Siewior 提交于
      setserial changes the IRQ via uart_set_info(). It invokes
      uart_shutdown() which free the current used IRQ and clear
      TTY_PORT_INITIALIZED. It will then update the IRQ number and invoke
      uart_startup() before returning to the caller leaving
      TTY_PORT_INITIALIZED cleared.
      
      The next open will crash with
      |  list_add double add: new=ffffffff839fcc98, prev=ffffffff839fcc98, next=ffffffff839fcc98.
      since the close from the IOCTL won't free the IRQ (and clean the list)
      due to the TTY_PORT_INITIALIZED check in uart_shutdown().
      
      There is same pattern in uart_do_autoconfig() and I *think* it also
      needs to set TTY_PORT_INITIALIZED there.
      Is there a reason why uart_startup() does not set the flag by itself
      after the IRQ has been acquired (since it is cleared in uart_shutdown)?
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      44117a1d
  9. 09 1月, 2018 1 次提交
  10. 28 11月, 2017 2 次提交
    • L
      serial: core: Support common rs485 binding for RTS polarity · f1e5b618
      Lukas Wunner 提交于
      When a driver invokes the uart_get_rs485_mode() helper, set the RTS
      polarity to active high by default unless the newly introduced
      "rs485-rts-active-low" property was specified.
      
      imx contains a line to set the default RTS polarity to active high,
      it is now superfluous and hence deleted.
      
      omap-serial historically defaults to active low and supports an
      "rs485-rts-active-high" property to inverse the polarity.
      Retain that behavior for compatibility.
      
      Cc: Mark Jackson <mpfj@newflow.co.uk>
      Cc: Michał Oleszczyk <oleszczyk.m@gmail.com>
      Cc: Rafael Gago Castano <rgc@hms.se>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Acked-by: NUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f1e5b618
    • L
      serial: Make retrieval of rs485 properties platform-agnostic · 743f93f8
      Lukas Wunner 提交于
      Commit ef838a81 ("serial: Add common rs485 device tree parsing
      function") consolidated retrieval of rs485 OF properties in a common
      helper function but did not #ifdef it to CONFIG_OF.  The function is
      therefore included on ACPI platforms as well even though it's not used.
      
      On the other hand ACPI platforms with rs485 do exist (e.g. Siemens
      IOT2040) and they may leverage _DSD to store rs485 properties.  Likewise,
      UART platform devices instantiated from an MFD should be able to specify
      rs485 properties.  In fact, the tty subsystem maintainer had asked for
      a "generic" function during review of commit ef838a81:
      https://marc.info/?l=linux-serial&m=150143441725194&w=4
      
      Thus, instead of constraining the helper to OF platforms, make it
      platform-agnostic by converting it to device_property_*() functions
      and renaming it accordingly.
      
      In imx.c, move the invocation of uart_get_rs485_mode() from
      serial_imx_probe_dt() to serial_imx_probe() so that it also gets called
      for non-OF devices.
      
      In omap-serial.c, move its invocation further up within
      serial_omap_probe_rs485() so that the RTS polarity can be overridden
      with the driver-specific "rs485-rts-active-high" property once we
      introduce a generic "rs485-rts-active-low" property.
      
      Cc: Jan Kiszka <jan.kiszka@siemens.com>
      Cc: Richard Genoud <richard.genoud@gmail.com>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Acked-by: NUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      743f93f8
  11. 08 11月, 2017 2 次提交
    • G
      tty: serial: Remove redundant license text · 4793f2eb
      Greg Kroah-Hartman 提交于
      Now that the SPDX tag is in all tty files, that identifies the license
      in a specific and legally-defined manner.  So the extra GPL text wording
      can be removed as it is no longer needed at all.
      
      This is done on a quest to remove the 700+ different ways that files in
      the kernel describe the GPL license text.  And there's unneeded stuff
      like the address (sometimes incorrect) for the FSF which is never
      needed.
      
      No copyright headers or other non-license-description text was removed.
      
      Cc: Jiri Slaby <jslaby@suse.com>
      Cc: Eric Anholt <eric@anholt.net>
      Cc: Stefan Wahren <stefan.wahren@i2se.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Ray Jui <rjui@broadcom.com>
      Cc: Scott Branden <sbranden@broadcom.com>
      Cc: bcm-kernel-feedback-list@broadcom.com
      Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Joachim Eastwood <manabian@gmail.com>
      Cc: Matthias Brugger <matthias.bgg@gmail.com>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Tobias Klauser <tklauser@distanz.ch>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Richard Genoud <richard.genoud@gmail.com>
      Cc: Alexander Shiyan <shc_work@mail.ru>
      Cc: Baruch Siach <baruch@tkos.co.il>
      Cc: Pat Gefre <pfg@sgi.com>
      Cc: "Guilherme G. Piccoli" <gpiccoli@linux.vnet.ibm.com>
      Cc: Jason Wessel <jason.wessel@windriver.com>
      Cc: Vladimir Zapolskiy <vz@mleia.com>
      Cc: Sylvain Lemieux <slemieux.tyco@gmail.com>
      Cc: Carlo Caione <carlo@caione.org>
      Cc: Kevin Hilman <khilman@baylibre.com>
      Cc: Liviu Dudau <liviu.dudau@arm.com>
      Cc: Sudeep Holla <sudeep.holla@arm.com>
      Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Cc: Andy Gross <andy.gross@linaro.org>
      Cc: David Brown <david.brown@linaro.org>
      Cc: "Andreas Färber" <afaerber@suse.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Laxman Dewangan <ldewangan@nvidia.com>
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Cc: Jonathan Hunter <jonathanh@nvidia.com>
      Cc: Barry Song <baohua@kernel.org>
      Cc: Patrice Chotard <patrice.chotard@st.com>
      Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
      Cc: Alexandre Torgue <alexandre.torgue@st.com>
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: Peter Korsgaard <jacmet@sunsite.dk>
      Cc: Timur Tabi <timur@tabi.org>
      Cc: Tony Prisk <linux@prisktech.co.nz>
      Cc: Michal Simek <michal.simek@xilinx.com>
      Cc: "Sören Brinkmann" <soren.brinkmann@xilinx.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4793f2eb
    • G
      tty: add SPDX identifiers to all remaining files in drivers/tty/ · e3b3d0f5
      Greg Kroah-Hartman 提交于
      It's good to have SPDX identifiers in all files to make it easier to
      audit the kernel tree for correct licenses.
      
      Update the drivers/tty files files with the correct SPDX license
      identifier based on the license text in the file itself.  The SPDX
      identifier is a legally binding shorthand, which can be used instead of
      the full boiler plate text.
      
      This work is based on a script and data from Thomas Gleixner, Philippe
      Ombredanne, and Kate Stewart.
      
      Cc: Jiri Slaby <jslaby@suse.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: David Sterba <dsterba@suse.com>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Eric Anholt <eric@anholt.net>
      Cc: Stefan Wahren <stefan.wahren@i2se.com>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Ray Jui <rjui@broadcom.com>
      Cc: Scott Branden <sbranden@broadcom.com>
      Cc: bcm-kernel-feedback-list@broadcom.com
      Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Joachim Eastwood <manabian@gmail.com>
      Cc: Matthias Brugger <matthias.bgg@gmail.com>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Tobias Klauser <tklauser@distanz.ch>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Richard Genoud <richard.genoud@gmail.com>
      Cc: Alexander Shiyan <shc_work@mail.ru>
      Cc: Baruch Siach <baruch@tkos.co.il>
      Cc: "Maciej W. Rozycki" <macro@linux-mips.org>
      Cc: "Uwe Kleine-König" <kernel@pengutronix.de>
      Cc: Pat Gefre <pfg@sgi.com>
      Cc: "Guilherme G. Piccoli" <gpiccoli@linux.vnet.ibm.com>
      Cc: Jason Wessel <jason.wessel@windriver.com>
      Cc: Vladimir Zapolskiy <vz@mleia.com>
      Cc: Sylvain Lemieux <slemieux.tyco@gmail.com>
      Cc: Carlo Caione <carlo@caione.org>
      Cc: Kevin Hilman <khilman@baylibre.com>
      Cc: Liviu Dudau <liviu.dudau@arm.com>
      Cc: Sudeep Holla <sudeep.holla@arm.com>
      Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Cc: Andy Gross <andy.gross@linaro.org>
      Cc: David Brown <david.brown@linaro.org>
      Cc: "Andreas Färber" <afaerber@suse.de>
      Cc: Kevin Cernekee <cernekee@gmail.com>
      Cc: Laxman Dewangan <ldewangan@nvidia.com>
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Cc: Jonathan Hunter <jonathanh@nvidia.com>
      Cc: Barry Song <baohua@kernel.org>
      Cc: Patrice Chotard <patrice.chotard@st.com>
      Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
      Cc: Alexandre Torgue <alexandre.torgue@st.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Peter Korsgaard <jacmet@sunsite.dk>
      Cc: Timur Tabi <timur@tabi.org>
      Cc: Tony Prisk <linux@prisktech.co.nz>
      Cc: Michal Simek <michal.simek@xilinx.com>
      Cc: "Sören Brinkmann" <soren.brinkmann@xilinx.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Cc: Philippe Ombredanne <pombredanne@nexb.com>
      Cc: Jiri Slaby <jslaby@suse.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e3b3d0f5
  12. 04 11月, 2017 1 次提交
  13. 19 9月, 2017 1 次提交
  14. 29 8月, 2017 2 次提交
  15. 30 7月, 2017 1 次提交
    • A
      serial: core: enforce type for upf_t when copying · a17e74c5
      Andy Shevchenko 提交于
      upf_t is a bitwise defined type and any assignment from different, but
      compatible, types makes static analyzer unhappy.
      
      drivers/tty/serial/serial_core.c:793:29: warning: incorrect type in assignment (different base types)
      drivers/tty/serial/serial_core.c:793:29:    expected int [signed] flags
      drivers/tty/serial/serial_core.c:793:29:    got restricted upf_t [usertype] flags
      drivers/tty/serial/serial_core.c:867:19: warning: incorrect type in assignment (different base types)
      drivers/tty/serial/serial_core.c:867:19:    expected restricted upf_t [usertype] new_flags
      drivers/tty/serial/serial_core.c:867:19:    got int [signed] flags
      
      Enforce corresponding types when upf_t being assigned.
      
      Note, we need __force attribute due to the scope of variable. It's being
      used in user space with plain old type while kernel uses bitwise one.
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a17e74c5
  16. 13 6月, 2017 1 次提交
  17. 18 5月, 2017 2 次提交
  18. 09 4月, 2017 1 次提交
  19. 31 3月, 2017 1 次提交
  20. 17 3月, 2017 1 次提交
    • J
      tty: serial_core, remove state checks in uart_poll* · 22077b09
      Jiri Slaby 提交于
      Coverity complains about uart_state checks in polling functions. And it
      is indeed correct. We do something like this:
      	struct uart_state *state = drv->state + line;
      	if (!state)
      		return;
      
      Adding 'line' to drv->state would move the potential NULL pointer to
      something near NULL and the check is useless. Even if we checked pure
      drv->state, nothing guarantees it is not freed and NULLed after the
      check. So if the only user of this interface (kgdboc) needs to assure
      something, this is neither the correct thing, nor place to do so.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Cc: linux-serial@vger.kernel.org
      Cc: Jason Wessel <jason.wessel@windriver.com>
      Cc: kgdb-bugreport@lists.sourceforge.net
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      22077b09
  21. 02 3月, 2017 1 次提交
  22. 25 12月, 2016 1 次提交
  23. 28 11月, 2016 1 次提交
  24. 28 10月, 2016 2 次提交
    • R
      tty: serial_core: fix NULL struct tty pointer access in uart_write_wakeup · d0f4bce2
      Rob Herring 提交于
      Since commit 761ed4a9 ("tty: serial_core: convert uart_close to
      use tty_port_close"), the serial console is broken on various systems
      and typing "reboot" splats the following on the serial console:
      
      INIT: Sending p[  427.863916] BUG: unable to handle kernel NULL pointer dereference at 00000000000001e0
      [  427.885156] IP: [] tty_wakeup+0xc/0x70
      [  427.898337] PGD 0 [  427.902051]
      [  427.907498] Oops: 0000 [#1] PREEMPT SMP
      [  427.917635] Modules linked in: nfsv3 nfs_acl nfs fscache lockd
      sunrpc grace edd af_packet cpufreq_conservative cpufreq_userspace
      cpufreq_powersave fuse loop md_mod dm_mod joydev hid_generic usbhid
      ipmi_ssif ohci_pci ohci_hcd ehci_pci ehci_hcd e1000e ptp firewire_ohci
      edac_core pps_core tpm_infineon sp5100_tco firewire_core acpi_cpufreq
      serio_raw pcspkr fjes usbcore shpchp edac_mce_amd tpm_tis ipmi_si
      tpm_tis_core i2c_piix4 k10temp sg ipmi_msghandler tpm sr_mod button
      cdrom kvm_amd kvm irqbypass crc_itu_t ast ttm drm_kms_helper drm
      fb_sys_fops sysimgblt sysfillrect syscopyarea i2c_algo_bit scsi_dh_rdac
      scsi_dh_alua scsi_dh_emc scsi_dh_hp_sw ata_generic pata_atiixp
      [  428.054179] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.9.0-rc1-1.g73e3f23-default #1
      [  428.072868] Hardware name: System manufacturer System Product Name/KGP(M)E-D16, BIOS 0902    12/03/2010
      [  428.094755] task: ffffffffa2c0d500 task.stack: ffffffffa2c00000
      [  428.109717] RIP: 0010:[]  [] tty_wakeup+0xc/0x70
      [  428.128407] RSP: 0018:ffff9a1a5fc03df8  EFLAGS: 00010086
      [  428.142184] RAX: ffff9a1857258000 RBX: ffffffffa3050ea0 RCX: 0000000000000000
      [  428.159649] RDX: 000000000000001b RSI: 0000000000000000 RDI: 0000000000000000
      [  428.177109] RBP: ffff9a1a5fc03e08 R08: 0000000000000000 R09: 0000000000000000
      [  428.194547] R10: 0000000000021c77 R11: 0000000000000000 R12: ffff9a1857258000
      [  428.212002] R13: 0000000000000000 R14: 0000000000000020 R15: 0000000000000020
      [  428.229481] FS:  0000000000000000(0000) GS:ffff9a1a5fc00000(0000) knlGS:0000000000000000
      [  428.248938] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  428.263726] CR2: 00000000000001e0 CR3: 0000000390c06000 CR4: 00000000000006f0
      [  428.281331] Stack:
      [  428.288696]  ffffffffa3050ea0 ffff9a1857258000 ffff9a1a5fc03e18 ffffffffa24e0ab1
      [  428.307064]  ffff9a1a5fc03e40 ffffffffa24e8865 ffffffffa3050ea0 00000000000000c2
      [  428.325456]  0000000000000046 ffff9a1a5fc03e78 ffffffffa24e8a5f ffffffffa3050ea0
      [  428.343905] Call Trace:
      [  428.352319]   [  428.356216]  [] uart_write_wakeup+0x21/0x30
      
      The problem is for console ports, the serial port is not shutdown and
      interrupts may fire after the struct tty is gone. Simply calling the
      tty_port helper tty_port_tty_wakeup instead of tty_wakeup directly will
      ensure there is a valid struct tty.
      
      Fixes: 761ed4a9 ("tty: serial_core: convert uart_close to use tty_port_close")
      Reported-by: NBorislav Petkov <bp@alien8.de>
      Reported-by: NMike Galbraith <mgalbraith@suse.de>
      Cc: Jiri Slaby <jslaby@suse.cz>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: linux-serial@vger.kernel.org
      Signed-off-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d0f4bce2
    • G
      tty: serial_core: Fix serial console crash on port shutdown · 4dda864d
      Geert Uytterhoeven 提交于
      The port->console flag is always false, as uart_console() is called
      before the serial console has been registered.
      
      Hence for a serial port used as the console, uart_tty_port_shutdown()
      will still be called when userspace closes the port, powering it down.
      This may lead to a system lock up when the serial console driver writes
      to the serial port's registers.
      
      To fix this, move the setting of port->console after the call to
      uart_configure_port(), which registers the serial console.
      
      Fixes: 761ed4a9 ("tty: serial_core: convert uart_close to use tty_port_close")
      Reported-by: NNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: NRob Herring <robh@kernel.org>
      Tested-by: NMugunthan V N <mugunthanvnm@ti.com>
      Tested-by: NNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
      [robh: rebased on tty-linus]
      Signed-off-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4dda864d
  25. 27 10月, 2016 1 次提交
  26. 15 9月, 2016 1 次提交
  27. 14 9月, 2016 1 次提交
  28. 02 9月, 2016 1 次提交
  29. 31 8月, 2016 2 次提交
  30. 26 6月, 2016 1 次提交
  31. 04 5月, 2016 1 次提交
  32. 01 5月, 2016 2 次提交
    • P
      serial: core: Prevent unsafe uart port access, part 3 · af224ca2
      Peter Hurley 提交于
      For tty operations which may expect uart port to have been removed
      but still have other necessary work to accomplish, check for NULL
      uart port; specifically uart_close(), uart_hangup() and sub-functions
      (uart_shutdown() and uart_port_shutdown()).
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af224ca2
    • P
      serial: core: Prevent unsafe uart port access, part 2 · 9ed19428
      Peter Hurley 提交于
      For serial core operations not already excluded by holding port->mutex,
      use reference counting to protect deferencing the state->uart_port.
      
      Introduce helper functions, uart_port_ref() and uart_port_deref(), to
      wrap uart_port access, and helper macros, uart_port_lock() and
      uart_port_unlock(), to wrap combination uart_port access with uart
      port lock sections.
      
      Port removal in uart_remove_one_port() waits for reference count to
      drop to zero before detaching the uart port from struct uart_state.
      
      For functions only reading the tx circular buffer indexes (where the
      uart port lock is claimed to prevent concurrent users), a NULL uart
      port is simply ignored and the operation completes normally.
      
      For functions change the tx circular buffer indexes (where the uart
      port lock is claimed to prevent concurrent users), the operation is
      aborted if the uart port is NULL (ie., has been detached).
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9ed19428