Skip to content
  1. Apr 27, 2024
    • Kuniyuki Iwashima's avatar
      af_unix: Call manage_oob() for every skb in unix_stream_read_generic(). · a1d3e352
      Kuniyuki Iwashima authored
      [ Upstream commit 283454c8 ]
      
      When we call recv() for AF_UNIX socket, we first peek one skb and
      calls manage_oob() to check if the skb is sent with MSG_OOB.
      
      However, when we fetch the next (and the following) skb, manage_oob()
      is not called now, leading a wrong behaviour.
      
      Let's say a socket send()s "hello" with MSG_OOB and the peer tries
      to recv() 5 bytes with MSG_PEEK.  Here, we should get only "hell"
      without 'o', but actually not:
      
        >>> from socket import *
        >>> c1, c2 = socketpair(AF_UNIX, SOCK_STREAM)
        >>> c1.send(b'hello', MSG_OOB)
        5
        >>> c2.recv(5, MSG_PEEK)
        b'hello'
      
      The first skb fills 4 bytes, and the next skb is peeked but not
      properly checked by manage_oob().
      
      Let's move up the again label to call manage_oob() for evry skb.
      
      With this patch:
      
        >>> from socket import *
        >>> c1, c2 = socketpair(AF_UNIX, SOCK_STREAM)
        >>> c1.send(b'hello', MSG_OOB)
        5
        >>> c2.recv(5, MSG_PEEK)
        b'hell'
      
      Fixes: 314001f0
      
       ("af_unix: Add OOB support")
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Link: https://lore.kernel.org/r/20240410171016.7621-2-kuniyu@amazon.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a1d3e352
    • Pablo Neira Ayuso's avatar
      netfilter: flowtable: incorrect pppoe tuple · f1c3c617
      Pablo Neira Ayuso authored
      [ Upstream commit 6db5dc7b ]
      
      pppoe traffic reaching ingress path does not match the flowtable entry
      because the pppoe header is expected to be at the network header offset.
      This bug causes a mismatch in the flow table lookup, so pppoe packets
      enter the classical forwarding path.
      
      Fixes: 72efd585
      
       ("netfilter: flowtable: add pppoe support")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f1c3c617
    • Pablo Neira Ayuso's avatar
      netfilter: flowtable: validate pppoe header · 8bf7c76a
      Pablo Neira Ayuso authored
      [ Upstream commit 87b3593b
      
       ]
      
      Ensure there is sufficient room to access the protocol field of the
      PPPoe header. Validate it once before the flowtable lookup, then use a
      helper function to access protocol field.
      
      Reported-by: default avatar <syzbot+b6f07e1c07ef40199081@syzkaller.appspotmail.com>
      Fixes: 72efd585
      
       ("netfilter: flowtable: add pppoe support")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8bf7c76a
    • Florian Westphal's avatar
      netfilter: nft_set_pipapo: do not free live element · 41d8fdf3
      Florian Westphal authored
      [ Upstream commit 3cfc9ec0 ]
      
      Pablo reports a crash with large batches of elements with a
      back-to-back add/remove pattern.  Quoting Pablo:
      
        add_elem("00000000") timeout 100 ms
        ...
        add_elem("0000000X") timeout 100 ms
        del_elem("0000000X") <---------------- delete one that was just added
        ...
        add_elem("00005000") timeout 100 ms
      
        1) nft_pipapo_remove() removes element 0000000X
        Then, KASAN shows a splat.
      
      Looking at the remove function there is a chance that we will drop a
      rule that maps to a non-deactivated element.
      
      Removal happens in two steps, first we do a lookup for key k and return the
      to-be-removed element and mark it as inactive in the next generation.
      Then, in a second step, the element gets removed from the set/map.
      
      The _remove function does not work correctly if we have more than one
      element that share the same key.
      
      This can happen if we insert an element into a set when the set already
      holds an element with same key, but the element mapping to the existing
      key has timed out or is not active in the next generation.
      
      In such case its possible that removal will unmap the wrong element.
      If this happens, we will leak the non-deactivated element, it becomes
      unreachable.
      
      The element that got deactivated (and will be freed later) will
      remain reachable in the set data structure, this can result in
      a crash when such an element is retrieved during lookup (stale
      pointer).
      
      Add a check that the fully matching key does in fact map to the element
      that we have marked as inactive in the deactivation step.
      If not, we need to continue searching.
      
      Add a bug/warn trap at the end of the function as well, the remove
      function must not ever be called with an invisible/unreachable/non-existent
      element.
      
      v2: avoid uneeded temporary variable (Stefano)
      
      Fixes: 3c4287f6
      
       ("nf_tables: Add set type for arbitrary concatenation of ranges")
      Reported-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Reviewed-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      41d8fdf3
    • Pablo Neira Ayuso's avatar
      netfilter: br_netfilter: skip conntrack input hook for promisc packets · b13db0d1
      Pablo Neira Ayuso authored
      [ Upstream commit 751de201 ]
      
      For historical reasons, when bridge device is in promisc mode, packets
      that are directed to the taps follow bridge input hook path. This patch
      adds a workaround to reset conntrack for these packets.
      
      Jianbo Liu reports warning splats in their test infrastructure where
      cloned packets reach the br_netfilter input hook to confirm the
      conntrack object.
      
      Scratch one bit from BR_INPUT_SKB_CB to annotate that this packet has
      reached the input hook because it is passed up to the bridge device to
      reach the taps.
      
      [   57.571874] WARNING: CPU: 1 PID: 0 at net/bridge/br_netfilter_hooks.c:616 br_nf_local_in+0x157/0x180 [br_netfilter]
      [   57.572749] Modules linked in: xt_MASQUERADE nf_conntrack_netlink nfnetlink iptable_nat xt_addrtype xt_conntrack nf_nat br_netfilter rpcsec_gss_krb5 auth_rpcgss oid_registry overlay rpcrdma rdma_ucm ib_iser libiscsi scsi_transport_isc si ib_umad rdma_cm ib_ipoib iw_cm ib_cm mlx5_ib ib_uverbs ib_core mlx5ctl mlx5_core
      [   57.575158] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 6.8.0+ #19
      [   57.575700] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
      [   57.576662] RIP: 0010:br_nf_local_in+0x157/0x180 [br_netfilter]
      [   57.577195] Code: fe ff ff 41 bd 04 00 00 00 be 04 00 00 00 e9 4a ff ff ff be 04 00 00 00 48 89 ef e8 f3 a9 3c e1 66 83 ad b4 00 00 00 04 eb 91 <0f> 0b e9 f1 fe ff ff 0f 0b e9 df fe ff ff 48 89 df e8 b3 53 47 e1
      [   57.578722] RSP: 0018:ffff88885f845a08 EFLAGS: 00010202
      [   57.579207] RAX: 0000000000000002 RBX: ffff88812dfe8000 RCX: 0000000000000000
      [   57.579830] RDX: ffff88885f845a60 RSI: ffff8881022dc300 RDI: 0000000000000000
      [   57.580454] RBP: ffff88885f845a60 R08: 0000000000000001 R09: 0000000000000003
      [   57.581076] R10: 00000000ffff1300 R11: 0000000000000002 R12: 0000000000000000
      [   57.581695] R13: ffff8881047ffe00 R14: ffff888108dbee00 R15: ffff88814519b800
      [   57.582313] FS:  0000000000000000(0000) GS:ffff88885f840000(0000) knlGS:0000000000000000
      [   57.583040] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   57.583564] CR2: 000000c4206aa000 CR3: 0000000103847001 CR4: 0000000000370eb0
      [   57.584194] DR0: 0000000000000000 DR1: 0000000000000000 DR2:
      0000000000000000
      [   57.584820] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7:
      0000000000000400
      [   57.585440] Call Trace:
      [   57.585721]  <IRQ>
      [   57.585976]  ? __warn+0x7d/0x130
      [   57.586323]  ? br_nf_local_in+0x157/0x180 [br_netfilter]
      [   57.586811]  ? report_bug+0xf1/0x1c0
      [   57.587177]  ? handle_bug+0x3f/0x70
      [   57.587539]  ? exc_invalid_op+0x13/0x60
      [   57.587929]  ? asm_exc_invalid_op+0x16/0x20
      [   57.588336]  ? br_nf_local_in+0x157/0x180 [br_netfilter]
      [   57.588825]  nf_hook_slow+0x3d/0xd0
      [   57.589188]  ? br_handle_vlan+0x4b/0x110
      [   57.589579]  br_pass_frame_up+0xfc/0x150
      [   57.589970]  ? br_port_flags_change+0x40/0x40
      [   57.590396]  br_handle_frame_finish+0x346/0x5e0
      [   57.590837]  ? ipt_do_table+0x32e/0x430
      [   57.591221]  ? br_handle_local_finish+0x20/0x20
      [   57.591656]  br_nf_hook_thresh+0x4b/0xf0 [br_netfilter]
      [   57.592286]  ? br_handle_local_finish+0x20/0x20
      [   57.592802]  br_nf_pre_routing_finish+0x178/0x480 [br_netfilter]
      [   57.593348]  ? br_handle_local_finish+0x20/0x20
      [   57.593782]  ? nf_nat_ipv4_pre_routing+0x25/0x60 [nf_nat]
      [   57.594279]  br_nf_pre_routing+0x24c/0x550 [br_netfilter]
      [   57.594780]  ? br_nf_hook_thresh+0xf0/0xf0 [br_netfilter]
      [   57.595280]  br_handle_frame+0x1f3/0x3d0
      [   57.595676]  ? br_handle_local_finish+0x20/0x20
      [   57.596118]  ? br_handle_frame_finish+0x5e0/0x5e0
      [   57.596566]  __netif_receive_skb_core+0x25b/0xfc0
      [   57.597017]  ? __napi_build_skb+0x37/0x40
      [   57.597418]  __netif_receive_skb_list_core+0xfb/0x220
      
      Fixes: 62e7151a
      
       ("netfilter: bridge: confirm multicast packets before passing them up the stack")
      Reported-by: default avatarJianbo Liu <jianbol@nvidia.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b13db0d1
    • Ziyang Xuan's avatar
      netfilter: nf_tables: Fix potential data-race in __nft_obj_type_get() · df7c0fb8
      Ziyang Xuan authored
      [ Upstream commit d78d867d ]
      
      nft_unregister_obj() can concurrent with __nft_obj_type_get(),
      and there is not any protection when iterate over nf_tables_objects
      list in __nft_obj_type_get(). Therefore, there is potential data-race
      of nf_tables_objects list entry.
      
      Use list_for_each_entry_rcu() to iterate over nf_tables_objects
      list in __nft_obj_type_get(), and use rcu_read_lock() in the caller
      nft_obj_type_get() to protect the entire type query process.
      
      Fixes: e5009240
      
       ("netfilter: nf_tables: add stateful objects")
      Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      df7c0fb8
    • Ziyang Xuan's avatar
      netfilter: nf_tables: Fix potential data-race in __nft_expr_type_get() · 8d56bad4
      Ziyang Xuan authored
      [ Upstream commit f969eb84 ]
      
      nft_unregister_expr() can concurrent with __nft_expr_type_get(),
      and there is not any protection when iterate over nf_tables_expressions
      list in __nft_expr_type_get(). Therefore, there is potential data-race
      of nf_tables_expressions list entry.
      
      Use list_for_each_entry_rcu() to iterate over nf_tables_expressions
      list in __nft_expr_type_get(), and use rcu_read_lock() in the caller
      nft_expr_type_get() to protect the entire type query process.
      
      Fixes: ef1f7df9
      
       ("netfilter: nf_tables: expression ops overloading")
      Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8d56bad4
    • Ard Biesheuvel's avatar
      x86/efistub: Remap kernel text read-only before dropping NX attribute · 408a43b6
      Ard Biesheuvel authored
      [ Commit 9c554610
      
       upstream ]
      
      Currently, the EFI stub invokes the EFI memory attributes protocol to
      strip any NX restrictions from the entire loaded kernel, resulting in
      all code and data being mapped read-write-execute.
      
      The point of the EFI memory attributes protocol is to remove the need
      for all memory allocations to be mapped with both write and execute
      permissions by default, and make it the OS loader's responsibility to
      transition data mappings to code mappings where appropriate.
      
      Even though the UEFI specification does not appear to leave room for
      denying memory attribute changes based on security policy, let's be
      cautious and avoid relying on the ability to create read-write-execute
      mappings. This is trivially achievable, given that the amount of kernel
      code executing via the firmware's 1:1 mapping is rather small and
      limited to the .head.text region. So let's drop the NX restrictions only
      on that subregion, but not before remapping it as read-only first.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      408a43b6
    • Ard Biesheuvel's avatar
      x86/sev: Move early startup code into .head.text section · f56faf87
      Ard Biesheuvel authored
      [ Commit 428080c9
      
       upstream ]
      
      In preparation for implementing rigorous build time checks to enforce
      that only code that can support it will be called from the early 1:1
      mapping of memory, move SEV init code that is called in this manner to
      the .head.text section.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Tested-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
      Link: https://lore.kernel.org/r/20240227151907.387873-19-ardb+git@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f56faf87
    • Ard Biesheuvel's avatar
      x86/sme: Move early SME kernel encryption handling into .head.text · d6f5bc5f
      Ard Biesheuvel authored
      [ Commit 48204aba
      
       upstream ]
      
      The .head.text section is the initial primary entrypoint of the core
      kernel, and is entered with the CPU executing from a 1:1 mapping of
      memory. Such code must never access global variables using absolute
      references, as these are based on the kernel virtual mapping which is
      not active yet at this point.
      
      Given that the SME startup code is also called from this early execution
      context, move it into .head.text as well. This will allow more thorough
      build time checks in the future to ensure that early startup code only
      uses RIP-relative references to global variables.
      
      Also replace some occurrences of __pa_symbol() [which relies on the
      compiler generating an absolute reference, which is not guaranteed] and
      an open coded RIP-relative access with RIP_REL_REF().
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Tested-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
      Link: https://lore.kernel.org/r/20240227151907.387873-18-ardb+git@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d6f5bc5f
    • Hou Wenlong's avatar
      x86/head/64: Move the __head definition to <asm/init.h> · e6489cc4
      Hou Wenlong authored
      [ Commit d2a285d6
      
       upstream ]
      
      Move the __head section definition to a header to widen its use.
      
      An upcoming patch will mark the code as __head in mem_encrypt_identity.c too.
      
      Signed-off-by: default avatarHou Wenlong <houwenlong.hwl@antgroup.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/0583f57977be184689c373fe540cbd7d85ca2047.1697525407.git.houwenlong.hwl@antgroup.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e6489cc4
    • Hou Wenlong's avatar
      x86/head/64: Add missing __head annotation to startup_64_load_idt() · bbcd0534
      Hou Wenlong authored
      [ Commit 7f6874ed
      
       upstream ]
      
      This function is currently only used in the head code and is only called
      from startup_64_setup_env(). Although it would be inlined by the
      compiler, it would be better to mark it as __head too in case it doesn't.
      
      Signed-off-by: default avatarHou Wenlong <houwenlong.hwl@antgroup.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/efcc5b5e18af880e415d884e072bf651c1fa7c34.1689130310.git.houwenlong.hwl@antgroup.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bbcd0534
    • Pasha Tatashin's avatar
      x86/mm: Remove P*D_PAGE_MASK and P*D_PAGE_SIZE macros · 20dc656b
      Pasha Tatashin authored
      [ Commit 82328227
      
       upstream ]
      
      Other architectures and the common mm/ use P*D_MASK, and P*D_SIZE.
      Remove the duplicated P*D_PAGE_MASK and P*D_PAGE_SIZE which are only
      used in x86/*.
      
      Signed-off-by: default avatarPasha Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Acked-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Link: https://lore.kernel.org/r/20220516185202.604654-1-tatashin@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      20dc656b
    • Ard Biesheuvel's avatar
      x86/efistub: Use 1:1 file:memory mapping for PE/COFF .compat section · d327e961
      Ard Biesheuvel authored
      [ Commit 1ad55cec upstream ]
      
      The .compat section is a dummy PE section that contains the address of
      the 32-bit entrypoint of the 64-bit kernel image if it is bootable from
      32-bit firmware (i.e., CONFIG_EFI_MIXED=y)
      
      This section is only 8 bytes in size and is only referenced from the
      loader, and so it is placed at the end of the memory view of the image,
      to avoid the need for padding it to 4k, which is required for sections
      appearing in the middle of the image.
      
      Unfortunately, this violates the PE/COFF spec, and even if most EFI
      loaders will work correctly (including the Tianocore reference
      implementation), PE loaders do exist that reject such images, on the
      basis that both the file and memory views of the file contents should be
      described by the section headers in a monotonically increasing manner
      without leaving any gaps.
      
      So reorganize the sections to avoid this issue. This results in a slight
      padding overhead (< 4k) which can be avoided if desired by disabling
      CONFIG_EFI_MIXED (which is only needed in rare cases these days)
      
      Fixes: 3e3eabe2
      
       ("x86/boot: Increase section and file alignment to 4k/512")
      Reported-by: default avatarMike Beaton <mjsbeaton@gmail.com>
      Link: https://lkml.kernel.org/r/CAHzAAWQ6srV6LVNdmfbJhOwhBw5ZzxxZZ07aHt9oKkfYAdvuQQ%40mail.gmail.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d327e961
    • Ard Biesheuvel's avatar
      x86/boot: Increase section and file alignment to 4k/512 · c4421279
      Ard Biesheuvel authored
      [ Commit 3e3eabe2
      
       upstream ]
      
      Align x86 with other EFI architectures, and increase the section
      alignment to the EFI page size (4k), so that firmware is able to honour
      the section permission attributes and map code read-only and data
      non-executable.
      
      There are a number of requirements that have to be taken into account:
      - the sign tools get cranky when there are gaps between sections in the
        file view of the image
      - the virtual offset of each section must be aligned to the image's
        section alignment
      - the file offset *and size* of each section must be aligned to the
        image's file alignment
      - the image size must be aligned to the section alignment
      - each section's virtual offset must be greater than or equal to the
        size of the headers.
      
      In order to meet all these requirements, while avoiding the need for
      lots of padding to accommodate the .compat section, the latter is placed
      at an arbitrary offset towards the end of the image, but aligned to the
      minimum file alignment (512 bytes). The space before the .text section
      is therefore distributed between the PE header, the .setup section and
      the .compat section, leaving no gaps in the file coverage, making the
      signing tools happy.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230915171623.655440-18-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c4421279
    • Ard Biesheuvel's avatar
      x86/boot: Split off PE/COFF .data section · 581f5d5e
      Ard Biesheuvel authored
      [ Commit 34951f3c
      
       upstream ]
      
      Describe the code and data of the decompressor binary using separate
      .text and .data PE/COFF sections, so that we will be able to map them
      using restricted permissions once we increase the section and file
      alignment sufficiently. This avoids the need for memory mappings that
      are writable and executable at the same time, which is something that
      is best avoided for security reasons.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230915171623.655440-17-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      581f5d5e
    • Ard Biesheuvel's avatar
      x86/boot: Drop PE/COFF .reloc section · 43b19205
      Ard Biesheuvel authored
      [ Commit fa575052
      
       upstream ]
      
      Ancient buggy EFI loaders may have required a .reloc section to be
      present at some point in time, but this has not been true for a long
      time so the .reloc section can just be dropped.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230915171623.655440-16-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      43b19205
    • Ard Biesheuvel's avatar
      x86/boot: Construct PE/COFF .text section from assembler · d03399c3
      Ard Biesheuvel authored
      [ Commit efa089e6
      
       upstream ]
      
      Now that the size of the setup block is visible to the assembler, it is
      possible to populate the PE/COFF header fields from the asm code
      directly, instead of poking the values into the binary using the build
      tool. This will make it easier to reorganize the section layout without
      having to tweak the build tool in lockstep.
      
      This change has no impact on the resulting bzImage binary.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230915171623.655440-15-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d03399c3
    • Ard Biesheuvel's avatar
      x86/boot: Derive file size from _edata symbol · 1fa0a214
      Ard Biesheuvel authored
      [ Commit aeb92067
      
       upstream ]
      
      Tweak the linker script so that the value of _edata represents the
      decompressor binary's file size rounded up to the appropriate alignment.
      This removes the need to calculate it in the build tool, and will make
      it easier to refer to the file size from the header directly in
      subsequent changes to the PE header layout.
      
      While adding _edata to the sed regex that parses the compressed
      vmlinux's symbol list, tweak the regex a bit for conciseness.
      
      This change has no impact on the resulting bzImage binary when
      configured with CONFIG_EFI_STUB=y.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230915171623.655440-14-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1fa0a214
    • Ard Biesheuvel's avatar
      x86/boot: Define setup size in linker script · 1c754c6e
      Ard Biesheuvel authored
      [ Commit 093ab258
      
       upstream ]
      
      The setup block contains the real mode startup code that is used when
      booting from a legacy BIOS, along with the boot_params/setup_data that
      is used by legacy x86 bootloaders to pass the command line and initial
      ramdisk parameters, among other things.
      
      The setup block also contains the PE/COFF header of the entire combined
      image, which includes the compressed kernel image, the decompressor and
      the EFI stub.
      
      This PE header describes the layout of the executable image in memory,
      and currently, the fact that the setup block precedes it makes it rather
      fiddly to get the right values into the right place in the final image.
      
      Let's make things a bit easier by defining the setup_size in the linker
      script so it can be referenced from the asm code directly, rather than
      having to rely on the build tool to calculate it. For the time being,
      add 64 bytes of fixed padding for the .reloc and .compat sections - this
      will be removed in a subsequent patch after the PE/COFF header has been
      reorganized.
      
      This change has no impact on the resulting bzImage binary when
      configured with CONFIG_EFI_MIXED=y.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230915171623.655440-13-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1c754c6e
    • Ard Biesheuvel's avatar
      x86/boot: Set EFI handover offset directly in header asm · f9d68334
      Ard Biesheuvel authored
      [ Commit eac95634
      
       upstream ]
      
      The offsets of the EFI handover entrypoints are available to the
      assembler when constructing the header, so there is no need to set them
      from the build tool afterwards.
      
      This change has no impact on the resulting bzImage binary.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230915171623.655440-12-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f9d68334
    • Ard Biesheuvel's avatar
      x86/boot: Grab kernel_info offset from zoffset header directly · e1380c92
      Ard Biesheuvel authored
      [ Commit 2e765c02
      
       upstream ]
      
      Instead of parsing zoffset.h and poking the kernel_info offset value
      into the header from the build tool, just grab the value directly in the
      asm file that describes this header.
      
      This change has no impact on the resulting bzImage binary.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230915171623.655440-11-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e1380c92
    • Ard Biesheuvel's avatar
      x86/boot: Drop references to startup_64 · 67b8dc50
      Ard Biesheuvel authored
      [ Commit b618d31f
      
       upstream ]
      
      The x86 boot image generation tool assign a default value to startup_64
      and subsequently parses the actual value from zoffset.h but it never
      actually uses the value anywhere. So remove this code.
      
      This change has no impact on the resulting bzImage binary.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230912090051.4014114-25-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      67b8dc50
    • Ard Biesheuvel's avatar
      x86/boot: Drop redundant code setting the root device · 33d38d9b
      Ard Biesheuvel authored
      [ Commit 7448e8e5 upstream ]
      
      The root device defaults to 0,0 and is no longer configurable at build
      time [0], so there is no need for the build tool to ever write to this
      field.
      
      [0] 079f85e6
      
       ("x86, build: Do not set the root_dev field in bzImage")
      
      This change has no impact on the resulting bzImage binary.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230912090051.4014114-23-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      33d38d9b
    • Ard Biesheuvel's avatar
      x86/boot: Omit compression buffer from PE/COFF image memory footprint · 5c3e92ad
      Ard Biesheuvel authored
      [ Commit 8eace5b3
      
       upstream ]
      
      Now that the EFI stub decompresses the kernel and hands over to the
      decompressed image directly, there is no longer a need to provide a
      decompression buffer as part of the .BSS allocation of the PE/COFF
      image. It also means the PE/COFF image can be loaded anywhere in memory,
      and setting the preferred image base is unnecessary. So drop the
      handling of this from the header and from the build tool.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230912090051.4014114-22-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c3e92ad
    • Ard Biesheuvel's avatar
      x86/boot: Remove the 'bugger off' message · f31f521a
      Ard Biesheuvel authored
      [ Commit 768171d7
      
       upstream ]
      
      Ancient (pre-2003) x86 kernels could boot from a floppy disk straight from
      the BIOS, using a small real mode boot stub at the start of the image
      where the BIOS would expect the boot record (or boot block) to appear.
      
      Due to its limitations (kernel size < 1 MiB, no support for IDE, USB or
      El Torito floppy emulation), this support was dropped, and a Linux aware
      bootloader is now always required to boot the kernel from a legacy BIOS.
      
      To smoothen this transition, the boot stub was not removed entirely, but
      replaced with one that just prints an error message telling the user to
      install a bootloader.
      
      As it is unlikely that anyone doing direct floppy boot with such an
      ancient kernel is going to upgrade to v6.5+ and expect that this boot
      method still works, printing this message is kind of pointless, and so
      it should be possible to remove the logic that emits it.
      
      Let's free up this space so it can be used to expand the PE header in a
      subsequent patch.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarH. Peter Anvin (Intel) <hpa@zytor.com>
      Link: https://lore.kernel.org/r/20230912090051.4014114-21-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f31f521a
    • Ard Biesheuvel's avatar
      x86/efi: Drop alignment flags from PE section headers · 0db16d1d
      Ard Biesheuvel authored
      [ Commit bfab35f5
      
       upstream ]
      
      The section header flags for alignment are documented in the PE/COFF
      spec as being applicable to PE object files only, not to PE executables
      such as the Linux bzImage, so let's drop them from the PE header.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230912090051.4014114-20-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0db16d1d
    • Ard Biesheuvel's avatar
      x86/efistub: Reinstate soft limit for initrd loading · 1800c962
      Ard Biesheuvel authored
      [ Commit decd347c upstream ]
      
      Commit
      
        8117961d ("x86/efi: Disregard setup header of loaded image")
      
      dropped the memcopy of the image's setup header into the boot_params
      struct provided to the core kernel, on the basis that EFI boot does not
      need it and should rely only on a single protocol to interface with the
      boot chain. It is also a prerequisite for being able to increase the
      section alignment to 4k, which is needed to enable memory protections
      when running in the boot services.
      
      So only the setup_header fields that matter to the core kernel are
      populated explicitly, and everything else is ignored. One thing was
      overlooked, though: the initrd_addr_max field in the setup_header is not
      used by the core kernel, but it is used by the EFI stub itself when it
      loads the initrd, where its default value of INT_MAX is used as the soft
      limit for memory allocation.
      
      This means that, in the old situation, the initrd was virtually always
      loaded in the lower 2G of memory, but now, due to initrd_addr_max being
      0x0, the initrd may end up anywhere in memory. This should not be an
      issue principle, as most systems can deal with this fine. However, it
      does appear to tickle some problems in older UEFI implementations, where
      the memory ends up being corrupted, resulting in errors when unpacking
      the initramfs.
      
      So set the initrd_addr_max field to INT_MAX like it was before.
      
      Fixes: 8117961d
      
       ("x86/efi: Disregard setup header of loaded image")
      Reported-by: default avatarRadek Podgorny <radek@podgorny.cz>
      Closes: https://lore.kernel.org/all/a99a831a-8ad5-4cb0-bff9-be637311f771@podgorny.cz
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1800c962
    • Ard Biesheuvel's avatar
      x86/efi: Disregard setup header of loaded image · f46e0e9f
      Ard Biesheuvel authored
      [ Commit 7e502622 upstream ]
      
      The native EFI entrypoint does not take a struct boot_params from the
      loader, but instead, it constructs one from scratch, using the setup
      header data placed at the start of the image.
      
      This setup header is placed in a way that permits legacy loaders to
      manipulate the contents (i.e., to pass the kernel command line or the
      address and size of an initial ramdisk), but EFI boot does not use it in
      that way - it only copies the contents that were placed there at build
      time, but EFI loaders will not (and should not) manipulate the setup
      header to configure the boot. (Commit 63bf28ce
      
       "efi: x86: Wipe
      setup_data on pure EFI boot" deals with some of the fallout of using
      setup_data in a way that breaks EFI boot.)
      
      Given that none of the non-zero values that are copied from the setup
      header into the EFI stub's struct boot_params are relevant to the boot
      now that the EFI stub no longer enters via the legacy decompressor, the
      copy can be omitted altogether.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230912090051.4014114-19-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f46e0e9f
    • Ard Biesheuvel's avatar
      x86/efi: Drop EFI stub .bss from .data section · f5603f9e
      Ard Biesheuvel authored
      [ Commit 5f51c5d0
      
       upstream ]
      
      Now that the EFI stub always zero inits its BSS section upon entry,
      there is no longer a need to place the BSS symbols carried by the stub
      into the .data section.
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20230912090051.4014114-18-ardb@google.com
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f5603f9e
    • Janusz Krzysztofik's avatar
      drm/i915/vma: Fix UAF on destroy against retire race · 704edc92
      Janusz Krzysztofik authored
      commit 0e45882c upstream.
      
      Object debugging tools were sporadically reporting illegal attempts to
      free a still active i915 VMA object when parking a GT believed to be idle.
      
      [161.359441] ODEBUG: free active (active state 0) object: ffff88811643b958 object type: i915_active hint: __i915_vma_active+0x0/0x50 [i915]
      [161.360082] WARNING: CPU: 5 PID: 276 at lib/debugobjects.c:514 debug_print_object+0x80/0xb0
      ...
      [161.360304] CPU: 5 PID: 276 Comm: kworker/5:2 Not tainted 6.5.0-rc1-CI_DRM_13375-g003f860e5577+ #1
      [161.360314] Hardware name: Intel Corporation Rocket Lake Client Platform/RocketLake S UDIMM 6L RVP, BIOS RKLSFWI1.R00.3173.A03.2204210138 04/21/2022
      [161.360322] Workqueue: i915-unordered __intel_wakeref_put_work [i915]
      [161.360592] RIP: 0010:debug_print_object+0x80/0xb0
      ...
      [161.361347] debug_object_free+0xeb/0x110
      [161.361362] i915_active_fini+0x14/0x130 [i915]
      [161.361866] release_references+0xfe/0x1f0 [i915]
      [161.362543] i915_vma_parked+0x1db/0x380 [i915]
      [161.363129] __gt_park+0x121/0x230 [i915]
      [161.363515] ____intel_wakeref_put_last+0x1f/0x70 [i915]
      
      That has been tracked down to be happening when another thread is
      deactivating the VMA inside __active_retire() helper, after the VMA's
      active counter has been already decremented to 0, but before deactivation
      of the VMA's object is reported to the object debugging tool.
      
      We could prevent from that race by serializing i915_active_fini() with
      __active_retire() via ref->tree_lock, but that wouldn't stop the VMA from
      being used, e.g. from __i915_vma_retire() called at the end of
      __active_retire(), after that VMA has been already freed by a concurrent
      i915_vma_destroy() on return from the i915_active_fini().  Then, we should
      rather fix the issue at the VMA level, not in i915_active.
      
      Since __i915_vma_parked() is called from __gt_park() on last put of the
      GT's wakeref, the issue could be addressed by holding the GT wakeref long
      enough for __active_retire() to complete before that wakeref is released
      and the GT parked.
      
      I believe the issue was introduced by commit d9393973 ("drm/i915:
      Remove the vma refcount") which moved a call to i915_active_fini() from
      a dropped i915_vma_release(), called on last put of the removed VMA kref,
      to i915_vma_parked() processing path called on last put of a GT wakeref.
      However, its visibility to the object debugging tool was suppressed by a
      bug in i915_active that was fixed two weeks later with commit e92eb246
      ("drm/i915/active: Fix missing debug object activation").
      
      A VMA associated with a request doesn't acquire a GT wakeref by itself.
      Instead, it depends on a wakeref held directly by the request's active
      intel_context for a GT associated with its VM, and indirectly on that
      intel_context's engine wakeref if the engine belongs to the same GT as the
      VMA's VM.  Those wakerefs are released asynchronously to VMA deactivation.
      
      Fix the issue by getting a wakeref for the VMA's GT when activating it,
      and putting that wakeref only after the VMA is deactivated.  However,
      exclude global GTT from that processing path, otherwise the GPU never goes
      idle.  Since __i915_vma_retire() may be called from atomic contexts, use
      async variant of wakeref put.  Also, to avoid circular locking dependency,
      take care of acquiring the wakeref before VM mutex when both are needed.
      
      v7: Add inline comments with justifications for:
          - using untracked variants of intel_gt_pm_get/put() (Nirmoy),
          - using async variant of _put(),
          - not getting the wakeref in case of a global GTT,
          - always getting the first wakeref outside vm->mutex.
      v6: Since __i915_vma_active/retire() callbacks are not serialized, storing
          a wakeref tracking handle inside struct i915_vma is not safe, and
          there is no other good place for that.  Use untracked variants of
          intel_gt_pm_get/put_async().
      v5: Replace "tile" with "GT" across commit description (Rodrigo),
        - avoid mentioning multi-GT case in commit description (Rodrigo),
        - explain why we need to take a temporary wakeref unconditionally inside
          i915_vma_pin_ww() (Rodrigo).
      v4: Refresh on top of commit 5e4e06e4 ("drm/i915: Track gt pm
          wakerefs") (Andi),
        - for more easy backporting, split out removal of former insufficient
          workarounds and move them to separate patches (Nirmoy).
        - clean up commit message and description a bit.
      v3: Identify root cause more precisely, and a commit to blame,
        - identify and drop former workarounds,
        - update commit message and description.
      v2: Get the wakeref before VM mutex to avoid circular locking dependency,
        - drop questionable Fixes: tag.
      
      Fixes: d9393973
      
       ("drm/i915: Remove the vma refcount")
      Closes: https://gitlab.freedesktop.org/drm/intel/issues/8875
      Signed-off-by: default avatarJanusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
      Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
      Cc: Nirmoy Das <nirmoy.das@intel.com>
      Cc: Andi Shyti <andi.shyti@linux.intel.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: stable@vger.kernel.org # v5.19+
      Reviewed-by: default avatarNirmoy Das <nirmoy.das@intel.com>
      Signed-off-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240305143747.335367-6-janusz.krzysztofik@linux.intel.com
      (cherry picked from commit f3c71b2d
      
      )
      Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: default avatarJanusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      704edc92
    • Jose Ignacio Tornos Martinez's avatar
      net: usb: ax88179_178a: avoid writing the mac address before first reading · add0ff34
      Jose Ignacio Tornos Martinez authored
      commit 56f78615 upstream.
      
      After the commit d2689b6a ("net: usb: ax88179_178a: avoid two
      consecutive device resets"), reset operation, in which the default mac
      address from the device is read, is not executed from bind operation and
      the random address, that is pregenerated just in case, is direclty written
      the first time in the device, so the default one from the device is not
      even read. This writing is not dangerous because is volatile and the
      default mac address is not missed.
      
      In order to avoid this and keep the simplification to have only one
      reset and reduce the delays, restore the reset from bind operation and
      remove the reset that is commanded from open operation. The behavior is
      the same but everything is ready for usbnet_probe.
      
      Tested with ASIX AX88179 USB Gigabit Ethernet devices.
      Restore the old behavior for the rest of possible devices because I don't
      have the hardware to test.
      
      cc: stable@vger.kernel.org # 6.6+
      Fixes: d2689b6a
      
       ("net: usb: ax88179_178a: avoid two consecutive device resets")
      Reported-by: default avatarJarkko Palviainen <jarkko.palviainen@gmail.com>
      Signed-off-by: default avatarJose Ignacio Tornos Martinez <jtornosm@redhat.com>
      Link: https://lore.kernel.org/r/20240417085524.219532-1-jtornosm@redhat.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      add0ff34
    • Jason A. Donenfeld's avatar
      random: handle creditable entropy from atomic process context · 07b37f22
      Jason A. Donenfeld authored
      commit e871abcd
      
       upstream.
      
      The entropy accounting changes a static key when the RNG has
      initialized, since it only ever initializes once. Static key changes,
      however, cannot be made from atomic context, so depending on where the
      last creditable entropy comes from, the static key change might need to
      be deferred to a worker.
      
      Previously the code used the execute_in_process_context() helper
      function, which accounts for whether or not the caller is
      in_interrupt(). However, that doesn't account for the case where the
      caller is actually in process context but is holding a spinlock.
      
      This turned out to be the case with input_handle_event() in
      drivers/input/input.c contributing entropy:
      
        [<ffffffd613025ba0>] die+0xa8/0x2fc
        [<ffffffd613027428>] bug_handler+0x44/0xec
        [<ffffffd613016964>] brk_handler+0x90/0x144
        [<ffffffd613041e58>] do_debug_exception+0xa0/0x148
        [<ffffffd61400c208>] el1_dbg+0x60/0x7c
        [<ffffffd61400c000>] el1h_64_sync_handler+0x38/0x90
        [<ffffffd613011294>] el1h_64_sync+0x64/0x6c
        [<ffffffd613102d88>] __might_resched+0x1fc/0x2e8
        [<ffffffd613102b54>] __might_sleep+0x44/0x7c
        [<ffffffd6130b6eac>] cpus_read_lock+0x1c/0xec
        [<ffffffd6132c2820>] static_key_enable+0x14/0x38
        [<ffffffd61400ac08>] crng_set_ready+0x14/0x28
        [<ffffffd6130df4dc>] execute_in_process_context+0xb8/0xf8
        [<ffffffd61400ab30>] _credit_init_bits+0x118/0x1dc
        [<ffffffd6138580c8>] add_timer_randomness+0x264/0x270
        [<ffffffd613857e54>] add_input_randomness+0x38/0x48
        [<ffffffd613a80f94>] input_handle_event+0x2b8/0x490
        [<ffffffd613a81310>] input_event+0x6c/0x98
      
      According to Guoyong, it's not really possible to refactor the various
      drivers to never hold a spinlock there. And in_atomic() isn't reliable.
      
      So, rather than trying to be too fancy, just punt the change in the
      static key to a workqueue always. There's basically no drawback of doing
      this, as the code already needed to account for the static key not
      changing immediately, and given that it's just an optimization, there's
      not exactly a hurry to change the static key right away, so deferal is
      fine.
      
      Reported-by: default avatarGuoyong Wang <guoyong.wang@mediatek.com>
      Cc: stable@vger.kernel.org
      Fixes: f5bda35f
      
       ("random: use static branch for crng_ready()")
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      07b37f22
    • Yuanhe Shu's avatar
      selftests/ftrace: Limit length in subsystem-enable tests · bcdd9ce7
      Yuanhe Shu authored
      commit 1a4ea83a upstream.
      
      While sched* events being traced and sched* events continuously happen,
      "[xx] event tracing - enable/disable with subsystem level files" would
      not stop as on some slower systems it seems to take forever.
      Select the first 100 lines of output would be enough to judge whether
      there are more than 3 types of sched events.
      
      Fixes: 815b18ea
      
       ("ftracetest: Add basic event tracing test cases")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarYuanhe Shu <xiangzao@linux.alibaba.com>
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Acked-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bcdd9ce7
    • Steven Rostedt (Google)'s avatar
      SUNRPC: Fix rpcgss_context trace event acceptor field · 45eec81e
      Steven Rostedt (Google) authored
      commit a4833e3a upstream.
      
      The rpcgss_context trace event acceptor field is a dynamically sized
      string that records the "data" parameter. But this parameter is also
      dependent on the "len" field to determine the size of the data.
      
      It needs to use __string_len() helper macro where the length can be passed
      in. It also incorrectly uses strncpy() to save it instead of
      __assign_str(). As these macros can change, it is not wise to open code
      them in trace events.
      
      As of commit c759e609 ("tracing: Remove __assign_str_len()"),
      __assign_str() can be used for both __string() and __string_len() fields.
      Before that commit, __assign_str_len() is required to be used. This needs
      to be noted for backporting. (In actuality, commit c1fa617c ("tracing:
      Rework __assign_str() and __string() to not duplicate getting the string")
      is the commit that makes __string_str_len() obsolete).
      
      Cc: stable@vger.kernel.org
      Fixes: 0c77668d
      
       ("SUNRPC: Introduce trace points in rpc_auth_gss.ko")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45eec81e
    • Alexey Izbyshev's avatar
      io_uring: Fix io_cqring_wait() not restoring sigmask on get_timespec64() failure · cbe7b911
      Alexey Izbyshev authored
      Commit 978e5c19 upstream.
      
      This bug was introduced in commit 950e79dd ("io_uring: minor
      io_cqring_wait() optimization"), which was made in preparation for
      adc8682e ("io_uring: Add support for napi_busy_poll"). The latter
      got reverted in cb318216 ("Revert "io_uring: Add support for
      napi_busy_poll""), so simply undo the former as well.
      
      Cc: stable@vger.kernel.org
      Fixes: 950e79dd
      
       ("io_uring: minor io_cqring_wait() optimization")
      Signed-off-by: default avatarAlexey Izbyshev <izbyshev@ispras.ru>
      Link: https://lore.kernel.org/r/20240405125551.237142-1-izbyshev@ispras.ru
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cbe7b911
    • Dillon Varone's avatar
      drm/amd/display: Do not recursively call manual trigger programming · 121a83be
      Dillon Varone authored
      [ Upstream commit 95392758
      
       ]
      
      [WHY&HOW]
      We should not be recursively calling the manual trigger programming function when
      FAMS is not in use.
      
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarAlvin Lee <alvin.lee2@amd.com>
      Acked-by: default avatarHamza Mahfooz <hamza.mahfooz@amd.com>
      Signed-off-by: default avatarDillon Varone <dillon.varone@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      121a83be
    • Tim Huang's avatar
      drm/amdgpu: fix incorrect number of active RBs for gfx11 · 01c227f5
      Tim Huang authored
      [ Upstream commit bbca7f41
      
       ]
      
      The RB bitmap should be global active RB bitmap &
      active RB bitmap based on active SA.
      
      Signed-off-by: default avatarTim Huang <Tim.Huang@amd.com>
      Reviewed-by: default avatarYifan Zhang <yifan1.zhang@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      01c227f5
    • Hawking Zhang's avatar
      drm/amdgpu: fix incorrect active rb bitmap for gfx11 · 87f8aac7
      Hawking Zhang authored
      [ Upstream commit f9c35f4f
      
       ]
      
      GFX v11 changes RB_BACKEND_DISABLE related registers
      from per SA to global ones. The approach to query active
      rb bitmap needs to be changed accordingly. Query per
      SE setting returns wrong active RB bitmap especially
      in the case when some of SA are disabled. With the new
      approach, driver will generate the active rb bitmap
      based on active SA bitmap and global active RB bitmap.
      
      Signed-off-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
      Reviewed-by: default avatarLikun Gao <Likun.Gao@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Stable-dep-of: bbca7f41
      
       ("drm/amdgpu: fix incorrect number of active RBs for gfx11")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      87f8aac7
    • Zack Rusin's avatar
      drm/vmwgfx: Enable DMA mappings with SEV · 1e053399
      Zack Rusin authored
      [ Upstream commit 4c08f019 ]
      
      Enable DMA mappings in vmwgfx after TTM has been fixed in commit
      3bf3710e
      
       ("drm/ttm: Add a generic TTM memcpy move for page-based iomem")
      
      This enables full guest-backed memory support and in particular allows
      usage of screen targets as the presentation mechanism.
      
      Signed-off-by: default avatarZack Rusin <zack.rusin@broadcom.com>
      Reported-by: default avatarYe Li <ye.li@broadcom.com>
      Tested-by: default avatarYe Li <ye.li@broadcom.com>
      Fixes: 3b0d6458
      
       ("drm/vmwgfx: Refuse DMA operation when SEV encryption is active")
      Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
      Cc: dri-devel@lists.freedesktop.org
      Cc: <stable@vger.kernel.org> # v6.6+
      Reviewed-by: default avatarMartin Krastev <martin.krastev@broadcom.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240408022802.358641-1-zack.rusin@broadcom.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1e053399