1. 02 Jul, 2022 5 commits
    • Jason A. Donenfeld's avatar
      random: quiet urandom warning ratelimit suppression message · 97e6ead0
      Jason A. Donenfeld authored
      commit c01d4d0a upstream.
      
      random.c ratelimits how much it warns about uninitialized urandom reads
      using __ratelimit(). When the RNG is finally initialized, it prints the
      number of missed messages due to ratelimiting.
      
      It has been this way since that functionality was introduced back in
      2018. Recently, cc1e127b ("random: remove ratelimiting for in-kernel
      unseeded randomness") put a bit more stress on the urandom ratelimiting,
      which teased out a bug in the implementation.
      
      Specifically, when under pressure, __ratelimit() will print its own
      message and reset the count back to 0, making the final message at the
      end less useful. Secondly, it does so as a pr_warn(), which apparently
      is undesirable for people's CI.
      
      Fortunately, __ratelimit() has the RATELIMIT_MSG_ON_RELEASE flag exactly
      for this purpose, so we set the flag.
      
      Fixes: 4e00b339
      
       ("random: rate limit unseeded randomness warnings")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Reported-by: default avatarRon Economos <re@w6rz.net>
      Tested-by: default avatarRon Economos <re@w6rz.net>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      97e6ead0
    • Nikos Tsironis's avatar
      dm era: commit metadata in postsuspend after worker stops · 91c20499
      Nikos Tsironis authored
      commit 9ae6e8b1 upstream.
      
      During postsuspend dm-era does the following:
      
      1. Archives the current era
      2. Commits the metadata, as part of the RPC call for archiving the
         current era
      3. Stops the worker
      
      Until the worker stops, it might write to the metadata again. Moreover,
      these writes are not flushed to disk immediately, but are cached by the
      dm-bufio client, which writes them back asynchronously.
      
      As a result, the committed metadata of a suspended dm-era device might
      not be consistent with the in-core metadata.
      
      In some cases, this can result in the corruption of the on-disk
      metadata. Suppose the following sequence of events:
      
      1. Load a new table, e.g. a snapshot-origin table, to a device with a
         dm-era table
      2. Suspend the device
      3. dm-era commits its metadata, but the worker does a few more metadata
         writes until it stops, as part of digesting an archived writeset
      4. These writes are cached by the dm-bufio client
      5. Load the dm-era table to another device.
      6. The new instance of the dm-era target loads the committed, on-disk
         metadata, which don't include the extra writes done by the worker
         after the metadata commit.
      7. Resume the new device
      8. The new dm-era target instance starts using the metadata
      9. Resume the original device
      10. The destructor of the old dm-era target instance is called and
          destroys the dm-bufio client, which results in flushing the cached
          writes to disk
      11. These writes might overwrite the writes done by the new dm-era
          instance, hence corrupting its metadata.
      
      Fix this by committing the metadata after the worker stops running.
      
      stop_worker uses flush_workqueue to flush the current work. However, the
      work item may re-queue itself and flush_workqueue doesn't wait for
      re-queued works to finish.
      
      This could result in the worker changing the metadata after they have
      been committed, or writing to the metadata concurrently with the commit
      in the postsuspend thread.
      
      Use drain_workqueue instead, which waits until the work and all
      re-queued works finish.
      
      Fixes: eec40579
      
       ("dm: add era target")
      Cc: stable@vger.kernel.org # v3.15+
      Signed-off-by: default avatarNikos Tsironis <ntsironis@arrikto.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      91c20499
    • Edward Wu's avatar
      ata: libata: add qc->flags in ata_qc_complete_template tracepoint · 42c75fc8
      Edward Wu authored
      commit 540a92bf upstream.
      
      Add flags value to check the result of ata completion
      
      Fixes: 255c03d1
      
       ("libata: Add tracepoints")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarEdward Wu <edwardwu@realtek.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      42c75fc8
    • Jason A. Donenfeld's avatar
      random: schedule mix_interrupt_randomness() less often · f2944c94
      Jason A. Donenfeld authored
      commit 534d2eaf upstream.
      
      It used to be that mix_interrupt_randomness() would credit 1 bit each
      time it ran, and so add_interrupt_randomness() would schedule mix() to
      run every 64 interrupts, a fairly arbitrary number, but nonetheless
      considered to be a decent enough conservative estimate.
      
      Since e3e33fc2 ("random: do not use input pool from hard IRQs"),
      mix() is now able to credit multiple bits, depending on the number of
      calls to add(). This was done for reasons separate from this commit, but
      it has the nice side effect of enabling this patch to schedule mix()
      less often.
      
      Currently the rules are:
      a) Credit 1 bit for every 64 calls to add().
      b) Schedule mix() once a second that add() is called.
      c) Schedule mix() once every 64 calls to add().
      
      Rules (a) and (c) no longer need to be coupled. It's still important to
      have _some_ value in (c), so that we don't "over-saturate" the fast
      pool, but the once per second we get from rule (b) is a plenty enough
      baseline. So, by increasing the 64 in rule (c) to something larger, we
      avoid calling queue_work_on() as frequently during irq storms.
      
      This commit changes that 64 in rule (c) to be 1024, which means we
      schedule mix() 16 times less often. And it does *not* need to change the
      64 in rule (a).
      
      Fixes: 58340f8e
      
       ("random: defer fast pool mixing to worker")
      Cc: stable@vger.kernel.org
      Cc: Dominik Brodowski <linux@dominikbrodowski.net>
      Acked-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f2944c94
    • Jiri Slaby's avatar
      vt: drop old FONT ioctls · 259742e9
      Jiri Slaby authored
      commit ff2047fb upstream.
      
      Drop support for these ioctls:
      * PIO_FONT, PIO_FONTX
      * GIO_FONT, GIO_FONTX
      * PIO_FONTRESET
      
      As was demonstrated by commit 90bfdeef
      
       (tty: make FONTX ioctl use
      the tty pointer they were actually passed), these ioctls are not used
      from userspace, as:
      1) they used to be broken (set up font on current console, not the open
         one) and racy (before the commit above)
      2) KDFONTOP ioctl is used for years instead
      
      Note that PIO_FONTRESET is defunct on most systems as VGA_CONSOLE is set
      on them for ages. That turns on BROKEN_GRAPHICS_PROGRAMS which makes
      PIO_FONTRESET just return an error.
      
      We are removing KD_FONT_FLAG_OLD here as it was used only by these
      removed ioctls. kd.h header exists both in kernel and uapi headers, so
      we can remove the kernel one completely. Everyone includeing kd.h will
      now automatically get the uapi one.
      
      There are now unused definitions of the ioctl numbers and "struct
      consolefontdesc" in kd.h, but as it is a uapi header, I am not touching
      these.
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      Link: https://lore.kernel.org/r/20210105120239.28031-8-jslaby@suse.cz
      
      
      Cc: guodaxing <guodaxing@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      259742e9
  2. 25 Jun, 2022 35 commits