Merge tag 'fscache-fixes-20220831' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 31 Aug 2022 17:13:34 +0000 (10:13 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 31 Aug 2022 17:13:34 +0000 (10:13 -0700)
Pull fscache/cachefiles fixes from David Howells:

 - Fix kdoc on fscache_use/unuse_cookie().

 - Fix the error returned by cachefiles_ondemand_copen() from an upcall
   result.

 - Fix the distribution of requests in on-demand mode in cachefiles to
   be fairer by cycling through them rather than picking the one with
   the lowest ID each time (IDs being reused).

* tag 'fscache-fixes-20220831' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
  cachefiles: make on-demand request distribution fairer
  cachefiles: fix error return code in cachefiles_ondemand_copen()
  fscache: fix misdocumented parameter

31 files changed:
Documentation/admin-guide/README.rst
Documentation/admin-guide/mm/damon/usage.rst
Documentation/conf.py
Documentation/sphinx/kerneldoc-preamble.sty
Documentation/translations/ja_JP/SubmittingPatches
drivers/char/mem.c
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
drivers/hid/hid-asus.c
drivers/hid/hid-ids.h
drivers/hid/hid-input.c
drivers/hid/hid-nintendo.c
drivers/hid/hid-quirks.c
drivers/hid/hid-steam.c
drivers/hid/hid-thrustmaster.c
drivers/hid/hidraw.c
drivers/hid/intel-ish-hid/ipc/hw-ish.h
drivers/hid/intel-ish-hid/ipc/pci-ish.c
drivers/hid/intel-ish-hid/ishtp-hid.h
drivers/hid/intel-ish-hid/ishtp/client.c
include/linux/compiler.h
include/linux/lsm_hook_defs.h
include/linux/lsm_hooks.h
include/linux/overflow.h
include/linux/security.h
include/linux/trace_events.h
io_uring/uring_cmd.c
lib/crypto/Kconfig
security/security.c
security/selinux/hooks.c
security/selinux/include/classmap.h
security/smack/smack_lsm.c

index caa3c09..9eb6b90 100644 (file)
@@ -1,9 +1,9 @@
 .. _readme:
 
-Linux kernel release 5.x <http://kernel.org/>
+Linux kernel release 6.x <http://kernel.org/>
 =============================================
 
-These are the release notes for Linux version 5.  Read them carefully,
+These are the release notes for Linux version 6.  Read them carefully,
 as they tell you what this is all about, explain how to install the
 kernel, and what to do if something goes wrong.
 
@@ -63,7 +63,7 @@ Installing the kernel source
    directory where you have permissions (e.g. your home directory) and
    unpack it::
 
-     xz -cd linux-5.x.tar.xz | tar xvf -
+     xz -cd linux-6.x.tar.xz | tar xvf -
 
    Replace "X" with the version number of the latest kernel.
 
@@ -72,12 +72,12 @@ Installing the kernel source
    files.  They should match the library, and not get messed up by
    whatever the kernel-du-jour happens to be.
 
- - You can also upgrade between 5.x releases by patching.  Patches are
+ - You can also upgrade between 6.x releases by patching.  Patches are
    distributed in the xz format.  To install by patching, get all the
    newer patch files, enter the top level directory of the kernel source
-   (linux-5.x) and execute::
+   (linux-6.x) and execute::
 
-     xz -cd ../patch-5.x.xz | patch -p1
+     xz -cd ../patch-6.x.xz | patch -p1
 
    Replace "x" for all versions bigger than the version "x" of your current
    source tree, **in_order**, and you should be ok.  You may want to remove
@@ -85,13 +85,13 @@ Installing the kernel source
    that there are no failed patches (some-file-name# or some-file-name.rej).
    If there are, either you or I have made a mistake.
 
-   Unlike patches for the 5.x kernels, patches for the 5.x.y kernels
+   Unlike patches for the 6.x kernels, patches for the 6.x.y kernels
    (also known as the -stable kernels) are not incremental but instead apply
-   directly to the base 5.x kernel.  For example, if your base kernel is 5.0
-   and you want to apply the 5.0.3 patch, you must not first apply the 5.0.1
-   and 5.0.2 patches. Similarly, if you are running kernel version 5.0.2 and
-   want to jump to 5.0.3, you must first reverse the 5.0.2 patch (that is,
-   patch -R) **before** applying the 5.0.3 patch. You can read more on this in
+   directly to the base 6.x kernel.  For example, if your base kernel is 6.0
+   and you want to apply the 6.0.3 patch, you must not first apply the 6.0.1
+   and 6.0.2 patches. Similarly, if you are running kernel version 6.0.2 and
+   want to jump to 6.0.3, you must first reverse the 6.0.2 patch (that is,
+   patch -R) **before** applying the 6.0.3 patch. You can read more on this in
    :ref:`Documentation/process/applying-patches.rst <applying_patches>`.
 
    Alternatively, the script patch-kernel can be used to automate this
@@ -114,7 +114,7 @@ Installing the kernel source
 Software requirements
 ---------------------
 
-   Compiling and running the 5.x kernels requires up-to-date
+   Compiling and running the 6.x kernels requires up-to-date
    versions of various software packages.  Consult
    :ref:`Documentation/process/changes.rst <changes>` for the minimum version numbers
    required and how to get updates for these packages.  Beware that using
@@ -132,12 +132,12 @@ Build directory for the kernel
    place for the output files (including .config).
    Example::
 
-     kernel source code: /usr/src/linux-5.x
+     kernel source code: /usr/src/linux-6.x
      build directory:    /home/name/build/kernel
 
    To configure and build the kernel, use::
 
-     cd /usr/src/linux-5.x
+     cd /usr/src/linux-6.x
      make O=/home/name/build/kernel menuconfig
      make O=/home/name/build/kernel
      sudo make O=/home/name/build/kernel modules_install install
index d52f572..ca91ecc 100644 (file)
@@ -50,10 +50,10 @@ For a short example, users can monitor the virtual address space of a given
 workload as below. ::
 
     # cd /sys/kernel/mm/damon/admin/
-    # echo 1 > kdamonds/nr && echo 1 > kdamonds/0/contexts/nr
+    # echo 1 > kdamonds/nr_kdamonds && echo 1 > kdamonds/0/contexts/nr_contexts
     # echo vaddr > kdamonds/0/contexts/0/operations
-    # echo 1 > kdamonds/0/contexts/0/targets/nr
-    # echo $(pidof <workload>) > kdamonds/0/contexts/0/targets/0/pid
+    # echo 1 > kdamonds/0/contexts/0/targets/nr_targets
+    # echo $(pidof <workload>) > kdamonds/0/contexts/0/targets/0/pid_target
     # echo on > kdamonds/0/state
 
 Files Hierarchy
@@ -366,12 +366,12 @@ memory rate becomes larger than 60%, or lower than 30%". ::
     # echo 1 > kdamonds/0/contexts/0/schemes/nr_schemes
     # cd kdamonds/0/contexts/0/schemes/0
     # # set the basic access pattern and the action
-    # echo 4096 > access_patterns/sz/min
-    # echo 8192 > access_patterns/sz/max
-    # echo 0 > access_patterns/nr_accesses/min
-    # echo 5 > access_patterns/nr_accesses/max
-    # echo 10 > access_patterns/age/min
-    # echo 20 > access_patterns/age/max
+    # echo 4096 > access_pattern/sz/min
+    # echo 8192 > access_pattern/sz/max
+    # echo 0 > access_pattern/nr_accesses/min
+    # echo 5 > access_pattern/nr_accesses/max
+    # echo 10 > access_pattern/age/min
+    # echo 20 > access_pattern/age/max
     # echo pageout > action
     # # set quotas
     # echo 10 > quotas/ms
index 934727e..255384d 100644 (file)
@@ -86,6 +86,7 @@ if major >= 3:
             "__used",
             "__weak",
             "noinline",
+            "__fix_address",
 
             # include/linux/memblock.h:
             "__init_memblock",
index 2a29cbe..9707e03 100644 (file)
 
 % Translations have Asian (CJK) characters which are only displayed if
 % xeCJK is used
+\usepackage{ifthen}
+\newboolean{enablecjk}
+\setboolean{enablecjk}{false}
 \IfFontExistsTF{Noto Sans CJK SC}{
-    % Load xeCJK when CJK font is available
+    \IfFileExists{xeCJK.sty}{
+       \setboolean{enablecjk}{true}
+    }{}
+}{}
+\ifthenelse{\boolean{enablecjk}}{
+    % Load xeCJK when both the Noto Sans CJK font and xeCJK.sty are available.
     \usepackage{xeCJK}
     % Noto CJK fonts don't provide slant shape. [AutoFakeSlant] permits
     % its emulation.
     % Inactivate CJK after tableofcontents
     \apptocmd{\sphinxtableofcontents}{\kerneldocCJKoff}{}{}
     \xeCJKsetup{CJKspace = true}% For inter-phrase space of Korean TOC
-}{ % No CJK font found
+}{ % Don't enable CJK
     % Custom macros to on/off CJK and switch CJK fonts (Dummy)
     \newcommand{\kerneldocCJKon}{}
     \newcommand{\kerneldocCJKoff}{}
     %% and ignore the argument (#1) in their definitions, whole contents of
     %% CJK chapters can be ignored.
     \newcommand{\kerneldocBeginSC}[1]{%
-       %% Put a note on missing CJK fonts in place of zh_CN translation.
-       \begin{sphinxadmonition}{note}{Note on missing fonts:}
+       %% Put a note on missing CJK fonts or the xecjk package in place of
+       %% zh_CN translation.
+       \begin{sphinxadmonition}{note}{Note on missing fonts and a package:}
            Translations of Simplified Chinese (zh\_CN), Traditional Chinese
            (zh\_TW), Korean (ko\_KR), and Japanese (ja\_JP) were skipped
-           due to the lack of suitable font families.
+           due to the lack of suitable font families and/or the texlive-xecjk
+           package.
 
            If you want them, please install ``Noto Sans CJK'' font families
-           by following instructions from
+           along with the texlive-xecjk package by following instructions from
            \sphinxcode{./scripts/sphinx-pre-install}.
            Having optional ``Noto Serif CJK'' font families will improve
            the looks of those translations.
index 66ce0d8..04deb77 100644 (file)
@@ -35,8 +35,7 @@ Linux カーネルに変更を加えたいと思っている個人又は会社
 てもらえやすくする提案を集めたものです。
 
 コードを投稿する前に、Documentation/process/submit-checklist.rst の項目リストに目
-を通してチェックしてください。もしあなたがドライバーを投稿しようとし
-ているなら、Documentation/process/submitting-drivers.rst にも目を通してください。
+を通してチェックしてください。
 
 --------------------------------------------
 セクション1 パッチの作り方と送り方
index 84ca98e..32a932a 100644 (file)
@@ -480,6 +480,11 @@ static ssize_t splice_write_null(struct pipe_inode_info *pipe, struct file *out,
        return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null);
 }
 
+static int uring_cmd_null(struct io_uring_cmd *ioucmd, unsigned int issue_flags)
+{
+       return 0;
+}
+
 static ssize_t read_iter_zero(struct kiocb *iocb, struct iov_iter *iter)
 {
        size_t written = 0;
@@ -663,6 +668,7 @@ static const struct file_operations null_fops = {
        .read_iter      = read_iter_null,
        .write_iter     = write_iter_null,
        .splice_write   = splice_write_null,
+       .uring_cmd      = uring_cmd_null,
 };
 
 static const struct file_operations __maybe_unused port_fops = {
index 4b90c86..47774b9 100644 (file)
@@ -288,11 +288,29 @@ int amd_sfh_irq_init(struct amd_mp2_dev *privdata)
        return 0;
 }
 
+static const struct dmi_system_id dmi_nodevs[] = {
+       {
+               /*
+                * Google Chromebooks use Chrome OS Embedded Controller Sensor
+                * Hub instead of Sensor Hub Fusion and leaves MP2
+                * uninitialized, which disables all functionalities, even
+                * including the registers necessary for feature detections.
+                */
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Google"),
+               },
+       },
+       { }
+};
+
 static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
        struct amd_mp2_dev *privdata;
        int rc;
 
+       if (dmi_first_match(dmi_nodevs))
+               return -ENODEV;
+
        privdata = devm_kzalloc(&pdev->dev, sizeof(*privdata), GFP_KERNEL);
        if (!privdata)
                return -ENOMEM;
index 08c9a9a..b59c3da 100644 (file)
@@ -1212,6 +1212,13 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
                rdesc = new_rdesc;
        }
 
+       if (drvdata->quirks & QUIRK_ROG_NKEY_KEYBOARD &&
+                       *rsize == 331 && rdesc[190] == 0x85 && rdesc[191] == 0x5a &&
+                       rdesc[204] == 0x95 && rdesc[205] == 0x05) {
+               hid_info(hdev, "Fixing up Asus N-KEY keyb report descriptor\n");
+               rdesc[205] = 0x01;
+       }
+
        return rdesc;
 }
 
index 0fb720a..f80d619 100644 (file)
 #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021   0x029c
 #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021   0x029a
 #define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021   0x029f
+#define USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT 0x8102
+#define USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY 0x8302
 
 #define USB_VENDOR_ID_ASUS             0x0486
 #define USB_DEVICE_ID_ASUS_T91MT       0x0185
 #define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN   0x2706
 #define I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN   0x261A
 #define I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN  0x2A1C
+#define I2C_DEVICE_ID_LENOVO_YOGA_C630_TOUCHSCREEN     0x279F
 
 #define USB_VENDOR_ID_ELECOM           0x056e
 #define USB_DEVICE_ID_ELECOM_BM084     0x0061
index 48c1c02..859aeb0 100644 (file)
@@ -383,6 +383,8 @@ static const struct hid_device_id hid_battery_quirks[] = {
          HID_BATTERY_QUIRK_IGNORE },
        { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO2_TOUCHSCREEN),
          HID_BATTERY_QUIRK_IGNORE },
+       { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_LENOVO_YOGA_C630_TOUCHSCREEN),
+         HID_BATTERY_QUIRK_IGNORE },
        {}
 };
 
@@ -1532,7 +1534,10 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
                         * assume ours
                         */
                        if (!report->tool)
-                               hid_report_set_tool(report, input, usage->code);
+                               report->tool = usage->code;
+
+                       /* drivers may have changed the value behind our back, resend it */
+                       hid_report_set_tool(report, input, report->tool);
                } else {
                        hid_report_release_tool(report, input, usage->code);
                }
index 92ac4f6..6028af3 100644 (file)
@@ -1221,6 +1221,7 @@ static void joycon_parse_report(struct joycon_ctlr *ctlr,
 
        spin_lock_irqsave(&ctlr->lock, flags);
        if (IS_ENABLED(CONFIG_NINTENDO_FF) && rep->vibrator_report &&
+           ctlr->ctlr_state != JOYCON_CTLR_STATE_REMOVED &&
            (msecs - ctlr->rumble_msecs) >= JC_RUMBLE_PERIOD_MS &&
            (ctlr->rumble_queue_head != ctlr->rumble_queue_tail ||
             ctlr->rumble_zero_countdown > 0)) {
@@ -1545,12 +1546,13 @@ static int joycon_set_rumble(struct joycon_ctlr *ctlr, u16 amp_r, u16 amp_l,
                ctlr->rumble_queue_head = 0;
        memcpy(ctlr->rumble_data[ctlr->rumble_queue_head], data,
               JC_RUMBLE_DATA_SIZE);
-       spin_unlock_irqrestore(&ctlr->lock, flags);
 
        /* don't wait for the periodic send (reduces latency) */
-       if (schedule_now)
+       if (schedule_now && ctlr->ctlr_state != JOYCON_CTLR_STATE_REMOVED)
                queue_work(ctlr->rumble_queue, &ctlr->rumble_worker);
 
+       spin_unlock_irqrestore(&ctlr->lock, flags);
+
        return 0;
 }
 
index dc67717..70f602c 100644 (file)
@@ -314,6 +314,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY) },
 #endif
 #if IS_ENABLED(CONFIG_HID_APPLEIR)
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL) },
index a3b151b..fc616db 100644 (file)
@@ -134,6 +134,11 @@ static int steam_recv_report(struct steam_device *steam,
        int ret;
 
        r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0];
+       if (!r) {
+               hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted -  nothing to read\n");
+               return -EINVAL;
+       }
+
        if (hid_report_len(r) < 64)
                return -EINVAL;
 
@@ -165,6 +170,11 @@ static int steam_send_report(struct steam_device *steam,
        int ret;
 
        r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0];
+       if (!r) {
+               hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted -  nothing to read\n");
+               return -EINVAL;
+       }
+
        if (hid_report_len(r) < 64)
                return -EINVAL;
 
index c3e6d69..cf1679b 100644 (file)
@@ -67,12 +67,13 @@ static const struct tm_wheel_info tm_wheels_infos[] = {
        {0x0200, 0x0005, "Thrustmaster T300RS (Missing Attachment)"},
        {0x0206, 0x0005, "Thrustmaster T300RS"},
        {0x0209, 0x0005, "Thrustmaster T300RS (Open Wheel Attachment)"},
+       {0x020a, 0x0005, "Thrustmaster T300RS (Sparco R383 Mod)"},
        {0x0204, 0x0005, "Thrustmaster T300 Ferrari Alcantara Edition"},
        {0x0002, 0x0002, "Thrustmaster T500RS"}
        //{0x0407, 0x0001, "Thrustmaster TMX"}
 };
 
-static const uint8_t tm_wheels_infos_length = 4;
+static const uint8_t tm_wheels_infos_length = 7;
 
 /*
  * This structs contains (in little endian) the response data
index 681614a..197b1e7 100644 (file)
@@ -350,6 +350,8 @@ static int hidraw_release(struct inode * inode, struct file * file)
        down_write(&minors_rwsem);
 
        spin_lock_irqsave(&hidraw_table[minor]->list_lock, flags);
+       for (int i = list->tail; i < list->head; i++)
+               kfree(list->buffer[i].value);
        list_del(&list->node);
        spin_unlock_irqrestore(&hidraw_table[minor]->list_lock, flags);
        kfree(list);
index e600dbf..fc108f1 100644 (file)
@@ -32,6 +32,7 @@
 #define ADL_P_DEVICE_ID                0x51FC
 #define ADL_N_DEVICE_ID                0x54FC
 #define RPL_S_DEVICE_ID                0x7A78
+#define MTL_P_DEVICE_ID                0x7E45
 
 #define        REVISION_ID_CHT_A0      0x6
 #define        REVISION_ID_CHT_Ax_SI   0x0
index 2c67ec1..7120b30 100644 (file)
@@ -43,6 +43,7 @@ static const struct pci_device_id ish_pci_tbl[] = {
        {PCI_DEVICE(PCI_VENDOR_ID_INTEL, ADL_P_DEVICE_ID)},
        {PCI_DEVICE(PCI_VENDOR_ID_INTEL, ADL_N_DEVICE_ID)},
        {PCI_DEVICE(PCI_VENDOR_ID_INTEL, RPL_S_DEVICE_ID)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MTL_P_DEVICE_ID)},
        {0, }
 };
 MODULE_DEVICE_TABLE(pci, ish_pci_tbl);
index 6a5cc11..35dddc5 100644 (file)
@@ -105,7 +105,7 @@ struct report_list {
  * @multi_packet_cnt:  Count of fragmented packet count
  *
  * This structure is used to store completion flags and per client data like
- * like report description, number of HID devices etc.
+ * report description, number of HID devices etc.
  */
 struct ishtp_cl_data {
        /* completion flags */
index 405e0d5..df0a825 100644 (file)
@@ -626,13 +626,14 @@ static void ishtp_cl_read_complete(struct ishtp_cl_rb *rb)
 }
 
 /**
- * ipc_tx_callback() - IPC tx callback function
+ * ipc_tx_send() - IPC tx send function
  * @prm: Pointer to client device instance
  *
- * Send message over IPC either first time or on callback on previous message
- * completion
+ * Send message over IPC. Message will be split into fragments
+ * if message size is bigger than IPC FIFO size, and all
+ * fragments will be sent one by one.
  */
-static void ipc_tx_callback(void *prm)
+static void ipc_tx_send(void *prm)
 {
        struct ishtp_cl *cl = prm;
        struct ishtp_cl_tx_ring *cl_msg;
@@ -677,32 +678,41 @@ static void ipc_tx_callback(void *prm)
                            list);
        rem = cl_msg->send_buf.size - cl->tx_offs;
 
-       ishtp_hdr.host_addr = cl->host_client_id;
-       ishtp_hdr.fw_addr = cl->fw_client_id;
-       ishtp_hdr.reserved = 0;
-       pmsg = cl_msg->send_buf.data + cl->tx_offs;
+       while (rem > 0) {
+               ishtp_hdr.host_addr = cl->host_client_id;
+               ishtp_hdr.fw_addr = cl->fw_client_id;
+               ishtp_hdr.reserved = 0;
+               pmsg = cl_msg->send_buf.data + cl->tx_offs;
+
+               if (rem <= dev->mtu) {
+                       /* Last fragment or only one packet */
+                       ishtp_hdr.length = rem;
+                       ishtp_hdr.msg_complete = 1;
+                       /* Submit to IPC queue with no callback */
+                       ishtp_write_message(dev, &ishtp_hdr, pmsg);
+                       cl->tx_offs = 0;
+                       cl->sending = 0;
 
-       if (rem <= dev->mtu) {
-               ishtp_hdr.length = rem;
-               ishtp_hdr.msg_complete = 1;
-               cl->sending = 0;
-               list_del_init(&cl_msg->list);   /* Must be before write */
-               spin_unlock_irqrestore(&cl->tx_list_spinlock, tx_flags);
-               /* Submit to IPC queue with no callback */
-               ishtp_write_message(dev, &ishtp_hdr, pmsg);
-               spin_lock_irqsave(&cl->tx_free_list_spinlock, tx_free_flags);
-               list_add_tail(&cl_msg->list, &cl->tx_free_list.list);
-               ++cl->tx_ring_free_size;
-               spin_unlock_irqrestore(&cl->tx_free_list_spinlock,
-                       tx_free_flags);
-       } else {
-               /* Send IPC fragment */
-               spin_unlock_irqrestore(&cl->tx_list_spinlock, tx_flags);
-               cl->tx_offs += dev->mtu;
-               ishtp_hdr.length = dev->mtu;
-               ishtp_hdr.msg_complete = 0;
-               ishtp_send_msg(dev, &ishtp_hdr, pmsg, ipc_tx_callback, cl);
+                       break;
+               } else {
+                       /* Send ipc fragment */
+                       ishtp_hdr.length = dev->mtu;
+                       ishtp_hdr.msg_complete = 0;
+                       /* All fregments submitted to IPC queue with no callback */
+                       ishtp_write_message(dev, &ishtp_hdr, pmsg);
+                       cl->tx_offs += dev->mtu;
+                       rem = cl_msg->send_buf.size - cl->tx_offs;
+               }
        }
+
+       list_del_init(&cl_msg->list);
+       spin_unlock_irqrestore(&cl->tx_list_spinlock, tx_flags);
+
+       spin_lock_irqsave(&cl->tx_free_list_spinlock, tx_free_flags);
+       list_add_tail(&cl_msg->list, &cl->tx_free_list.list);
+       ++cl->tx_ring_free_size;
+       spin_unlock_irqrestore(&cl->tx_free_list_spinlock,
+               tx_free_flags);
 }
 
 /**
@@ -720,7 +730,7 @@ static void ishtp_cl_send_msg_ipc(struct ishtp_device *dev,
                return;
 
        cl->tx_offs = 0;
-       ipc_tx_callback(cl);
+       ipc_tx_send(cl);
        ++cl->send_msg_cnt_ipc;
 }
 
index 01ce94b..7713d7b 100644 (file)
@@ -240,6 +240,12 @@ static inline void *offset_to_ptr(const int *off)
 #define __must_be_array(a)     BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
 
 /*
+ * Whether 'type' is a signed type or an unsigned type. Supports scalar types,
+ * bool and also pointer types.
+ */
+#define is_signed_type(type) (((type)(-1)) < (__force type)1)
+
+/*
  * This is needed in functions which generate the stack canary, see
  * arch/x86/kernel/smpboot.c::start_secondary() for an example.
  */
index 8064481..60fff13 100644 (file)
@@ -407,4 +407,5 @@ LSM_HOOK(int, 0, perf_event_write, struct perf_event *event)
 #ifdef CONFIG_IO_URING
 LSM_HOOK(int, 0, uring_override_creds, const struct cred *new)
 LSM_HOOK(int, 0, uring_sqpoll, void)
+LSM_HOOK(int, 0, uring_cmd, struct io_uring_cmd *ioucmd)
 #endif /* CONFIG_IO_URING */
index 84a0d7e..3aa6030 100644 (file)
  *      Check whether the current task is allowed to spawn a io_uring polling
  *      thread (IORING_SETUP_SQPOLL).
  *
+ * @uring_cmd:
+ *      Check whether the file_operations uring_cmd is allowed to run.
+ *
  */
 union security_list_options {
        #define LSM_HOOK(RET, DEFAULT, NAME, ...) RET (*NAME)(__VA_ARGS__);
index f1221d1..0eb3b19 100644 (file)
@@ -30,7 +30,6 @@
  * https://mail-index.netbsd.org/tech-misc/2007/02/05/0000.html -
  * credit to Christian Biere.
  */
-#define is_signed_type(type)       (((type)(-1)) < (type)1)
 #define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type)))
 #define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T)))
 #define type_min(T) ((T)((T)-type_max(T)-(T)1))
index 1bc362c..7bd0c49 100644 (file)
@@ -2060,6 +2060,7 @@ static inline int security_perf_event_write(struct perf_event *event)
 #ifdef CONFIG_SECURITY
 extern int security_uring_override_creds(const struct cred *new);
 extern int security_uring_sqpoll(void);
+extern int security_uring_cmd(struct io_uring_cmd *ioucmd);
 #else
 static inline int security_uring_override_creds(const struct cred *new)
 {
@@ -2069,6 +2070,10 @@ static inline int security_uring_sqpoll(void)
 {
        return 0;
 }
+static inline int security_uring_cmd(struct io_uring_cmd *ioucmd)
+{
+       return 0;
+}
 #endif /* CONFIG_SECURITY */
 #endif /* CONFIG_IO_URING */
 
index b18759a..8401dec 100644 (file)
@@ -814,8 +814,6 @@ extern int trace_add_event_call(struct trace_event_call *call);
 extern int trace_remove_event_call(struct trace_event_call *call);
 extern int trace_event_get_offsets(struct trace_event_call *call);
 
-#define is_signed_type(type)   (((type)(-1)) < (type)1)
-
 int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set);
 int trace_set_clr_event(const char *system, const char *event, int set);
 int trace_array_set_clr_event(struct trace_array *tr, const char *system,
index b9989ae..e78b6f9 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/errno.h>
 #include <linux/file.h>
 #include <linux/io_uring.h>
+#include <linux/security.h>
 
 #include <uapi/linux/io_uring.h>
 
@@ -88,6 +89,10 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
        if (!req->file->f_op->uring_cmd)
                return -EOPNOTSUPP;
 
+       ret = security_uring_cmd(ioucmd);
+       if (ret)
+               return ret;
+
        if (ctx->flags & IORING_SETUP_SQE128)
                issue_flags |= IO_URING_F_SQE128;
        if (ctx->flags & IORING_SETUP_CQE32)
index 9ff549f..47816af 100644 (file)
@@ -33,7 +33,6 @@ config CRYPTO_ARCH_HAVE_LIB_CHACHA
 
 config CRYPTO_LIB_CHACHA_GENERIC
        tristate
-       select XOR_BLOCKS
        help
          This symbol can be depended upon by arch implementations of the
          ChaCha library interface that require the generic code as a
index 14d30fe..4b95de2 100644 (file)
@@ -2660,4 +2660,8 @@ int security_uring_sqpoll(void)
 {
        return call_int_hook(uring_sqpoll, 0);
 }
+int security_uring_cmd(struct io_uring_cmd *ioucmd)
+{
+       return call_int_hook(uring_cmd, 0, ioucmd);
+}
 #endif /* CONFIG_IO_URING */
index 7957350..03bca97 100644 (file)
@@ -91,6 +91,7 @@
 #include <uapi/linux/mount.h>
 #include <linux/fsnotify.h>
 #include <linux/fanotify.h>
+#include <linux/io_uring.h>
 
 #include "avc.h"
 #include "objsec.h"
@@ -6987,6 +6988,28 @@ static int selinux_uring_sqpoll(void)
        return avc_has_perm(&selinux_state, sid, sid,
                            SECCLASS_IO_URING, IO_URING__SQPOLL, NULL);
 }
+
+/**
+ * selinux_uring_cmd - check if IORING_OP_URING_CMD is allowed
+ * @ioucmd: the io_uring command structure
+ *
+ * Check to see if the current domain is allowed to execute an
+ * IORING_OP_URING_CMD against the device/file specified in @ioucmd.
+ *
+ */
+static int selinux_uring_cmd(struct io_uring_cmd *ioucmd)
+{
+       struct file *file = ioucmd->file;
+       struct inode *inode = file_inode(file);
+       struct inode_security_struct *isec = selinux_inode(inode);
+       struct common_audit_data ad;
+
+       ad.type = LSM_AUDIT_DATA_FILE;
+       ad.u.file = file;
+
+       return avc_has_perm(&selinux_state, current_sid(), isec->sid,
+                           SECCLASS_IO_URING, IO_URING__CMD, &ad);
+}
 #endif /* CONFIG_IO_URING */
 
 /*
@@ -7231,6 +7254,7 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
 #ifdef CONFIG_IO_URING
        LSM_HOOK_INIT(uring_override_creds, selinux_uring_override_creds),
        LSM_HOOK_INIT(uring_sqpoll, selinux_uring_sqpoll),
+       LSM_HOOK_INIT(uring_cmd, selinux_uring_cmd),
 #endif
 
        /*
index ff757ae..1c2f41f 100644 (file)
@@ -253,7 +253,7 @@ const struct security_class_mapping secclass_map[] = {
        { "anon_inode",
          { COMMON_FILE_PERMS, NULL } },
        { "io_uring",
-         { "override_creds", "sqpoll", NULL } },
+         { "override_creds", "sqpoll", "cmd", NULL } },
        { NULL }
   };
 
index 0018314..bffccdc 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/fs_context.h>
 #include <linux/fs_parser.h>
 #include <linux/watch_queue.h>
+#include <linux/io_uring.h>
 #include "smack.h"
 
 #define TRANS_TRUE     "TRUE"
@@ -4732,6 +4733,36 @@ static int smack_uring_sqpoll(void)
        return -EPERM;
 }
 
+/**
+ * smack_uring_cmd - check on file operations for io_uring
+ * @ioucmd: the command in question
+ *
+ * Make a best guess about whether a io_uring "command" should
+ * be allowed. Use the same logic used for determining if the
+ * file could be opened for read in the absence of better criteria.
+ */
+static int smack_uring_cmd(struct io_uring_cmd *ioucmd)
+{
+       struct file *file = ioucmd->file;
+       struct smk_audit_info ad;
+       struct task_smack *tsp;
+       struct inode *inode;
+       int rc;
+
+       if (!file)
+               return -EINVAL;
+
+       tsp = smack_cred(file->f_cred);
+       inode = file_inode(file);
+
+       smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
+       smk_ad_setfield_u_fs_path(&ad, file->f_path);
+       rc = smk_tskacc(tsp, smk_of_inode(inode), MAY_READ, &ad);
+       rc = smk_bu_credfile(file->f_cred, file, MAY_READ, rc);
+
+       return rc;
+}
+
 #endif /* CONFIG_IO_URING */
 
 struct lsm_blob_sizes smack_blob_sizes __lsm_ro_after_init = {
@@ -4889,6 +4920,7 @@ static struct security_hook_list smack_hooks[] __lsm_ro_after_init = {
 #ifdef CONFIG_IO_URING
        LSM_HOOK_INIT(uring_override_creds, smack_uring_override_creds),
        LSM_HOOK_INIT(uring_sqpoll, smack_uring_sqpoll),
+       LSM_HOOK_INIT(uring_cmd, smack_uring_cmd),
 #endif
 };