Skip to contentSkip to conversation

6.18.65-rc1 review

PATCH In review Greg Kroah-Hartman 12 participants 2,163 messages Nov 18 – Nov 20 Stable branch Page 17 of 17

lore
Share & tools
lore
author maintainer
#2105 lore raw

PATCH 2103/2151 eth: bnxt: resize Rx head buffers when rx-copybreak changes

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jakub Kicinski <[email protected]>

[ Upstream commit 09f10efee6f93863ea71489ce84563f4d51787f6 ]

Since rx-copybreak became configurable, bnxt_set_ring_params() sizes the head buffers to fit at least rx_copybreak bytes, and the copybreak path in bnxt_copy_data() syncs rx_copybreak bytes of the head buffer. bnxt_set_tunable() however only updates bp->rx_copybreak, and nothing on the open path recalculates the ring parameters. After raising rx-copybreak the head buffers keep their old size until some other setting changes, and bnxt_copy_data() syncs past their end, into the next buffer in the page or past the end of the page:

DMA-API: bnxt_en 0000:01:00.0: device driver tries to sync DMA memory it has not allocated [device address=0x00000002aa210c40] [size=1024 bytes]

  WARNING: kernel/dma/debug.c:1162 at check_sync+0x577/0x1eb0, CPU#22: swapper/22/0
  Call Trace:
   <IRQ>
   debug_dma_sync_single_for_cpu+0x66/0x90
   bnxt_copy_data+0x12f/0x290
   bnxt_rx_pkt+0x24ea/0x50f0
   __bnxt_poll_work+0x42c/0xc00
   bnxt_poll_p5+0x579/0x17a0
   __napi_poll+0x8b/0x2c0
   net_rx_action+0x58f/0xbb0

Here the head buffers were still sized for the 640B HDS threshold, four 1kB buffers per page, while rx-copybreak was raised to 1024. Without coherent DMA or with swiotlb the oversized sync can corrupt a neighboring buffer owned by the device or by an skb.

The device must be down for rx-copybreak to change, so recalculate the ring parameters right away, like bnxt_set_ringparam() does.

Hit while testing patch 1, tested on BCM57504 - boot; set rx-copybreak to 1024 with the link down (CONFIG_DMA_API_DEBUG); ifup.

Fixes 152f4da05aee ("bnxt_en: add support for rx-copybreak ethtool command")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +1 -0
index 2dc9708fb63f6..8181d1bdca028 100644
@@ -4445,6 +4445,7 @@ static int bnxt_set_tunable(struct net_device *dev,
 			if (netif_running(dev))
 				return -EBUSY;
 			bp->rx_copybreak = rx_copybreak;
+			bnxt_set_ring_params(bp);
 		}
 		return 0;
 	case ETHTOOL_PFC_PREVENTION_TOUT:
Signature · 1 line
2.53.0
author maintainer
#2106 lore raw

PATCH 2104/2151 eth: bnxt: dont leak buffers when XDP agg buffer allocation fails

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jakub Kicinski <[email protected]>

[ Upstream commit 1b2f02fb4ba92d01603c8261c94be8d348de65b0 ]

If a replacement agg buffer can't be allocated for a packet received with XDP attached, bnxt_rx_pkt() drops the packet without returning its head buffer to the ring. The head buffer leaks, and since rx_prod still advances, the device gets a BD with a stale DMA address which points at a buffer the driver no longer owns. When that BD completes the driver finds no buffer in the slot.

The agg buffers consumed before the failing one have already been replaced on the agg ring, they are referenced only by the frags of the xdp_buff, which nobody frees. bnxt_xdp_buff_frags_free() would skip them since the frags flag is set only on success, so set it upfront.

Pointed out in LLM review of the first patch of the series. Tested on a BCM57504 at MTU 9000 with a frags-capable XDP_PASS program, receiving 8000B ICMPv6 echo requests (a head and two agg buffers each) while page_pool_alloc_netmems() called from bnxt_rx_agg_netmems_xdp() failed half of the time (bpftrace override()). 44.7k packets were dropped, the page pools' inflight count stayed flat and there were no KASAN or DEBUG_PAGEALLOC splats.

Fixes 4c6c123c9af9 ("bnxt: adding bnxt_rx_agg_pages_xdp for aggregated xdp")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +11 -6
index 6e8e316165137..49016042d324e 100644
@@ -1372,16 +1372,19 @@ static u32 bnxt_rx_agg_netmems_xdp(struct bnxt *bp,
 	struct skb_shared_info *shinfo = xdp_get_shared_info_from_buff(xdp);
 	u32 total_frag_len = 0;
 
-	if (!xdp_buff_has_frags(xdp))
+	if (!xdp_buff_has_frags(xdp)) {
+		xdp_buff_set_frags_flag(xdp);
 		shinfo->nr_frags = 0;
+	}
 
 	total_frag_len = __bnxt_rx_agg_netmems(bp, cpr, idx, agg_bufs, tpa,
 					       NULL, xdp);
-	if (total_frag_len) {
-		xdp_buff_set_frags_flag(xdp);
-		shinfo->nr_frags = agg_bufs;
-		shinfo->xdp_frags_size = total_frag_len;
+	if (!total_frag_len) {
+		bnxt_xdp_buff_frags_free(cpr->bnapi->rx_ring, xdp);
+		return 0;
 	}
+	shinfo->nr_frags = agg_bufs;
+	shinfo->xdp_frags_size = total_frag_len;
 	return total_frag_len;
 }
 
@@ -2253,8 +2256,10 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
 							       cp_cons,
 							       agg_bufs,
 							       false);
-			if (!frag_len)
+			if (!frag_len) {
+				bnxt_reuse_rx_data(rxr, cons, data);
 				goto oom_next_rx;
+			}
 
 		}
 		xdp_active = true;
Signature · 1 line
2.53.0
author maintainer
#2107 lore raw

PATCH 2105/2151 eth: bnxt: free XDP frags when xdp_do_redirect() fails

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jakub Kicinski <[email protected]>

[ Upstream commit c10f3420d59859df107838aa97b49357616d9b47 ]

When xdp_do_redirect() fails bnxt_rx_xdp() recycles the head page but not the frags of a multi-buffer frame. Their agg ring slots have already been refilled, so the pages leak, and the page pool can't be destroyed until they are returned, which will never happen. Redirect to an AF_XDP socket in copy mode fails this way with -ENOMEM whenever the socket's fill ring runs out of buffers.
A socket bound without XDP_USE_SG also fails with -ENOSPC for every frame that doesn't fit in a single chunk.

All the other drop paths in this function free the frags.

Pointed out in LLM review of the first patch of the series. Tested on a BCM57504 at MTU 9000 by redirecting 60k 8000B ICMPv6 echo requests (a head and two agg buffers each) to lo, which can't transmit XDP frames. The page pools' inflight count stayed flat rather than growing by two pages per frame.

Fixes a7559bc8c17c ("bnxt: support transmit and free of aggregation buffers")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +1 -0
index 2db8cfcf922f3..52563b9489809 100644
@@ -307,6 +307,7 @@ bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons,
 
 		if (xdp_do_redirect(bp->dev, xdp, xdp_prog)) {
 			trace_xdp_exception(bp->dev, xdp_prog, act);
+			bnxt_xdp_buff_frags_free(rxr, xdp);
 			page_pool_recycle_direct(rxr->page_pool, page);
 			return true;
 		}
Signature · 1 line
2.53.0
author maintainer
#2108 lore raw

PATCH 2106/2151 eth: bnxt: hand XDP frags over to the copybreak skb

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jakub Kicinski <[email protected]>

[ Upstream commit 364b88b54fc260d22ee318bae862c2d7d8c31dc6 ]

With a multi-buffer XDP program attached, a packet only has agg buffers if it filled its head buffer, which in page mode holds most of a page. The program can still move the start of the packet forward with bpf_xdp_adjust_head() and leave at most rx_copybreak bytes in the head. bnxt_rx_pkt() then copies the head into a new skb, puts the head page back on the ring, and calls bnxt_xdp_build_skb() on the copy. bnxt_xdp_build_skb() only sets nr_frags and the skb's length accounting, because it expects an skb built around the head page, sharing its shinfo with the xdp_buff. The copy ends up with nr_frags set but no frag descriptors, and the stack later reads and releases whatever its frags array happens to contain. The real frags leak.

Copy the frag descriptors to the new skb in bnxt_copy_xdp(), so that bnxt_xdp_build_skb() finds the frags where it expects them. The frags now belong to the skb, and the head page goes back on the ring as before.

Pointed out in LLM review of the first patch of the series. Confirmed by reading the code, the unfixed kernel was not run with the reproducer below.
Tested on a BCM57504 at MTU 9000 with rx-copybreak raised to 1024 and a frags-capable XDP program moving the start of multi-buffer frames 3000B forward with bpf_xdp_adjust_head(), receiving 8000B ICMPv6 echo requests (a head and two agg buffers each). All 60k frames took the copybreak path with frags attached, the sampled skbs reached GRO with len=4998 data_len=4492 nr_frags=2, and were freed by the stack with the page pools' inflight count staying flat, no KASAN or DEBUG_PAGEALLOC splats.

Fixes 1dc4c557bfed ("bnxt: adding bnxt_xdp_build_skb to build skb from multibuffer xdp_buff")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +8 -0
index 49016042d324e..414da981a3e5b 100644
@@ -1456,6 +1456,14 @@ static struct sk_buff *bnxt_copy_xdp(struct bnxt_napi *bnapi,
 		__skb_pull(skb, metasize);
 	}
 
+	if (unlikely(xdp_buff_has_frags(xdp))) {
+		struct skb_shared_info *sinfo;
+
+		sinfo = xdp_get_shared_info_from_buff(xdp);
+		memcpy(skb_shinfo(skb)->frags, sinfo->frags,
+		       sinfo->nr_frags * sizeof(skb_frag_t));
+	}
+
 	return skb;
 }
 
Signature · 1 line
2.53.0
author maintainer
#2109 lore raw

PATCH 2107/2151 gro: do not GRO GSO packets with inconsistent payload

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kyle Zeng <[email protected]>

[ Upstream commit de788d8a7032475f900c16e9cc0c1417f4f719eb ]

tcp_gro_receive() excludes empty non-GSO packets with the unsigned len - 1 check, but its GSO branch only checks that gso_size matches the held packet's MSS. A trusted TCP GSO skb can reach GRO again with no payload after TC pedit increases its TCP data offset.

If the skb is fully linear, skb_gro_receive() then enters its fragment transfer path with nr_frags == 0. The do-while loop copies skb_frag_t entries backwards beyond both fragment arrays. An unprivileged process using its own user and network namespaces can trigger a KASAN slab-out-of-bounds write and panic through veth, pedit and GRE.

More generally, the payload of such a packet can be shrunk to any value, making it inconsistent with its gso_segs, and a GSO packet with gso_segs == 0 contributes no segment to the GRO packet.

Do not aggregate GSO packets with gso_segs == 0, and require the payload of GSO packets to be consistent with gso_segs and gso_size, the last segment being allowed to be short. This rejects the empty skb before either TCP merge helper, and covers both IPv4 and IPv6.

Fixes 5eddb24901ee ("gro: add support of (hw)gro packets to gro stack")
[edumazet: check payload against gso_segs, refuse gso_segs == 0]
---
 net/core/gro.c         |  5 +++--
 net/ipv4/tcp_offload.c | 12 +++++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)
net/core/gro.c +3 -2
index f96e5024758e2..a7b3fdc1f7bae 100644
@@ -518,9 +518,10 @@ static enum gro_result dev_gro_receive(struct gro_node *gro,
 	NAPI_GRO_CB(skb)->count = 1;
 	if (unlikely(skb_is_gso(skb))) {
 		NAPI_GRO_CB(skb)->count = skb_shinfo(skb)->gso_segs;
-		/* Only support TCP and non DODGY users. */
+		/* Only support TCP and non DODGY users, with a sane gso_segs. */
 		if (!skb_is_gso_tcp(skb) ||
-		    (skb_shinfo(skb)->gso_type & SKB_GSO_DODGY))
+		    (skb_shinfo(skb)->gso_type & SKB_GSO_DODGY) ||
+		    !NAPI_GRO_CB(skb)->count)
 			NAPI_GRO_CB(skb)->flush = 1;
 	}
 
net/ipv4/tcp_offload.c +9 -3
index 3ae6b4e0763c0..d405159967125 100644
@@ -343,14 +343,20 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb,
 
 	mss = skb_shinfo(p)->gso_size;
 
-	/* If skb is a GRO packet, make sure its gso_size matches prior packet mss.
+	/* If skb is a GRO packet, make sure its gso_size matches prior packet
+	 * mss, and that its payload is consistent with its gso_segs
+	 * (the last segment can be short).
 	 * If it is a single frame, do not aggregate it if its length
 	 * is bigger than our mss.
 	 */
-	if (unlikely(skb_is_gso(skb)))
+	if (unlikely(skb_is_gso(skb))) {
+		unsigned int segs = NAPI_GRO_CB(skb)->count;
+
 		flush |= (mss != skb_shinfo(skb)->gso_size);
-	else
+		flush |= len <= (segs - 1) * mss || len > segs * mss;
+	} else {
 		flush |= (len - 1) >= mss;
+	}
 
 	flush |= (ntohl(th2->seq) + skb_gro_len(p)) ^ ntohl(th->seq);
 	flush |= skb_cmp_decrypted(p, skb);
Signature · 1 line
2.53.0
author maintainer
#2110 lore raw

PATCH 2108/2151 net: bgmac: fix TX DMA unmapping and slot cleanup

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Rosen Penev <[email protected]>

[ Upstream commit 4f45e97b3aac2282f2b436d97338c9c2c484d093 ]

When mapping a fragment fails, bgmac_dma_tx_add() unwinds with the wrong slots. It passes the failed fragment's slot->dma_addr, which holds the mapping error, to dma_unmap_single() for the head. The fragment loop indexes from ring->end instead of ring->end + 1, so it unmaps the head a second time as a page and leaves the last mapped fragment mapped. None of the affected slots get their dma_addr cleared either, which includes the head slot when mapping the head fails.

bgmac_dma_tx_ring_free() unmaps every slot with a non-zero dma_addr, so tearing down the ring unmaps these addresses again. It also frees the skbs of pending TX slots but leaves slot->skb and slot->dma_addr set. The slots survive a down/up cycle, and bgmac_dma_tx_add() only sets slot->skb on the last slot of a packet. If a slot with a stale pointer is later used for the head or a fragment of a scatter/gather packet, bgmac_dma_tx_free() frees the old skb a second time when that slot completes.

bgmac_dma_tx_ring_free() also picks dma_unmap_single() or dma_unmap_page() by looking at slot->skb, which is set on the last slot of a packet, while the head was mapped with dma_map_single() and the fragments with skb_frag_dma_map().

In the error path, unmap the head and each mapped fragment from their own slots, and clear dma_addr on every slot the failed packet touched. In bgmac_dma_tx_ring_free(), choose the unmap function by the SOF flag of the descriptor like bgmac_dma_tx_free() does, unmap every slot before freeing any skb, since a packet can wrap around the end of the ring with its skb on the last slot, and clear both fields.

This was found through code inspection by an LLM while hitting other bugs on an Asus RT-N16. It did not hit these ones specifically.

---
 drivers/net/ethernet/broadcom/bgmac.c | 47 +++++++++++++++++----------
 1 file changed, 30 insertions(+), 17 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +30 -17
index 1835266fdd09f..b3f0ecc583fd5 100644
@@ -208,19 +208,24 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
 	return NETDEV_TX_OK;
 
 err_dma:
-	dma_unmap_single(dma_dev, slot->dma_addr, skb_headlen(skb),
-			 DMA_TO_DEVICE);
+	slot->dma_addr = 0;
 
 	while (i-- > 0) {
-		int index = (ring->end + i) % BGMAC_TX_RING_SLOTS;
-		struct bgmac_slot_info *slot = &ring->slots[index];
-		u32 ctl1 = le32_to_cpu(ring->cpu_base[index].ctl1);
-		int len = ctl1 & BGMAC_DESC_CTL1_LEN;
-
-		dma_unmap_page(dma_dev, slot->dma_addr, len, DMA_TO_DEVICE);
+		index = (ring->end + 1 + i) % BGMAC_TX_RING_SLOTS;
+		slot = &ring->slots[index];
+		dma_unmap_page(dma_dev, slot->dma_addr,
+			       skb_frag_size(&skb_shinfo(skb)->frags[i]),
+			       DMA_TO_DEVICE);
+		slot->dma_addr = 0;
 	}
 
+	slot = &ring->slots[ring->end % BGMAC_TX_RING_SLOTS];
+	dma_unmap_single(dma_dev, slot->dma_addr, skb_headlen(skb),
+			 DMA_TO_DEVICE);
+
 err_dma_head:
+	slot->dma_addr = 0;
+
 	netdev_err(bgmac->net_dev, "Mapping error of skb on ring 0x%X\n",
 		   ring->mmio_base);
 
@@ -535,17 +540,25 @@ static void bgmac_dma_tx_ring_free(struct bgmac *bgmac,
 		unsigned int len = ctl1 & BGMAC_DESC_CTL1_LEN;
 
 		slot = &ring->slots[i];
-		dev_kfree_skb(slot->skb);
 
-		if (!slot->dma_addr)
-			continue;
+		if (slot->dma_addr) {
+			if (le32_to_cpu(dma_desc[i].ctl0) & BGMAC_DESC_CTL0_SOF)
+				dma_unmap_single(dma_dev, slot->dma_addr,
+						 len, DMA_TO_DEVICE);
+			else
+				dma_unmap_page(dma_dev, slot->dma_addr,
+					       len, DMA_TO_DEVICE);
+			slot->dma_addr = 0;
+		}
+	}
 
-		if (slot->skb)
-			dma_unmap_single(dma_dev, slot->dma_addr,
-					 len, DMA_TO_DEVICE);
-		else
-			dma_unmap_page(dma_dev, slot->dma_addr,
-				       len, DMA_TO_DEVICE);
+	/* A packet can wrap around the end of the ring with its skb on the
+	 * last slot, so free the skbs only once every slot is unmapped.
+	 */
+	for (i = 0; i < BGMAC_TX_RING_SLOTS; i++) {
+		slot = &ring->slots[i];
+		dev_kfree_skb(slot->skb);
+		slot->skb = NULL;
 	}
 }
 
Signature · 1 line
2.53.0
author maintainer
#2111 lore raw

PATCH 2109/2151 tcp: avoid double destroy in tcp_abort() of an unaccepted child

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kyle Zeng <[email protected]>

[ Upstream commit dbd62ad55a4c898f5a4c9edb20c0c062afb799df ]

tcp_abort() checks for TCP_CLOSE while only owning the socket lock, then grabs the BH lock before calling tcp_done_with_error().

For a child still sitting in a listener accept queue (which can be reached via SOCK_DESTROY or bpf_sock_destroy()), inet_csk_listen_stop() can run in this window: it only holds the child BH lock, and calls inet_child_forget(), which disconnects, orphans and destroys the child.

tcp_abort() then calls tcp_done_with_error() -> tcp_done(), which sees SOCK_DEAD and calls inet_csk_destroy_sock() a second time, leading to a double sock_put() and a use-after-free.

Recheck TCP_CLOSE after acquiring the BH lock, unless we just closed a listener ourselves, in which case tcp_done_with_error() must still run to report the error.

Note that the WARN_ON(sock_owned_by_user(child)) in inet_csk_listen_stop() can still trigger in this window.

Fixes bac76cf89816 ("tcp: fix forever orphan socket caused by tcp_abort")
[edumazet: recheck TCP_CLOSE under the BH lock instead of moving the test, smaller diff]
---
 net/ipv4/tcp.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
net/ipv4/tcp.c +13 -1
index 11a78d4f9ae00..aa860cbd3a442 100644
@@ -5066,6 +5066,8 @@ EXPORT_SYMBOL_GPL(tcp_done);
 int tcp_abort(struct sock *sk, int err)
 {
 	int state = inet_sk_state_load(sk);
+	bool listener = false;
+	int ret = 0;
 
 	if (state == TCP_NEW_SYN_RECV) {
 		struct request_sock *req = inet_reqsk(sk);
@@ -5100,21 +5102,31 @@ int tcp_abort(struct sock *sk, int err)
 	if (sk->sk_state == TCP_LISTEN) {
 		tcp_set_state(sk, TCP_CLOSE);
 		inet_csk_listen_stop(sk);
+		listener = true;
 	}
 
 	/* Don't race with BH socket closes such as inet_csk_listen_stop. */
 	local_bh_disable();
 	bh_lock_sock(sk);
 
+	/* An unaccepted child might have been closed by
+	 * inet_csk_listen_stop() while we were not holding its BH lock.
+	 */
+	if (!listener && sk->sk_state == TCP_CLOSE) {
+		ret = -ENOENT;
+		goto out;
+	}
+
 	if (tcp_need_reset(sk->sk_state))
 		tcp_send_active_reset(sk, SK_RST_REASON_TCP_STATE);
 	tcp_done_with_error(sk, err);
 
+out:
 	bh_unlock_sock(sk);
 	local_bh_enable();
 	if (!has_current_bpf_ctx())
 		release_sock(sk);
-	return 0;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(tcp_abort);
 
Signature · 1 line
2.53.0
author maintainer
#2112 lore raw

PATCH 2110/2151 apparmor: fix check SCTP bind, and connect permission checks

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: John Johansen <[email protected]>

[ Upstream commit 7a82f9a06459ff1c37b5e97b204430442cc076e3 ]

SCTP mediation of bind is not being checked correctly because bind permission needs to be checked in the sctp_bind_connect() hook.

Require for bind permissions when CTP_SET_PEER_PRIMARY_ADDR, and SCTP_SOCKOPT_BINDX_ADD are asked for.

The peer initialized ASCONF cases (SCTP_PARAM_ADD_IP and SCTP_PARAM_SET_PRIMARY) are processed in softirq context and are not mediated atm. SCTP_PRIMATEY_ADDR, and SCTP_SET_PEER_PRIMARY_ADDR only select among address already in the association.

Fixes 56974a6fcfef ("apparmor: add base infastructure for socket mediation")
---
 security/apparmor/lsm.c | 5 +++++
 1 file changed, 5 insertions(+)
security/apparmor/lsm.c +5 -0
index 9b9be6849411d..9e82e4c0b0433 100644
@@ -1392,6 +1392,11 @@ static int apparmor_sctp_bind_connect(struct sock *sk, int optname,
 				      struct sockaddr *address, int addrlen)
 {
 	switch (optname) {
+	/* Bind checks */
+	case SCTP_SET_PEER_PRIMARY_ADDR:
+	case SCTP_SOCKOPT_BINDX_ADD:
+		return aa_sk_perm(OP_BIND, AA_MAY_BIND, sk);
+	/* Connect checks */
 	case SCTP_SOCKOPT_CONNECTX:
 	case SCTP_SENDMSG_CONNECT:
 		return aa_sk_perm(OP_CONNECT, AA_MAY_CONNECT, sk);
Signature · 1 line
2.53.0
author maintainer
#2113 lore raw

PATCH 2111/2151 tcp: initialize mapped children before route lookup

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kyle Zeng <[email protected]>

[ Upstream commit b7ff0e7a9ae3df2f123807a7e670bc348b1e1b9d ]

IPv4 passive opens on a dual-stack listener go through tcp_v4_syn_recv_sock() with tcp_v6_mapped_child_init() as the optional initializer. The callback currently runs after the output route lookup. If that lookup fails, tcp_done() destroys a clone whose pinet6 and ipv6_fl_list still refer to the listener's state.

With the flowlabel list head in inet_sock, fl6_free_socklist() walks the clone's list and RCU-frees its nodes without unlinking them from the live listener. Subsequent flowlabel operations can use or free the nodes again. Commit 858d2a4f67ff ("tcp: fix potential race in tcp_v6_syn_recv_sock()") moved the initializer before ehash insertion, but did not cover this error path.

Invoke the existing initializer after the IPv4 fields it consumes have been set, but before route lookup can fail. It needs neither the destination nor sk_setup_caps(), and all later disposal paths remain covered.

Fixes 1c17f4373d4d ("ipv6: Move ipv6_fl_list from ipv6_pinfo to inet_sock.")
---
 net/ipv4/tcp_ipv4.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
net/ipv4/tcp_ipv4.c +6 -4
index 5b145ee0d0bb3..b5517f9af5465 100644
@@ -1804,6 +1804,12 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
 	if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_reflect_tos))
 		newinet->tos = tcp_rsk(req)->syn_tos & ~INET_ECN_MASK;
 
+#if IS_ENABLED(CONFIG_IPV6)
+	/* Detach IPv6 state before a route lookup can fail. */
+	if (opt_child_init)
+		opt_child_init(newsk, sk);
+#endif
+
 	if (!dst) {
 		dst = inet_csk_route_child_sock(sk, newsk, req);
 		if (!dst)
@@ -1813,10 +1819,6 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
 	}
 	sk_setup_caps(newsk, dst);
 
-#if IS_ENABLED(CONFIG_IPV6)
-	if (opt_child_init)
-		opt_child_init(newsk, sk);
-#endif
 	tcp_ca_openreq_child(newsk, dst);
 
 	tcp_sync_mss(newsk, dst4_mtu(dst));
Signature · 1 line
2.53.0
author maintainer
#2114 lore raw

PATCH 2112/2151 net: add eth_type_trans_careful()

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <[email protected]>

[ Upstream commit 2519a6fe7a8bba57a961eb804e43e7df35ac40fe ]

eth_type_trans() assumes ETH_HLEN bytes are present in skb->head. NIC drivers always provide this, and they should keep using the fast version.

Devices looping skbs from their transmit path back to their receive path get skbs built by the stack instead. Their link-layer header might have been popped by tc actions (act_vlan pop_eth, act_ife decode) or OVS actions (pop_eth + pop_mpls / pop_nsh), leaving fewer than ETH_HLEN bytes in the linear part. eth_type_trans() then hits the BUG() in __skb_pull().

Add eth_type_trans_careful(), which first pulls the Ethernet header, and returns a drop reason on failure, so that the few devices exposed to this can drop such packets.

Stable-dep-of: 093a28998374 ("loopback: use eth_type_trans_careful()")

---
 include/linux/etherdevice.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
include/linux/etherdevice.h +28 -0
index df8f88f63a706..1f833ebd71ed9 100644
@@ -38,6 +38,34 @@ int fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr);
 
 u32 eth_get_headlen(const struct net_device *dev, const void *data, u32 len);
 __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev);
+
+/**
+ * eth_type_trans_careful - eth_type_trans() for skbs coming from the stack
+ * @skb: buffer, possibly with less than ETH_HLEN bytes in its linear area
+ * @dev: receiving network device
+ *
+ * eth_type_trans() expects ETH_HLEN bytes in skb->head, which NIC drivers
+ * provide. Devices looping skbs from their transmit path back to the
+ * receive path (loopback, OVS internal ports) get skbs built by the stack,
+ * whose link-layer header might have been popped by tc or OVS actions.
+ *
+ * Sets skb->protocol on success.
+ *
+ * Return: SKB_NOT_DROPPED_YET on success, or a drop reason. In the latter
+ * case, the caller must free @skb.
+ */
+static inline enum skb_drop_reason
+eth_type_trans_careful(struct sk_buff *skb, struct net_device *dev)
+{
+	enum skb_drop_reason reason = pskb_may_pull_reason(skb, ETH_HLEN);
+
+	if (unlikely(reason))
+		return reason;
+
+	skb->protocol = eth_type_trans(skb, dev);
+	return SKB_NOT_DROPPED_YET;
+}
+
 extern const struct header_ops eth_header_ops;
 
 int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
Signature · 1 line
2.53.0
author maintainer
#2115 lore raw

PATCH 2113/2151 loopback: use eth_type_trans_careful()

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <[email protected]>

[ Upstream commit 093a28998374f4007ffe67cc661f8192c1b062a9 ]

tc egress actions can leave an skb with fewer than ETH_HLEN bytes in its linear part. loopback_xmit() then crashes in eth_type_trans():

tc qdisc add dev lo clsact
tc filter add dev lo egress matchall action vlan pop_eth # AF_PACKET SOCK_RAW: eth / eth / 8192 bytes of payload

kernel BUG at include/linux/skbuff.h:2839!

  RIP: 0010:eth_type_trans (include/linux/etherdevice.h:635 net/ethernet/eth.c:163)
  Call Trace:
   loopback_xmit (drivers/net/loopback.c:87)
   dev_hard_start_xmit (include/linux/netdevice.h:5455 include/linux/netdevice.h:5464 net/core/dev.c:4057 net/core/dev.c:4073)
   __dev_queue_xmit (net/core/dev.c:5066)
   packet_sendmsg (net/packet/af_packet.c:3157 net/packet/af_packet.c:3189)

The same happens with "action ife decode" on lo egress.

Use eth_type_trans_careful(), and drop the packet if the Ethernet header can not be pulled.

---
 drivers/net/loopback.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/loopback.c +7 -1
index 1fb6ce6843ade..6d16d6040401d 100644
@@ -70,6 +70,7 @@ EXPORT_SYMBOL(blackhole_netdev);
 static netdev_tx_t loopback_xmit(struct sk_buff *skb,
 				 struct net_device *dev)
 {
+	enum skb_drop_reason reason;
 	int len;
 
 	skb_tx_timestamp(skb);
@@ -84,7 +85,12 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
 	 */
 	skb_dst_force(skb);
 
-	skb->protocol = eth_type_trans(skb, dev);
+	reason = eth_type_trans_careful(skb, dev);
+	if (unlikely(reason)) {
+		dev_core_stats_tx_dropped_inc(dev);
+		kfree_skb_reason(skb, reason);
+		return NETDEV_TX_OK;
+	}
 
 	len = skb->len;
 	if (likely(__netif_rx(skb) == NET_RX_SUCCESS))
Signature · 1 line
2.53.0
author maintainer
#2116 lore raw

PATCH 2114/2151 selftests/bpf: cover short IPv4/IPv6 inputs with adjust_room

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Sun Jian <[email protected]>

[ Upstream commit f1cc94665df907a85589ddb5fe74d7768ff61533 ]

Add a selftest covering ETH_HLEN-sized IPv4/IPv6 EtherType inputs for bpf_prog_test_run_skb().

Reuse a single zero-initialized struct ethhdr eth_hlen and set eth_hlen.h_proto from the per-test h_proto field.

Also add a dedicated tc_adjust_room program and route the short IPv4/IPv6 cases to it, so the selftest actually exercises the bpf_skb_adjust_room() path from the report.

Stable-dep-of: 695e1408eb90 ("net: use eth_type_trans_careful() in __dev_forward_skb2()")

---
 .../selftests/bpf/prog_tests/empty_skb.c      | 40 +++++++++++++++++--
 tools/testing/selftests/bpf/progs/empty_skb.c |  7 ++++
 2 files changed, 44 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/empty_skb.c +37 -3
index 438583e1f2d12..c9fcb70cbafbc 100644
@@ -10,8 +10,8 @@ void test_empty_skb(void)
 	struct empty_skb *bpf_obj = NULL;
 	struct nstoken *tok = NULL;
 	struct bpf_program *prog;
+	struct ethhdr eth_hlen;
 	char eth_hlen_pp[15];
-	char eth_hlen[14];
 	int veth_ifindex;
 	int ipip_ifindex;
 	int err;
@@ -25,7 +25,9 @@ void test_empty_skb(void)
 		int err;
 		int ret;
 		int lwt_egress_ret; /* expected retval at lwt/egress */
+		__be16 h_proto;
 		bool success_on_tc;
+		bool adjust_room;
 	} tests[] = {
 		/* Empty packets are always rejected. */
 
@@ -46,6 +48,28 @@ void test_empty_skb(void)
 			.err = -EINVAL,
 		},
 
+		/* ETH_HLEN-sized packets with IPv4/IPv6 EtherType but
+		 * no L3 header are rejected.
+		 */
+		{
+			.msg = "veth short IPv4 ingress packet",
+			.data_in = &eth_hlen,
+			.data_size_in = sizeof(eth_hlen),
+			.ifindex = &veth_ifindex,
+			.err = -EINVAL,
+			.h_proto = htons(ETH_P_IP),
+			.adjust_room = true,
+		},
+		{
+			.msg = "veth short IPv6 ingress packet",
+			.data_in = &eth_hlen,
+			.data_size_in = sizeof(eth_hlen),
+			.ifindex = &veth_ifindex,
+			.err = -EINVAL,
+			.h_proto = htons(ETH_P_IPV6),
+			.adjust_room = true,
+		},
+
 		/* ETH_HLEN-sized packets:
 		 * - can not be redirected at LWT_XMIT
 		 * - can be redirected at TC to non-tunneling dest
@@ -54,7 +78,7 @@ void test_empty_skb(void)
 		{
 			/* __bpf_redirect_common */
 			.msg = "veth ETH_HLEN packet ingress",
-			.data_in = eth_hlen,
+			.data_in = &eth_hlen,
 			.data_size_in = sizeof(eth_hlen),
 			.ifindex = &veth_ifindex,
 			.ret = -ERANGE,
@@ -68,7 +92,7 @@ void test_empty_skb(void)
 			 * tc: skb->len=14 <= skb_network_offset=14
 			 */
 			.msg = "ipip ETH_HLEN packet ingress",
-			.data_in = eth_hlen,
+			.data_in = &eth_hlen,
 			.data_size_in = sizeof(eth_hlen),
 			.ifindex = &ipip_ifindex,
 			.ret = -ERANGE,
@@ -108,17 +132,27 @@ void test_empty_skb(void)
 	SYS(out, "ip addr add 192.168.1.1/16 dev ipip0");
 	ipip_ifindex = if_nametoindex("ipip0");
 
+	memset(eth_hlen_pp, 0, sizeof(eth_hlen_pp));
+	memset(&eth_hlen, 0, sizeof(eth_hlen));
+
 	bpf_obj = empty_skb__open_and_load();
 	if (!ASSERT_OK_PTR(bpf_obj, "open skeleton"))
 		goto out;
 
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
+		if (tests[i].data_in == &eth_hlen)
+			eth_hlen.h_proto = tests[i].h_proto;
+
 		bpf_object__for_each_program(prog, bpf_obj->obj) {
 			bool at_egress = strstr(bpf_program__name(prog), "egress") != NULL;
 			bool at_tc = !strncmp(bpf_program__section_name(prog), "tc", 2);
+			bool is_adjust_room = !strcmp(bpf_program__name(prog), "tc_adjust_room");
 			int expected_ret;
 			char buf[128];
 
+			if (tests[i].adjust_room != is_adjust_room)
+				continue;
+
 			expected_ret = at_egress && !at_tc ? tests[i].lwt_egress_ret : tests[i].ret;
 
 			tattr.data_in = tests[i].data_in;
tools/testing/selftests/bpf/progs/empty_skb.c +7 -0
index 4b0cd67532511..44326f5cc8bb4 100644
@@ -35,3 +35,10 @@ int tc_redirect_egress(struct __sk_buff *skb)
 	ret = bpf_clone_redirect(skb, ifindex, 0);
 	return 0;
 }
+
+SEC("tc")
+int tc_adjust_room(struct __sk_buff *skb)
+{
+	ret = bpf_skb_adjust_room(skb, 4, BPF_ADJ_ROOM_NET, 0);
+	return 0;
+}
Signature · 1 line
2.53.0
author maintainer
#2117 lore raw

PATCH 2115/2151 net: use eth_type_trans_careful() in __dev_forward_skb2()

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <[email protected]>

[ Upstream commit 695e1408eb908ac7acf78069933201f92b95727c ]

A tc egress BPF program can push a tiny link-layer header with bpf_skb_change_head() on an skb whose head is almost empty, then redirect it to an Ethernet device ingress. __bpf_redirect_common() only checks mac_header < network_header, and __dev_forward_skb2() crashes in eth_type_trans():

tc filter add dev lo egress pref 1 matchall action vlan pop_eth continue tc filter add dev lo egress pref 2 bpf da obj prog.o
# prog: bpf_skb_change_head(skb, 1, 0);
# return bpf_redirect(veth1_ifindex, BPF_F_INGRESS);
# AF_PACKET SOCK_RAW on lo: eth / eth / 8192 bytes of payload

kernel BUG at include/linux/skbuff.h:2839!

  RIP: 0010:eth_type_trans (include/linux/etherdevice.h:635 net/ethernet/eth.c:163)
  Call Trace:
   __dev_forward_skb2 (net/core/dev.c:2507)
   dev_forward_skb_nomtu (net/core/dev.c:2546)
   __dev_queue_xmit (net/core/dev.c:4738 net/core/dev.c:4998)
   packet_sendmsg (net/packet/af_packet.c:3157 net/packet/af_packet.c:3189)

Use eth_type_trans_careful(), and drop the packet if the Ethernet header can not be pulled. This also covers other dev_forward_skb() users (veth, macvlan, ipvlan, netdevsim, l2tp_eth).

Update the empty_skb BPF selftest: at lwt_xmit, BPF_PROG_TEST_RUN strips the Ethernet header, so the "veth ETH_HLEN+1" packet is a 1-byte skb. Redirecting it to veth ingress used to read the Ethernet header past skb->tail and deliver a 1-byte frame; it is now dropped with NET_RX_DROP, as veth_xmit() already does at egress.

---
 net/core/dev.c                                | 18 +++++++++++++-----
 .../selftests/bpf/prog_tests/empty_skb.c      | 19 ++++++++++++-------
 2 files changed, 25 insertions(+), 12 deletions(-)
net/core/dev.c +13 -5
index 356e9a3fc224d..e4216b78a1a49 100644
@@ -2437,14 +2437,22 @@ EXPORT_SYMBOL_GPL(is_skb_forwardable);
 static int __dev_forward_skb2(struct net_device *dev, struct sk_buff *skb,
 			      bool check_mtu)
 {
-	int ret = ____dev_forward_skb(dev, skb, check_mtu);
+	enum skb_drop_reason reason;
+	int ret;
+
+	ret = ____dev_forward_skb(dev, skb, check_mtu);
+	if (unlikely(ret))
+		return ret;
 
-	if (likely(!ret)) {
-		skb->protocol = eth_type_trans(skb, dev);
-		skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
+	reason = eth_type_trans_careful(skb, dev);
+	if (unlikely(reason)) {
+		dev_core_stats_rx_dropped_inc(dev);
+		kfree_skb_reason(skb, reason);
+		return NET_RX_DROP;
 	}
+	skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
 
-	return ret;
+	return 0;
 }
 
 int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
tools/testing/selftests/bpf/prog_tests/empty_skb.c +12 -7
index c9fcb70cbafbc..a3938c16557b1 100644
@@ -24,7 +24,7 @@ void test_empty_skb(void)
 		int *ifindex;
 		int err;
 		int ret;
-		int lwt_egress_ret; /* expected retval at lwt/egress */
+		int lwt_ret; /* expected retval at lwt */
 		__be16 h_proto;
 		bool success_on_tc;
 		bool adjust_room;
@@ -82,7 +82,7 @@ void test_empty_skb(void)
 			.data_size_in = sizeof(eth_hlen),
 			.ifindex = &veth_ifindex,
 			.ret = -ERANGE,
-			.lwt_egress_ret = -ERANGE,
+			.lwt_ret = -ERANGE,
 			.success_on_tc = true,
 		},
 		{
@@ -96,17 +96,23 @@ void test_empty_skb(void)
 			.data_size_in = sizeof(eth_hlen),
 			.ifindex = &ipip_ifindex,
 			.ret = -ERANGE,
-			.lwt_egress_ret = -ERANGE,
+			.lwt_ret = -ERANGE,
 		},
 
-		/* ETH_HLEN+1-sized packet should be redirected. */
+		/* ETH_HLEN+1-sized packet should be redirected at TC.
+		 * At LWT, the Ethernet header is not part of the skb, and
+		 * a 1-byte packet is too short for an Ethernet device.
+		 */
 
 		{
 			.msg = "veth ETH_HLEN+1 packet ingress",
 			.data_in = eth_hlen_pp,
 			.data_size_in = sizeof(eth_hlen_pp),
 			.ifindex = &veth_ifindex,
-			.lwt_egress_ret = 1, /* veth_xmit NET_XMIT_DROP */
+			/* lwt: skb->len=1, dropped by veth_xmit() at egress
+			 * and by __dev_forward_skb2() at ingress.
+			 */
+			.lwt_ret = 1, /* NET_XMIT_DROP / NET_RX_DROP */
 		},
 		{
 			.msg = "ipip ETH_HLEN+1 packet ingress",
@@ -144,7 +150,6 @@ void test_empty_skb(void)
 			eth_hlen.h_proto = tests[i].h_proto;
 
 		bpf_object__for_each_program(prog, bpf_obj->obj) {
-			bool at_egress = strstr(bpf_program__name(prog), "egress") != NULL;
 			bool at_tc = !strncmp(bpf_program__section_name(prog), "tc", 2);
 			bool is_adjust_room = !strcmp(bpf_program__name(prog), "tc_adjust_room");
 			int expected_ret;
@@ -153,7 +158,7 @@ void test_empty_skb(void)
 			if (tests[i].adjust_room != is_adjust_room)
 				continue;
 
-			expected_ret = at_egress && !at_tc ? tests[i].lwt_egress_ret : tests[i].ret;
+			expected_ret = at_tc ? tests[i].ret : tests[i].lwt_ret;
 
 			tattr.data_in = tests[i].data_in;
 			tattr.data_size_in = tests[i].data_size_in;
Signature · 1 line
2.53.0
author maintainer
#2118 lore raw

PATCH 2116/2151 openvswitch: use eth_type_trans_careful() in internal_dev_recv()

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <[email protected]>

[ Upstream commit b55e5a0159c8f53edefcb7848d95eb93db37bce1 ]

OVS actions like pop_eth followed by pop_mpls(ETH_P_TEB) or pop_nsh can expose an inner Ethernet header which is not in the linear part of the skb. Output to an internal port then crashes in eth_type_trans():

flow: in_port(0),eth(),eth_type(0x8847),mpls(lse=0x00010140)
actions: pop_eth,pop_mpls(0x6558),0
# AF_PACKET SOCK_RAW on dp0: eth / mpls / eth / 4096 bytes of payload

kernel BUG at include/linux/skbuff.h:2839!

  RIP: 0010:eth_type_trans (include/linux/etherdevice.h:635 net/ethernet/eth.c:163)
  Call Trace:
   internal_dev_recv (net/openvswitch/vport-internal_dev.c:202) openvswitch
   do_execute_actions (net/openvswitch/actions.c:1296) openvswitch
   ovs_execute_actions (net/openvswitch/actions.c:1606) openvswitch
   ovs_dp_process_packet (net/openvswitch/datapath.c:310) openvswitch
   ovs_vport_receive (net/openvswitch/vport.c:448) openvswitch
   internal_dev_xmit (net/openvswitch/vport-internal_dev.c:42) openvswitch
   dev_hard_start_xmit (include/linux/netdevice.h:5455 include/linux/netdevice.h:5464 net/core/dev.c:4057 net/core/dev.c:4073)
   __dev_queue_xmit (net/core/dev.c:5066)
   packet_sendmsg (net/packet/af_packet.c:3157 net/packet/af_packet.c:3189)

Use eth_type_trans_careful(), and drop the packet if the Ethernet header can not be pulled. This covers all OVS actions at the consumer, instead of fixing each producer.

Fixes b2d0f5d5dc53 ("openvswitch: enable NSH support")
Fixes f66b53fdbb22 ("openvswitch: New MPLS actions for layer 2 tunnelling")
---
 net/openvswitch/vport-internal_dev.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
net/openvswitch/vport-internal_dev.c +7 -1
index 125d310871e93..06a363df81556 100644
@@ -186,6 +186,7 @@ static void internal_dev_destroy(struct vport *vport)
 static int internal_dev_recv(struct sk_buff *skb)
 {
 	struct net_device *netdev = skb->dev;
+	enum skb_drop_reason reason;
 
 	if (unlikely(!(netdev->flags & IFF_UP))) {
 		kfree_skb(skb);
@@ -197,7 +198,12 @@ static int internal_dev_recv(struct sk_buff *skb)
 	nf_reset_ct(skb);
 
 	skb->pkt_type = PACKET_HOST;
-	skb->protocol = eth_type_trans(skb, netdev);
+	reason = eth_type_trans_careful(skb, netdev);
+	if (unlikely(reason)) {
+		dev_core_stats_rx_dropped_inc(netdev);
+		kfree_skb_reason(skb, reason);
+		return NETDEV_TX_OK;
+	}
 	skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
 	dev_sw_netstats_rx_add(netdev, skb->len);
 
Signature · 1 line
2.53.0
author maintainer
#2119 lore raw

PATCH 2117/2151 netlink: check sk_rcvbuf before charging the dump skb

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jhonata Poma-Hansen <[email protected]>

[ Upstream commit b45d37740cfb4bdfccef3fbd9fd970fd3224438f ]

Since commit ae8f160e7eb2 ("netlink: Fix wraparounds of sk->sk_rmem_alloc."), netlink_dump() charges the dump skb first and queues it only if sk_rmem_alloc is still below sk_rcvbuf. Commit a215b5723922 ("netlink: make sure we allow at least one dump skb") added an exception for an empty socket.

A dump that starts while something else is still charged to a socket with a small receive buffer fails with ENOBUFS and stays running. Every recvmsg() retries it, fails again and sets sk_err, so a reader that peeks before reading, as libnl does, gets ENOBUFS on the read after each peek, never consumes the message at the head of the queue and spins forever.

I hit this with "iw dev wlan0 scan" hanging at 100% CPU on an arm64 board with a 6.6 based kernel (iw 5.19 sets SO_RCVBUF to 8KiB). A kprobe trace showed the scan dump starting while the NEW_SCAN_RESULTS notification iw had just read was still charged to its socket, because iw had preempted the sender before netlink_broadcast() returned.

Check the limit before charging, as before ae8f160e7eb2, which also covers the empty socket. netlink_recvmsg() continues a dump only at or below half of sk_rcvbuf, so the skb is then always queued, and a dump goes over the limit by at most one skb. Refuse a skb that would take sk_rmem_alloc past INT_MAX, so the wraparound stays fixed.

Reproduced on net in a KVM guest with a userspace reproducer and the selftest in the next patch; both pass with this fix.

Fixes ae8f160e7eb2 ("netlink: Fix wraparounds of sk->sk_rmem_alloc.")
---
 net/netlink/af_netlink.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/netlink/af_netlink.c +5 -1
index 7141bbfc241f1..fb7785a59af59 100644
@@ -2307,9 +2307,13 @@ static int netlink_dump(struct sock *sk, bool lock_taken)
 	if (!skb)
 		goto errout_skb;
 
+	/* Check the limit before charging the skb: netlink_recvmsg() continues
+	 * the dump at or below half of sk_rcvbuf, and the skb must be queued
+	 * then. Keep sk_rmem_alloc at or below INT_MAX.
+	 */
 	rcvbuf = READ_ONCE(sk->sk_rcvbuf);
 	rmem = atomic_add_return(skb->truesize, &sk->sk_rmem_alloc);
-	if (rmem != skb->truesize && rmem >= rcvbuf) {
+	if (rmem - skb->truesize >= rcvbuf || rmem > INT_MAX) {
 		atomic_sub(skb->truesize, &sk->sk_rmem_alloc);
 		goto errout_skb;
 	}
Signature · 1 line
2.53.0
author maintainer
#2120 lore raw

PATCH 2118/2151 apparmor: advertise that sctp is being mediated

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: John Johansen <[email protected]>

[ Upstream commit 35b8ab3f36ac0fcd8fc910da0bed889b6c75c426 ]

Enable the test harness to detect that the kernel should be properly mediating sctp.

Fixes 7a82f9a06459f ("apparmor: fix check SCTP bind, and connect permission checks")
---
 security/apparmor/net.c | 1 +
 1 file changed, 1 insertion(+)
security/apparmor/net.c +1 -0
index 6376a86f82e17..e8b60f1b6810f 100644
@@ -23,6 +23,7 @@
 struct aa_sfs_entry aa_sfs_entry_network[] = {
 	AA_SFS_FILE_STRING("af_mask",	AA_SFS_AF_MASK),
 	AA_SFS_FILE_BOOLEAN("tcp-fast-open",		1),
+	AA_SFS_FILE_BOOLEAN("sctp",		1),
 	{ }
 };
 
Signature · 1 line
2.53.0
author maintainer
#2121 lore raw

PATCH 2119/2151 tun: drop batched packets while the device is down

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Xiao Liang <[email protected]>

[ Upstream commit 8f44631ba02afe9fff2f0a0fb66560ab19df87fd ]

tun_sendmsg() handles TUN_MSG_PTR batches from vhost-net by calling tun_xdp_one() instead of tun_get_user(). But this path does not check IFF_UP, allowing packets from a guest to be injected into the host receive path while the device is administratively down.

Check IFF_UP in tun_xdp_one() before running XDP or building an skb. Drop the packet when the device is down, matching tun_get_user().

Fixes 043d222f93ab ("tuntap: accept an array of XDP buffs through sendmsg()")
---
 drivers/net/tun.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/tun.c +6 -0
index ff1f69589a66a..afb02752b257f 100644
@@ -2417,6 +2417,12 @@ static int tun_xdp_one(struct tun_struct *tun,
 		return -EINVAL;
 	}
 
+	if (unlikely(!(READ_ONCE(tun->dev->flags) & IFF_UP))) {
+		put_page(virt_to_head_page(xdp->data));
+		dev_core_stats_rx_dropped_inc(tun->dev);
+		return -EIO;
+	}
+
 	xdp_prog = rcu_dereference(tun->xdp_prog);
 	if (xdp_prog) {
 		if (gso->gso_type) {
Signature · 1 line
2.53.0
author maintainer
#2122 lore raw

PATCH 2120/2151 watch_queue: keep info_id separate from rcu_head

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Zhiyu Zhang <[email protected]>

[ Upstream commit 53d72818f9e2aeb03a6053544ee6efa4eb2a3988 ]

struct watch overlays info_id with rcu_head. A notification poster reads info_id under rcu_read_lock(), but a concurrent final put can enqueue the watch with call_rcu(). Enqueueing the callback writes rcu_head before the grace period has elapsed, so it can corrupt info_id while the object remains legally visible to the reader.

__post_watch_notification() then merges that value into the notification info word without masking it. Pointer bits can corrupt WATCH_INFO_LENGTH and make post_one_notification() copy beyond the posting task's stack record.

Give info_id storage separate from rcu_head so RCU enqueueing cannot modify it. Place it after the kref, which uses existing tail padding on x86-64. Mask info_id with WATCH_INFO_ID at the point of use as an additional invariant check.

An unprivileged shell and keyctl reproducer was run for 30 seconds in QEMU. The vulnerable baseline produced malformed notification lengths, while this change completed with 288631 key notifications and no malformed record.

---
 include/linux/watch_queue.h | 6 ++----
 kernel/watch_queue.c        | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)
include/linux/watch_queue.h +2 -4
index 429c7b6afeada..b87e1babb5f03 100644
@@ -52,10 +52,7 @@ struct watch_queue {
  * Representation of a watch on an object.
  */
 struct watch {
-	union {
-		struct rcu_head	rcu;
-		u32		info_id;	/* ID to be OR'd in to info field */
-	};
+	struct rcu_head		rcu;
 	struct watch_queue __rcu *queue;	/* Queue to post events to */
 	struct hlist_node	queue_node;	/* Link in queue->watches */
 	struct watch_list __rcu	*watch_list;
@@ -64,6 +61,7 @@ struct watch {
 	void			*private;	/* Private data for the watched object */
 	u64			id;		/* Internal identifier */
 	struct kref		usage;		/* Object usage count */
+	u32			info_id;	/* ID to be OR'd in to info field */
 };
 
 /*
kernel/watch_queue.c +1 -1
index bc8d6b641ed43..0c413613ffe2c 100644
@@ -212,7 +212,7 @@ void __post_watch_notification(struct watch_list *wlist,
 		if (watch->id != id)
 			continue;
 		n->info &= ~WATCH_INFO_ID;
-		n->info |= watch->info_id;
+		n->info |= watch->info_id & WATCH_INFO_ID;
 
 		wqueue = rcu_dereference(watch->queue);
 		wf = rcu_dereference(wqueue->filter);
Signature · 1 line
2.53.0
author maintainer
#2123 lore raw

PATCH 2121/2151 splice: retry tee() instead of returning 0 when it races

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nickolai Zeldovich <[email protected]>

[ Upstream commit b2aa970a0a03c117306f48d75a4c3125a8cc9957 ]

tee() can return 0 while the input pipe still has writers, when another task reads the input pipe or fills the output pipe at the same time. tee(2) documents 0 as "no data was copied" because the input pipe has no writers, and loops built on it (the man page example breaks out on 0) stop early. In a test with one thread writing 1 byte at a time to the input pipe, one reading it and one draining the output pipe, about one tee() call in 150 returned 0.

do_tee() runs ipipe_prep() and opipe_prep() to wait for data and room, each under its own pipe lock, and only then takes both locks in link_pipe(). If the input pipe was emptied or the output pipe filled in between, link_pipe() finds nothing to do and returns 0. splice_pipe_to_pipe(), which was modelled on tee(), handles the same race by dropping both locks and going back to the prep steps ("A zero return value means EOF, so retry instead"), and returns -EAGAIN for SPLICE_F_NONBLOCK.

Do the same in link_pipe(): move the prep steps into it and retry when nothing was linked although the input pipe still has writers.

Tested under QEMU (x86_64) with the program in the notes: 154 of 22698 tee() calls returned 0 before the change, none of 34429 after it.

---
 fs/splice.c | 43 +++++++++++++++++++++++++++++++------------
 1 file changed, 31 insertions(+), 12 deletions(-)
fs/splice.c +31 -12
index 8ac45441e2193..0c38b36df3992 100644
@@ -1858,6 +1858,15 @@ static ssize_t link_pipe(struct pipe_inode_info *ipipe,
 	unsigned int i_tail, o_tail;
 	ssize_t ret = 0;
 
+retry:
+	ret = ipipe_prep(ipipe, flags);
+	if (ret)
+		return ret;
+
+	ret = opipe_prep(opipe, flags);
+	if (ret)
+		return ret;
+
 	/*
 	 * Potential ABBA deadlock, work around it by ordering lock
 	 * grabbing by pipe info address. Otherwise two different processes
@@ -1879,13 +1888,32 @@ static ssize_t link_pipe(struct pipe_inode_info *ipipe,
 		i_head = ipipe->head;
 		o_tail = opipe->tail;
 
+		if (pipe_empty(i_head, i_tail) && !ipipe->writers)
+			break;
+
 		/*
 		 * If we have iterated all input buffers or run out of
 		 * output room, break.
 		 */
 		if (pipe_empty(i_head, i_tail) ||
-		    pipe_full(o_head, o_tail, opipe->max_usage))
-			break;
+		    pipe_full(o_head, o_tail, opipe->max_usage)) {
+			if (ret)
+				break;
+
+			if (flags & SPLICE_F_NONBLOCK) {
+				ret = -EAGAIN;
+				break;
+			}
+
+			/*
+			 * We raced with another reader/writer and haven't
+			 * linked any buffers. A zero return value means EOF,
+			 * so retry instead.
+			 */
+			pipe_unlock(ipipe);
+			pipe_unlock(opipe);
+			goto retry;
+		}
 
 		ibuf = pipe_buf(ipipe, i_tail);
 		obuf = pipe_buf(opipe, o_head);
@@ -1956,16 +1984,7 @@ ssize_t do_tee(struct file *in, struct file *out, size_t len,
 		if ((in->f_flags | out->f_flags) & O_NONBLOCK)
 			flags |= SPLICE_F_NONBLOCK;
 
-		/*
-		 * Keep going, unless we encounter an error. The ipipe/opipe
-		 * ordering doesn't really matter.
-		 */
-		ret = ipipe_prep(ipipe, flags);
-		if (!ret) {
-			ret = opipe_prep(opipe, flags);
-			if (!ret)
-				ret = link_pipe(ipipe, opipe, len, flags);
-		}
+		ret = link_pipe(ipipe, opipe, len, flags);
 	}
 
 	if (ret > 0) {
Signature · 1 line
2.53.0
author maintainer
#2124 lore raw

PATCH 2122/2151 ucount: read the parent ucounts before dropping the rlimit count

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nickolai Zeldovich <[email protected]>

[ Upstream commit 38bf603d1ea5d5a65a9cb277df75327ffec01ff1 ]

do_dec_rlimit_put_ucounts() drops its share of iter->rlimit[type] and only then loads iter->ns->ucounts. If the decrement leaves the count non-zero, a concurrent caller can take it to zero and put the last reference, which frees the ucounts and possibly its user namespace with kfree_rcu(). An exiting task frees its pending signals without siglock or any RCU read-side section, so when it is preempted between the decrement and the load for a grace period it reads freed memory and then decrements a counter through the pointer it found there.

A pending signal holds no reference on its ucounts: the reference is taken by whoever moves the count from 0 to 1 and dropped by whoever moves it back to 0, so the caller's share of the count is all that keeps iter alive, and only until it is dropped.

Load the parent first; it stays pinned by the caller's share of its own count.

---
 kernel/ucount.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
kernel/ucount.c +5 -2
index 5cbf1553658ea..56d5566477942 100644
@@ -279,9 +279,12 @@ static void do_dec_rlimit_put_ucounts(struct ucounts *ucounts,
 {
 	struct ucounts *iter, *next;
 	for (iter = ucounts; iter != last; iter = next) {
-		long dec = atomic_long_sub_return(1, &iter->rlimit[type]);
-		WARN_ON_ONCE(dec < 0);
+		long dec;
+
+		/* Our count pins @iter; once it is dropped @iter may be freed. */
 		next = iter->ns->ucounts;
+		dec = atomic_long_sub_return(1, &iter->rlimit[type]);
+		WARN_ON_ONCE(dec < 0);
 		if (dec == 0)
 			put_ucounts(iter);
 	}
Signature · 1 line
2.53.0
author maintainer
#2125 lore raw

PATCH 2123/2151 fs_pin: do not trust the pin after a spurious wakeup in pin_kill()

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nickolai Zeldovich <[email protected]>

[ Upstream commit f3a6dae67c9ca3d913cbb42fe324c9b47c8d9e53 ]

A task waiting in pin_kill() for another task's ->kill() can take p->wait.lock after the pin has been freed, and can return with its on-stack wait entry still on p->wait. With BSD process accounting this is a use-after-free of the acct structure when umount() of the mount holding the accounting file races with acct(2).

pin_kill() takes a still-queued entry as proof that pin_remove() has not run, so p is alive. But autoremove_wake_function() dequeues only when try_to_wake_up() succeeds: if the waiter was already woken spuriously, pin_remove() leaves the entry queued, acct_pin_kill() frees the acct with kfree_rcu(), and the grace period can end while the waiter sits between schedule() and rcu_read_lock().

Dequeue the entry unconditionally in a private wake function; pin_remove() is the only waker and sets p->done first.

Reproduced under QEMU with KASAN and test-only delays: a slab-use-after-free in pin_kill() before the patch, no report after.

---
 fs/fs_pin.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
fs/fs_pin.c +14 -1
index 1a508f2167e0a..a4e5a5a7aca8d 100644
@@ -28,6 +28,19 @@ void pin_insert(struct fs_pin *pin, struct vfsmount *m)
 	spin_unlock(&pin_lock);
 }
 
+/*
+ * Unlike autoremove_wake_function(), dequeue even if the waiter was already
+ * running: pin_kill() trusts @p only while its entry is still queued.
+ */
+static int pin_kill_wake_function(struct wait_queue_entry *wait,
+				  unsigned int mode, int sync, void *key)
+{
+	int ret = default_wake_function(wait, mode, sync, key);
+
+	list_del_init_careful(&wait->entry);
+	return ret;
+}
+
 void pin_kill(struct fs_pin *p)
 {
 	wait_queue_entry_t wait;
@@ -36,7 +49,7 @@ void pin_kill(struct fs_pin *p)
 		rcu_read_unlock();
 		return;
 	}
-	init_wait(&wait);
+	init_wait_func(&wait, pin_kill_wake_function);
 	spin_lock_irq(&p->wait.lock);
 	if (likely(!p->done)) {
 		p->done = -1;
Signature · 1 line
2.53.0
author maintainer
#2126 lore raw

PATCH 2124/2151 Add error handling to minix filesystem for inode corruption detection

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jori Koolstra <[email protected]>

[ Upstream commit 21215ce7a95ae03891708028a8c805e5dc47395e ]

We would like to provide early and specific warnings of filesystem corruption without running into generic WARN_ONs and BUG_ONs. Towards this goal, ext4, e.g., has a EFSCORRUPTED errno and a standardized inode corruption message format. This patch adds this errno and message format to the minix filesystem.

Stable-dep-of: fc9577079df8 ("minix: reject rmdir of a directory with a corrupted link count")

---
 fs/minix/inode.c | 16 ++++++++++++++++
 fs/minix/minix.h |  9 +++++++++
 2 files changed, 25 insertions(+)
fs/minix/inode.c +16 -0
index 5bfe42599a585..ed84279446267 100644
@@ -26,6 +26,22 @@ static int minix_write_inode(struct inode *inode,
 		struct writeback_control *wbc);
 static int minix_statfs(struct dentry *dentry, struct kstatfs *buf);
 
+void __minix_error_inode(struct inode *inode, const char *function,
+			 unsigned int line, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+	printk(KERN_CRIT "minix-fs error (device %s): %s:%d: "
+	       "inode #%lu: comm %s: %pV\n",
+	       inode->i_sb->s_id, function, line, inode->i_ino,
+	       current->comm, &vaf);
+	va_end(args);
+}
+
 static void minix_evict_inode(struct inode *inode)
 {
 	truncate_inode_pages_final(&inode->i_data);
fs/minix/minix.h +9 -0
index c81e48badae93..73e1087502253 100644
@@ -42,6 +42,9 @@ struct minix_sb_info {
 	unsigned short s_version;
 };
 
+void __minix_error_inode(struct inode *inode, const char *function,
+			 unsigned int line, const char *fmt, ...);
+
 struct inode *minix_iget(struct super_block *, unsigned long);
 struct minix_inode *minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **);
 struct minix2_inode *minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **);
@@ -168,4 +171,10 @@ static inline int minix_test_bit(int nr, const void *vaddr)
 
 #endif
 
+#define minix_error_inode(inode, fmt, ...)			\
+	__minix_error_inode((inode), __func__, __LINE__,	\
+			    (fmt), ##__VA_ARGS__)
+
+#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
+
 #endif /* FS_MINIX_H */
Signature · 1 line
2.53.0
author maintainer
#2127 lore raw

PATCH 2125/2151 Fix a drop_nlink warning in minix_rmdir

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jori Koolstra <[email protected]>

[ Upstream commit d3e0e8661ceb4fe3aab85af3730dbf41240d561f ]

Syzbot found a drop_nlink warning that is triggered by an easy to detect nlink corruption of a directory. This patch adds a sanity check to minix_rmdir to prevent the warning and instead return EFSCORRUPTED to the caller.

The changes were tested using the syzbot reproducer as well as local testing.

Stable-dep-of: fc9577079df8 ("minix: reject rmdir of a directory with a corrupted link count")

---
 fs/minix/namei.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
fs/minix/namei.c +17 -8
index 8938536d8d3cf..68d2dd75b97fb 100644
@@ -161,15 +161,24 @@ static int minix_unlink(struct inode * dir, struct dentry *dentry)
 static int minix_rmdir(struct inode * dir, struct dentry *dentry)
 {
 	struct inode * inode = d_inode(dentry);
-	int err = -ENOTEMPTY;
-
-	if (minix_empty_dir(inode)) {
-		err = minix_unlink(dir, dentry);
-		if (!err) {
-			inode_dec_link_count(dir);
-			inode_dec_link_count(inode);
-		}
+	int err = -EFSCORRUPTED;
+
+	if (dir->i_nlink <= 2) {
+		minix_error_inode(dir, "inode has corrupted nlink");
+		goto out;
+	}
+
+	err = -ENOTEMPTY;
+	if (!minix_empty_dir(inode))
+		goto out;
+
+	err = minix_unlink(dir, dentry);
+	if (!err) {
+		inode_dec_link_count(dir);
+		inode_dec_link_count(inode);
 	}
+
+out:
 	return err;
 }
 
Signature · 1 line
2.53.0
author maintainer
#2128 lore raw

PATCH 2126/2151 minix: reject rmdir of a directory with a corrupted link count

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nguyen Ngoc Thang <[email protected]>

[ Upstream commit fc9577079df8a44ccbf39d2f06634017d286e4f0 ]

minix_rmdir() calls minix_unlink(), which drops the victim's link count once, and then drops it a second time for the "." entry. An image where an empty directory has i_nlink < 2 makes the second drop hit drop_nlink() with i_nlink == 0:

  WARNING: fs/inode.c:408 at drop_nlink
   minix_rmdir+0xe9/0x150
   vfs_rmdir
   filename_rmdir
   __do_sys_unlinkat

The parent's link count is already validated; do the same for the directory being removed and fail with -EFSCORRUPTED.

---
 fs/minix/namei.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/minix/namei.c +4 -0
index 68d2dd75b97fb..89aa05f29c669 100644
@@ -167,6 +167,10 @@ static int minix_rmdir(struct inode * dir, struct dentry *dentry)
 		minix_error_inode(dir, "inode has corrupted nlink");
 		goto out;
 	}
+	if (inode->i_nlink < 2) {
+		minix_error_inode(inode, "inode has corrupted nlink");
+		goto out;
+	}
 
 	err = -ENOTEMPTY;
 	if (!minix_empty_dir(inode))
Signature · 1 line
2.53.0
author maintainer
#2129 lore raw

PATCH 2127/2151 rtc: ds1685: arm the wake-up alarm at power-off only if an alarm is set

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Imre Kaloz <[email protected]>

[ Upstream commit c2373bcd50d9654b76eac585c7c98105665b3321 ]

ds1685_rtc_poweroff() always sets WIE. The wake-up alarm then compares the time-of-day and date alarm registers, which hold whatever was last written to them, and a match powers the machine straight back on.

Set WIE only when AIE is set in Control B, and clear it otherwise.

Fixes aaaf5fbf56f1 ("rtc: add driver for DS1685 family of real time clocks")
---
 drivers/rtc/rtc-ds1685.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/rtc/rtc-ds1685.c +12 -6
index 97423f1d0361f..7f84ea02c4038 100644
@@ -1370,7 +1370,7 @@ module_platform_driver(ds1685_rtc_driver);
 void __noreturn
 ds1685_rtc_poweroff(struct platform_device *pdev)
 {
-	u8 ctrla, ctrl4a, ctrl4b;
+	u8 ctrla, ctrlb, ctrl4a, ctrl4b;
 	struct ds1685_priv *rtc;
 
 	/* Check for valid RTC data, else, spin forever. */
@@ -1397,6 +1397,8 @@ ds1685_rtc_poweroff(struct platform_device *pdev)
 		ctrla &= ~(RTC_CTRL_A_DV2);
 		rtc->write(rtc, RTC_CTRL_A, ctrla);
 
+		ctrlb = rtc->read(rtc, RTC_CTRL_B);
+
 		/*
 		 * Read Control 4A and check the status of the auxillary
 		 * battery.  This must be present and working (VRT2 = 1)
@@ -1411,13 +1413,17 @@ ds1685_rtc_poweroff(struct platform_device *pdev)
 
 			/*
 			 * The auxillary battery is present and working.
-			 * Enable extended functions (ABE=1), enable
-			 * wake-up (WIE=1), and enable kickstart (KSE=1)
-			 * in Control 4B.
+			 * Enable extended functions (ABE=1) and kickstart
+			 * (KSE=1) in Control 4B.  Enable wake-up (WIE=1) only
+			 * if an alarm is set, else stale alarm registers
+			 * can power the system back on.
 			 */
 			ctrl4b = rtc->read(rtc, RTC_EXT_CTRL_4B);
-			ctrl4b |= (RTC_CTRL_4B_ABE | RTC_CTRL_4B_WIE |
-				   RTC_CTRL_4B_KSE);
+			ctrl4b |= (RTC_CTRL_4B_ABE | RTC_CTRL_4B_KSE);
+			if (ctrlb & RTC_CTRL_B_AIE)
+				ctrl4b |= RTC_CTRL_4B_WIE;
+			else
+				ctrl4b &= ~(RTC_CTRL_4B_WIE);
 			rtc->write(rtc, RTC_EXT_CTRL_4B, ctrl4b);
 		}
 
Signature · 1 line
2.53.0
author maintainer
#2130 lore raw

PATCH 2128/2151 rtc: ds1685: do not sleep in the power-off handler

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Imre Kaloz <[email protected]>

[ Upstream commit 21a829af60a7f5c7456f1f0ff9b6b0eff0ceb738 ]

Power-off handlers run from an atomic notifier chain and must not sleep. Use mdelay() for the delay before setting PAB.

---
 drivers/rtc/rtc-ds1685.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ds1685.c +1 -1
index 7f84ea02c4038..4c7629b1f51f0 100644
@@ -1429,7 +1429,7 @@ ds1685_rtc_poweroff(struct platform_device *pdev)
 
 		/* Set PAB to 1 in Control 4A to power the system down. */
 		dev_warn(&pdev->dev, "Powerdown.\n");
-		msleep(20);
+		mdelay(20);
 		rtc->write(rtc, RTC_EXT_CTRL_4A,
 			   (ctrl4a | RTC_CTRL_4A_PAB));
 
Signature · 1 line
2.53.0
author maintainer
#2131 lore raw

PATCH 2129/2151 libbpf: fix cross-endian build with newer libbpf

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Dominique Martinet <[email protected]>

commit 087f3964f4b3 ("libbpf: Support layout section handling in BTF") added extra data to the BTF header.

This extra data is ignored in the native case, but when building with different endianness the bswap code in old libbpf would check for strict size equality, leading to build failures such as this when BTF data is generated with a newer version of libbpf (through pahole)
BTFIDS vmlinux.unstripped
libbpf: Can't load BTF with non-native endianness due to unsupported header length 32
FAILED: load BTF from vmlinux.unstripped: Operation not supported make[2]: *** [../scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 255

Newer libbpf versions also properly ignore trailing data in the bswap case, but the patch is too intrusive to backport, so take the header length comparison fix from it instead.

Fixes 3289959b97ca ("libbpf: Support BTF loading and raw data output in both endianness")
---
 tools/lib/bpf/btf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/bpf/btf.c +2 -2
index 7f3b23aeaaba7..4b0e99f6f5ce9 100644
@@ -229,14 +229,14 @@ static int btf_parse_hdr(struct btf *btf)
 	struct btf_header *hdr = btf->hdr;
 	__u32 meta_left;
 
-	if (btf->raw_size < sizeof(struct btf_header)) {
+	if (btf->raw_size < offsetofend(struct btf_header, str_len)) {
 		pr_debug("BTF header not found\n");
 		return -EINVAL;
 	}
 
 	if (hdr->magic == bswap_16(BTF_MAGIC)) {
 		btf->swapped_endian = true;
-		if (bswap_32(hdr->hdr_len) != sizeof(struct btf_header)) {
+		if (bswap_32(hdr->hdr_len) < offsetofend(struct btf_header, str_len)) {
 			pr_warn("Can't load BTF with non-native endianness due to unsupported header length %u\n",
 				bswap_32(hdr->hdr_len));
 			return -ENOTSUP;
Signature · 1 line
2.53.0
author maintainer
#2132 lore raw

PATCH 2130/2151 mm: fix OOM killer inaccuracy on large many-core systems

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Mathieu Desnoyers <[email protected]>

[ Upstream commit 5898aa8f9a0b42fe1f65c7364010ab15ec5c38bf ]

Use the precise, albeit slower, precise RSS counter sums for the OOM killer task selection and console dumps. The approximated value is too imprecise on large many-core systems.

The following rss tracking issues were noted by Sweet Tea Dorminy [1], which lead to picking wrong tasks as OOM kill target:

Recently, several internal services had an RSS usage regression as part of a kernel upgrade. Previously, they were on a pre-6.2 kernel and were able to read RSS statistics in a backup watchdog process to monitor and decide if they'd overrun their memory budget. Now, however, a representative service with five threads, expected to use about a hundred MB of memory, on a 250-cpu machine had memory usage tens of megabytes different from the expected amount -- this constituted a significant percentage of inaccuracy, causing the watchdog to act.

This was a result of commit f1a7941243c1 ("mm: convert mm's rss stats into percpu_counter") [1]. Previously, the memory error was bounded by 64*nr_threads pages, a very livable megabyte. Now, however, as a result of scheduler decisions moving the threads around the CPUs, the memory error could be as large as a gigabyte.

This is a really tremendous inaccuracy for any few-threaded program on a large machine and impedes monitoring significantly. These stat counters are also used to make OOM killing decisions, so this additional inaccuracy could make a big difference in OOM situations -- either resulting in the wrong process being killed, or in less memory being returned from an OOM-kill than expected.

Here is a (possibly incomplete) list of the prior approaches that were used or proposed, along with their downside:

1) Per-thread rss tracking: large error on many-thread processes.

2) Per-CPU counters: up to 12% slower for short-lived processes and 9% increased system time in make test workloads [1]. Moreover, the inaccuracy increases with O(n^2) with the number of CPUs.

3) Per-NUMA-node counters: requires atomics on fast-path (overhead), error is high with systems that have lots of NUMA nodes (32 times the number of NUMA nodes).

commit 82241a83cd15 ("mm: fix the inaccurate memory statistics issue for users") introduced get_mm_counter_sum() for precise proc memory status queries for some proc files.

The simple fix proposed here is to do the precise per-cpu counters sum every time a counter value needs to be read. This applies to the OOM killer task selection, oom task console dumps (printk).

This change increases the latency introduced when the OOM killer executes in favor of doing a more precise OOM target task selection. Effectively, the OOM killer iterates on all tasks, for all relevant page types, for which the precise sum iterates on all possible CPUs.

As a reference, here is the execution time of the OOM killer before/after the change:

AMD EPYC 9654 96-Core (2 sockets)
Within a KVM, configured with 256 logical cpus.

                                  |  before  |  after   |
----------------------------------|----------|----------|
nr_processes=40                   |  0.3 ms  |   0.5 ms |
nr_processes=10000                |  3.0 ms  |  80.0 ms |
Fixes f1a7941243c1 ("mm: convert mm's rss stats into percpu_counter")
Cc "Paul E. McKenney" <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Mathieu Desnoyers <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc Martin Liu <[email protected]>
Cc David Rientjes <[email protected]>
Cc Shakeel Butt <[email protected]>
Cc SeongJae Park <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Sweet Tea Dorminy <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc "Liam R . Howlett" <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Wei Yang <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Miaohe Lin <[email protected]>
Cc Al Viro <[email protected]>
Cc Yu Zhao <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc Mateusz Guzik <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Aboorva Devarajan <[email protected]>
[ Backported without changes ]
---
 include/linux/mm.h |  7 +++++++
 mm/oom_kill.c      | 22 +++++++++++-----------
 2 files changed, 18 insertions(+), 11 deletions(-)
include/linux/mm.h +7 -0
index 2c0503bbcc190..bc5771e26e1db 100644
@@ -2843,6 +2843,13 @@ static inline unsigned long get_mm_rss(struct mm_struct *mm)
 		get_mm_counter(mm, MM_SHMEMPAGES);
 }
 
+static inline unsigned long get_mm_rss_sum(struct mm_struct *mm)
+{
+	return get_mm_counter_sum(mm, MM_FILEPAGES) +
+		get_mm_counter_sum(mm, MM_ANONPAGES) +
+		get_mm_counter_sum(mm, MM_SHMEMPAGES);
+}
+
 static inline unsigned long get_mm_hiwater_rss(struct mm_struct *mm)
 {
 	return max(mm->hiwater_rss, get_mm_rss(mm));
mm/oom_kill.c +11 -11
index c145b0feecc1f..e6a69fa0b7b21 100644
@@ -228,7 +228,7 @@ long oom_badness(struct task_struct *p, unsigned long totalpages)
 	 * The baseline for the badness score is the proportion of RAM that each
 	 * task's rss, pagetable and swap space use.
 	 */
-	points = get_mm_rss(p->mm) + get_mm_counter(p->mm, MM_SWAPENTS) +
+	points = get_mm_rss_sum(p->mm) + get_mm_counter_sum(p->mm, MM_SWAPENTS) +
 		mm_pgtables_bytes(p->mm) / PAGE_SIZE;
 	task_unlock(p);
 
@@ -402,10 +402,10 @@ static int dump_task(struct task_struct *p, void *arg)
 
 	pr_info("[%7d] %5d %5d %8lu %8lu %8lu %8lu %9lu %8ld %8lu         %5hd %s\n",
 		task->pid, from_kuid(&init_user_ns, task_uid(task)),
-		task->tgid, task->mm->total_vm, get_mm_rss(task->mm),
-		get_mm_counter(task->mm, MM_ANONPAGES), get_mm_counter(task->mm, MM_FILEPAGES),
-		get_mm_counter(task->mm, MM_SHMEMPAGES), mm_pgtables_bytes(task->mm),
-		get_mm_counter(task->mm, MM_SWAPENTS),
+		task->tgid, task->mm->total_vm, get_mm_rss_sum(task->mm),
+		get_mm_counter_sum(task->mm, MM_ANONPAGES), get_mm_counter_sum(task->mm, MM_FILEPAGES),
+		get_mm_counter_sum(task->mm, MM_SHMEMPAGES), mm_pgtables_bytes(task->mm),
+		get_mm_counter_sum(task->mm, MM_SWAPENTS),
 		task->signal->oom_score_adj, task->comm);
 	task_unlock(task);
 
@@ -603,9 +603,9 @@ static bool oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)
 
 	pr_info("oom_reaper: reaped process %d (%s), now anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n",
 			task_pid_nr(tsk), tsk->comm,
-			K(get_mm_counter(mm, MM_ANONPAGES)),
-			K(get_mm_counter(mm, MM_FILEPAGES)),
-			K(get_mm_counter(mm, MM_SHMEMPAGES)));
+			K(get_mm_counter_sum(mm, MM_ANONPAGES)),
+			K(get_mm_counter_sum(mm, MM_FILEPAGES)),
+			K(get_mm_counter_sum(mm, MM_SHMEMPAGES)));
 out_finish:
 	trace_finish_task_reaping(tsk->pid);
 out_unlock:
@@ -959,9 +959,9 @@ static void __oom_kill_process(struct task_struct *victim, const char *message)
 	mark_oom_victim(victim);
 	pr_err("%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB, UID:%u pgtables:%lukB oom_score_adj:%hd\n",
 		message, task_pid_nr(victim), victim->comm, K(mm->total_vm),
-		K(get_mm_counter(mm, MM_ANONPAGES)),
-		K(get_mm_counter(mm, MM_FILEPAGES)),
-		K(get_mm_counter(mm, MM_SHMEMPAGES)),
+		K(get_mm_counter_sum(mm, MM_ANONPAGES)),
+		K(get_mm_counter_sum(mm, MM_FILEPAGES)),
+		K(get_mm_counter_sum(mm, MM_SHMEMPAGES)),
 		from_kuid(&init_user_ns, task_uid(victim)),
 		mm_pgtables_bytes(mm) >> 10, victim->signal->oom_score_adj);
 	task_unlock(victim);
Signature · 1 line
2.53.0
author maintainer
#2133 lore raw

PATCH 2131/2151 vdpa_sim: disable page faults around vringh_need_notify_iotlb()

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Linus Torvalds <[email protected]>

[ Upstream commit 05fb07c40e0013ba5ae373c6ea1bcc622eaea7f0 ]

When vdpa_sim runs with use_va (the default), its rings live in user memory, and vringh reads the ring's flags and event index with __get_user() through the user address. The net and block simulators call vringh_need_notify_iotlb() with bottom halves disabled, so those reads happen in atomic context.

That only works today because __get_user() has no might_fault() check: a fault is not handled in atomic context and simply comes back as -EFAULT. Make that explicit with pagefault_disable() around the call, so vringh can use the normal user accessors without complaint. Only the notification check needs this: the rest of the ring processing runs in the same kthread without bottom halves disabled, and can fault normally.

---
 drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 9 ++++++++-
 drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/vdpa/vdpa_sim/vdpa_sim_blk.c +8 -1
index 770a40a20be9d..0d5922ba05bcb 100644
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
+#include <linux/uaccess.h>
 #include <linux/blkdev.h>
 #include <linux/vringh.h>
 #include <linux/vdpa.h>
@@ -343,11 +344,17 @@ static void vdpasim_blk_work(struct vdpasim *vdpasim)
 			continue;
 
 		while (vdpasim_blk_handle_req(vdpasim, vq)) {
+			bool notify;
+
 			/* Make sure used is visible before rasing the interrupt. */
 			smp_wmb();
 
 			local_bh_disable();
-			if (vringh_need_notify_iotlb(&vq->vring) > 0)
+			/* The ring may be in user memory, and we can't take faults here */
+			pagefault_disable();
+			notify = vringh_need_notify_iotlb(&vq->vring) > 0;
+			pagefault_enable();
+			if (notify)
 				vringh_notify(&vq->vring);
 			local_bh_enable();
 
drivers/vdpa/vdpa_sim/vdpa_sim_net.c +8 -1
index b596d4a532d01..2271dd26da127 100644
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
+#include <linux/uaccess.h>
 #include <linux/etherdevice.h>
 #include <linux/vringh.h>
 #include <linux/vdpa.h>
@@ -68,6 +69,8 @@ static struct vdpasim_net *sim_to_net(struct vdpasim *vdpasim)
 
 static void vdpasim_net_complete(struct vdpasim_virtqueue *vq, size_t len)
 {
+	bool notify;
+
 	/* Make sure data is wrote before advancing index */
 	smp_wmb();
 
@@ -77,7 +80,11 @@ static void vdpasim_net_complete(struct vdpasim_virtqueue *vq, size_t len)
 	smp_wmb();
 
 	local_bh_disable();
-	if (vringh_need_notify_iotlb(&vq->vring) > 0)
+	/* The ring may be in user memory, and we can't take faults here */
+	pagefault_disable();
+	notify = vringh_need_notify_iotlb(&vq->vring) > 0;
+	pagefault_enable();
+	if (notify)
 		vringh_notify(&vq->vring);
 	local_bh_enable();
 }
Signature · 1 line
2.53.0
author maintainer
#2134 lore raw

PATCH 2132/2151 PCI/sysfs: Decouple acpi_index from the optional device name element

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Krzysztof Wilczyński <[email protected]>

[ Upstream commit 337bdf853101a0ee66eadf668f0fef21f8276b52 ]

The "_DSM for Naming a PCI or PCI Express Device Under Operating Systems" (PCI Firmware r3.3, sec 4.6.7) returns a package of two elements:

1) Instance number (mandatory Integer)
2) String name (optional String, null string if not populated)

These are exposed as sysfs 'acpi_index' and 'label'. Previously, if the name was malformed, reads of 'acpi_index' failed unnecessarily.

Validate each element only for the attribute that exports it. So "acpi_index" now depends on the instance number alone, and "label" reads fail with -EIO when the name element is neither a string nor a buffer. The package elements pointer is read only after the object type has been checked.

On platforms with a valid instance number and a malformed name element the "acpi_index" attribute starts returning data. Because udev derives the onboard interface name from "acpi_index", an interface on such a platform may be renamed once, on the first boot after this change. That is the attribute assuming the value the firmware always provided.

---
 drivers/pci/pci-label.c | 53 +++++++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 20 deletions(-)
drivers/pci/pci-label.c +33 -20
index f81248a11a18e..08c461f1142d7 100644
@@ -157,7 +157,7 @@ static int dsm_get_label(struct device *dev, char *buf,
 {
 	acpi_handle handle = ACPI_HANDLE(dev);
 	union acpi_object *obj, *tmp;
-	int len = 0;
+	int len;
 
 	if (!handle)
 		return -ENODEV;
@@ -167,30 +167,43 @@ static int dsm_get_label(struct device *dev, char *buf,
 	if (!obj)
 		return -EIO;
 
+	if (obj->type != ACPI_TYPE_PACKAGE || obj->package.count != 2) {
+		len = -EIO;
+		goto out;
+	}
+
 	tmp = obj->package.elements;
-	if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 2 &&
-	    tmp[0].type == ACPI_TYPE_INTEGER &&
-	    (tmp[1].type == ACPI_TYPE_STRING ||
-	     tmp[1].type == ACPI_TYPE_BUFFER)) {
-		/*
-		 * The second string element is optional even when
-		 * this _DSM is implemented; when not implemented,
-		 * this entry must return a null string.
-		 */
-		if (attr == ACPI_ATTR_INDEX_SHOW) {
-			len = sysfs_emit(buf, "%llu\n", tmp->integer.value);
-		} else if (attr == ACPI_ATTR_LABEL_SHOW) {
-			if (tmp[1].type == ACPI_TYPE_STRING)
-				len = sysfs_emit(buf, "%s\n",
-						 tmp[1].string.pointer);
-			else if (tmp[1].type == ACPI_TYPE_BUFFER)
-				len = dsm_label_utf16s_to_utf8s(tmp + 1, buf);
-		}
+	if (tmp[0].type != ACPI_TYPE_INTEGER) {
+		len = -EIO;
+		goto out;
 	}
 
+	if (attr == ACPI_ATTR_INDEX_SHOW) {
+		len = sysfs_emit(buf, "%llu\n", tmp[0].integer.value);
+		goto out;
+	}
+
+	/*
+	 * Per PCI Firmware r3.3, sec 4.6.7, the device name is optional
+	 * even when this _DSM is implemented. When not implemented, this
+	 * entry must return a NULL string.
+	 */
+	switch (tmp[1].type) {
+	case ACPI_TYPE_STRING:
+		len = sysfs_emit(buf, "%s\n", tmp[1].string.pointer);
+		break;
+	case ACPI_TYPE_BUFFER:
+		len = dsm_label_utf16s_to_utf8s(&tmp[1], buf);
+		break;
+	default:
+		len = -EIO;
+		break;
+	}
+
+out:
 	ACPI_FREE(obj);
 
-	return len > 0 ? len : -EIO;
+	return len;
 }
 
 static ssize_t label_show(struct device *dev, struct device_attribute *attr,
Signature · 1 line
2.53.0
author maintainer
#2135 lore raw

PATCH 2133/2151 scsi: core: Fix additional sense code definition

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Damien Le Moal <[email protected]>

commit 3b7ccba37858dd3d7d3780eb42ab943152e5b7ec upstream.

The ASC() macro used to define an additional sense code with no additional sense code qualifier conflicts with the ASC macro definition of the file arch/sparc/include/asm/ns87303.h, leading to compilation errors. Avoid this conflict by renaming the macro as SCSI_ASC() and the ASC_DEF() macro to SCSI_ASC_DEF() to be consistent.

---
 include/scsi/scsi_sense.h |  236 +++++++++++++++++++++++-----------------------
 1 file changed, 118 insertions(+), 118 deletions(-)
include/scsi/scsi_sense.h +118 -118
@@ -30,10 +30,10 @@ enum scsi_sense_key {
 	COMPLETED		= 0x0f,
 };
 
-#define ASC_DEF(name)	ASC_##name
-#define ASC(name, code)					\
-	ASC_DEF(name)	= (code),			\
-	name		= ((code) << 8) | 0x00
+#define SCSI_ASC_DEF(name)	ASC_##name
+#define SCSI_ASC(name, code)				\
+	SCSI_ASC_DEF(name)	= (code),		\
+	name			= ((code) << 8) | 0x00
 
 /*
  * SCSI additional sense codes and sense codes qualifiers.
@@ -49,7 +49,7 @@ enum scsi_sense_key {
  * are prefixed with "SSC_" (e.g. WARNING and WRITE_ERROR).
  */
 enum scsi_sense_code {
-	ASC(NO_ADDITIONAL_SENSE_INFORMATION,			0x00),
+	SCSI_ASC(NO_ADDITIONAL_SENSE_INFORMATION,		0x00),
 	FILEMARK_DETECTED					= 0x0001,
 	END_OF_PARTITION_MEDIUM_DETECTED			= 0x0002,
 	SETMARK_DETECTED					= 0x0003,
@@ -77,15 +77,15 @@ enum scsi_sense_code {
 	DEFERRED_MICROCODE_IS_PENDING				= 0x0022,
 	OVERLAPPING_ATOMIC_COMMAND_IN_PROGRESS			= 0x0023,
 
-	ASC(NO_INDEX_SECTOR_SIGNAL,				0x01),
+	SCSI_ASC(NO_INDEX_SECTOR_SIGNAL,			0x01),
 
-	ASC(NO_SEEK_COMPLETE,					0x02),
+	SCSI_ASC(NO_SEEK_COMPLETE,				0x02),
 
-	ASC(PERIPHERAL_DEVICE_WRITE_FAULT,			0x03),
+	SCSI_ASC(PERIPHERAL_DEVICE_WRITE_FAULT,			0x03),
 	NO_WRITE_CURRENT					= 0x0301,
 	EXCESSIVE_WRITE_ERRORS					= 0x0302,
 
-	ASC(LU_NOT_READY,					0x04),
+	SCSI_ASC(LU_NOT_READY,					0x04),
 	LU_IS_IN_PROCESS_OF_BECOMING_READY			= 0x0401,
 	LU_NOT_READY_INITIALIZING_COMMAND_REQUIRED		= 0x0402,
 	LU_NOT_READY_MANUAL_INTERVENTION_REQUIRED		= 0x0403,
@@ -123,28 +123,28 @@ enum scsi_sense_code {
 	DEPOPULATION_IN_PROGRESS				= 0x0424,
 	DEPOPULATION_RESTORATION_IN_PROGRESS			= 0x0425,
 
-	ASC(LU_DOES_NOT_RESPOND_TO_SELECTION,			0x05),
+	SCSI_ASC(LU_DOES_NOT_RESPOND_TO_SELECTION,		0x05),
 
-	ASC(NO_REFERENCE_POSITION_FOUND,			0x06),
+	SCSI_ASC(NO_REFERENCE_POSITION_FOUND,			0x06),
 
-	ASC(MULTIPLE_PERIPHERAL_DEVICES_SELECTED,		0x07),
+	SCSI_ASC(MULTIPLE_PERIPHERAL_DEVICES_SELECTED,		0x07),
 
-	ASC(LU_COMMUNICATION_FAILURE,				0x08),
+	SCSI_ASC(LU_COMMUNICATION_FAILURE,			0x08),
 	LU_COMMUNICATION_TIMEOUT				= 0x0801,
 	LU_COMMUNICATION_PARITY_ERROR				= 0x0802,
 	LU_COMMUNICATION_CRC_ERROR				= 0x0803,
 	UNREACHABLE_COPY_TARGET					= 0x0804,
 
-	ASC(TRACK_FOLLOWING_ERROR,				0x09),
+	SCSI_ASC(TRACK_FOLLOWING_ERROR,				0x09),
 	TRACKING_SERVO_FAILURE					= 0x0901,
 	FOCUS_SERVO_FAILURE					= 0x0902,
 	SPINDLE_SERVO_FAILURE					= 0x0903,
 	HEAD_SELECT_FAULT					= 0x0904,
 	VIBRATION_INDUCED_TRACKING_ERROR			= 0x0905,
 
-	ASC(ERROR_LOG_OVERFLOW,					0x0A),
+	SCSI_ASC(ERROR_LOG_OVERFLOW,				0x0A),
 
-	ASC(SSC_WARNING,					0x0B),
+	SCSI_ASC(SSC_WARNING,					0x0B),
 	WARNING_SPECIFIED_TEMPERATURE_EXCEEDED			= 0x0B01,
 	WARNING_ENCLOSURE_DEGRADED				= 0x0B02,
 	WARNING_BACKGROUND_SELFTEST_FAILED			= 0x0B03,
@@ -167,7 +167,7 @@ enum scsi_sense_code {
 	WARNING_PHYSICAL_ELEMENT_STATUS_CHANGE			= 0x0B14,
 
 	/* Defined as "WRITE ERROR" in T10. */
-	ASC(SSC_WRITE_ERROR,					0x0C),
+	SCSI_ASC(SSC_WRITE_ERROR,				0x0C),
 	WRITE_ERROR_RECOVERED_WITH_AUTO_REALLOCATION		= 0x0C01,
 	WRITE_ERROR_AUTO_REALLOCATION_FAILED			= 0x0C02,
 	WRITE_ERROR_RECOMMEND_REASSIGNMENT			= 0x0C03,
@@ -187,26 +187,26 @@ enum scsi_sense_code {
 	WRITE_ERROR_RECOVERY_SCAN_NEEDED			= 0x0C11,
 	WRITE_ERROR_INSUFFICIENT_ZONE_RESOURCES			= 0x0C12,
 
-	ASC(ERROR_DETECTED_BY_THIRD_PARTY_TEMPORARY_INITIATOR,	0x0D),
+	SCSI_ASC(ERROR_DETECTED_BY_THIRD_PARTY_TEMPORARY_INITIATOR, 0x0D),
 	THIRD_PARTY_DEVICE_FAILURE				= 0x0D01,
 	COPY_TARGET_DEVICE_NOT_REACHABLE			= 0x0D02,
 	INCORRECT_COPY_TARGET_DEVICE_TYPE			= 0x0D03,
 	COPY_TARGET_DEVICE_DATA_UNDERRUN			= 0x0D04,
 	COPY_TARGET_DEVICE_DATA_OVERRUN				= 0x0D05,
 
-	ASC(INVALID_INFORMATION_UNIT,				0x0E),
+	SCSI_ASC(INVALID_INFORMATION_UNIT,			0x0E),
 	INFORMATION_UNIT_TOO_SHORT				= 0x0E01,
 	INFORMATION_UNIT_TOO_LONG				= 0x0E02,
 	INVALID_FIELD_IN_COMMAND_INFORMATION_UNIT		= 0x0E03,
 
-	ASC(ID_CRC_OR_ECC_ERROR,				0x10),
+	SCSI_ASC(ID_CRC_OR_ECC_ERROR,				0x10),
 	LOGICAL_BLOCK_GUARD_CHECK_FAILED			= 0x1001,
 	LOGICAL_BLOCK_APPLICATION_TAG_CHECK_FAILED		= 0x1002,
 	LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED		= 0x1003,
 	LOGICAL_BLOCK_PROTECTION_ERROR_ON_RECOVER_BUFFERED_DATA	= 0x1004,
 	LOGICAL_BLOCK_PROTECTION_METHOD_ERROR			= 0x1005,
 
-	ASC(UNRECOVERED_READ_ERROR,				0x11),
+	SCSI_ASC(UNRECOVERED_READ_ERROR,			0x11),
 	READ_RETRIES_EXHAUSTED					= 0x1101,
 	ERROR_TOO_LONG_TO_CORRECT				= 0x1102,
 	MULTIPLE_READ_ERRORS					= 0x1103,
@@ -229,11 +229,11 @@ enum scsi_sense_code {
 	READ_ERROR_LBA_MARKED_BAD_BY_APPLICATION_CLIENT		= 0x1114,
 	WRITE_AFTER_SANITIZE_REQUIRED				= 0x1115,
 
-	ASC(ADDRESS_MARK_NOT_FOUND_FOR_ID_FIELD,		0x12),
+	SCSI_ASC(ADDRESS_MARK_NOT_FOUND_FOR_ID_FIELD,		0x12),
 
-	ASC(ADDRESS_MARK_NOT_FOUND_FOR_DATA_FIELD,		0x13),
+	SCSI_ASC(ADDRESS_MARK_NOT_FOUND_FOR_DATA_FIELD,		0x13),
 
-	ASC(RECORDED_ENTITY_NOT_FOUND,				0x14),
+	SCSI_ASC(RECORDED_ENTITY_NOT_FOUND,			0x14),
 	RECORD_NOT_FOUND					= 0x1401,
 	FILEMARK_OR_SETMARK_NOT_FOUND				= 0x1402,
 	END_OF_DATA_NOT_FOUND					= 0x1403,
@@ -242,17 +242,17 @@ enum scsi_sense_code {
 	RECORD_NOT_FOUND_DATA_AUTO_REALLOCATED			= 0x1406,
 	LOCATE_OPERATION_FAILURE				= 0x1407,
 
-	ASC(RANDOM_POSITIONING_ERROR,				0x15),
+	SCSI_ASC(RANDOM_POSITIONING_ERROR,			0x15),
 	MECHANICAL_POSITIONING_ERROR				= 0x1501,
 	POSITIONING_ERROR_DETECTED_BY_READ_OF_MEDIUM		= 0x1502,
 
-	ASC(DATA_SYNCHRONIZATION_MARK_ERROR,			0x16),
+	SCSI_ASC(DATA_SYNCHRONIZATION_MARK_ERROR,		0x16),
 	DATA_SYNC_ERROR_DATA_REWRITTEN				= 0x1601,
 	DATA_SYNC_ERROR_RECOMMEND_REWRITE			= 0x1602,
 	DATA_SYNC_ERROR_DATA_AUTO_REALLOCATED			= 0x1603,
 	DATA_SYNC_ERROR_RECOMMEND_REASSIGNMENT			= 0x1604,
 
-	ASC(RECOVERED_DATA_WITH_NO_ERROR_CORRECTION_APPLIED,	0x17),
+	SCSI_ASC(RECOVERED_DATA_WITH_NO_ERROR_CORRECTION_APPLIED, 0x17),
 	RECOVERED_DATA_WITH_RETRIES				= 0x1701,
 	RECOVERED_DATA_WITH_POSITIVE_HEAD_OFFSET		= 0x1702,
 	RECOVERED_DATA_WITH_NEGATIVE_HEAD_OFFSET		= 0x1703,
@@ -263,7 +263,7 @@ enum scsi_sense_code {
 	RECOVERED_DATA_WITHOUT_ECC_RECOMMEND_REWRITE		= 0x1708,
 	RECOVERED_DATA_WITHOUT_ECC_DATA_REWRITTEN		= 0x1709,
 
-	ASC(RECOVERED_DATA_WITH_ERROR_CORRECTION_APPLIED,	0x18),
+	SCSI_ASC(RECOVERED_DATA_WITH_ERROR_CORRECTION_APPLIED,	0x18),
 	RECOVERED_DATA_WITH_ERROR_CORRECTION_RETRIES_APPLIED	= 0x1801,
 	RECOVERED_DATA_DATA_AUTO_REALLOCATED			= 0x1802,
 	RECOVERED_DATA_WITH_CIRC				= 0x1803,
@@ -273,27 +273,27 @@ enum scsi_sense_code {
 	RECOVERED_DATA_WITH_ECC_DATA_REWRITTEN			= 0x1807,
 	RECOVERED_DATA_WITH_LINKING				= 0x1808,
 
-	ASC(DEFECT_LIST_ERROR,					0x19),
+	SCSI_ASC(DEFECT_LIST_ERROR,				0x19),
 	DEFECT_LIST_NOT_AVAILABLE				= 0x1901,
 	DEFECT_LIST_ERROR_IN_PRIMARY_LIST			= 0x1902,
 	DEFECT_LIST_ERROR_IN_GROWN_LIST				= 0x1903,
 
-	ASC(PARAMETER_LIST_LENGTH_ERROR,			0x1A),
+	SCSI_ASC(PARAMETER_LIST_LENGTH_ERROR,			0x1A),
 
-	ASC(SYNCHRONOUS_DATA_TRANSFER_ERROR,			0x1B),
+	SCSI_ASC(SYNCHRONOUS_DATA_TRANSFER_ERROR,		0x1B),
 
-	ASC(DEFECT_LIST_NOT_FOUND,				0x1C),
+	SCSI_ASC(DEFECT_LIST_NOT_FOUND,				0x1C),
 	PRIMARY_DEFECT_LIST_NOT_FOUND				= 0x1C01,
 	GROWN_DEFECT_LIST_NOT_FOUND				= 0x1C02,
 
-	ASC(MISCOMPARE_DURING_VERIFY_OPERATION,			0x1D),
+	SCSI_ASC(MISCOMPARE_DURING_VERIFY_OPERATION,		0x1D),
 	MISCOMPARE_VERIFY_OF_UNMAPPED_LBA			= 0x1D01,
 
-	ASC(RECOVERED_ID_WITH_ECC_CORRECTION,			0x1E),
+	SCSI_ASC(RECOVERED_ID_WITH_ECC_CORRECTION,		0x1E),
 
-	ASC(PARTIAL_DEFECT_LIST_TRANSFER,			0x1F),
+	SCSI_ASC(PARTIAL_DEFECT_LIST_TRANSFER,			0x1F),
 
-	ASC(INVALID_COMMAND_OP_CODE,				0x20),
+	SCSI_ASC(INVALID_COMMAND_OP_CODE,			0x20),
 	ACCESS_DENIED_INITIATOR_PENDING_ENROLLED		= 0x2001,
 	ACCESS_DENIED_NO_ACCESS_RIGHTS				= 0x2002,
 	ACCESS_DENIED_INVALID_MGMT_ID_KEY			= 0x2003,
@@ -309,7 +309,7 @@ enum scsi_sense_code {
 	NOT_A_SUBSIDIARY_LOGICAL_UNIT				= 0x200E,
 	NOT_A_CONGLOMERATE_LOGICAL_UNIT				= 0x200F,
 
-	ASC(LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE,			0x21),
+	SCSI_ASC(LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE,		0x21),
 	INVALID_ELEMENT_ADDRESS					= 0x2101,
 	INVALID_ADDRESS_FOR_WRITE				= 0x2102,
 	INVALID_WRITE_CROSSING_LAYER_JUMP			= 0x2103,
@@ -320,9 +320,9 @@ enum scsi_sense_code {
 	MISALIGNED_WRITE_COMMAND				= 0x2108,
 	ATTEMPT_TO_ACCESS_GAP_ZONE				= 0x2109,
 
-	ASC(ILLEGAL_FUNCTION,					0x22),
+	SCSI_ASC(ILLEGAL_FUNCTION,				0x22),
 
-	ASC(INVALID_TOKEN_OP,					0x23),
+	SCSI_ASC(INVALID_TOKEN_OP,				0x23),
 	INVALID_TOKEN_OP_UNSUPPORTED_TOKEN_TYPE			= 0x2301,
 	INVALID_TOKEN_OP_REMOTE_TOKEN_USAGE_NOT_SUPPORTED	= 0x2302,
 	INVALID_TOKEN_OP_REMOTE_ROD_TOKEN_CREATION_NOT_SUPPORTED = 0x2303,
@@ -334,7 +334,7 @@ enum scsi_sense_code {
 	INVALID_TOKEN_OP_TOKEN_DELETED				= 0x2309,
 	INVALID_TOKEN_OP_INVALID_TOKEN_LENGTH			= 0x230A,
 
-	ASC(INVALID_FIELD_IN_CDB,				0x24),
+	SCSI_ASC(INVALID_FIELD_IN_CDB,				0x24),
 	CDB_DECRYPTION_ERROR					= 0x2401,
 	SECURITY_AUDIT_VALUE_FROZEN				= 0x2404,
 	SECURITY_WORKING_KEY_FROZEN				= 0x2405,
@@ -343,9 +343,9 @@ enum scsi_sense_code {
 	INVALID_XCDB						= 0x2408,
 	INVALID_FAST_FORMAT					= 0x2409,
 
-	ASC(LU_NOT_SUPPORTED,					0x25),
+	SCSI_ASC(LU_NOT_SUPPORTED,				0x25),
 
-	ASC(INVALID_FIELD_IN_PARAMETER_LIST,			0x26),
+	SCSI_ASC(INVALID_FIELD_IN_PARAMETER_LIST,		0x26),
 	PARAMETER_NOT_SUPPORTED					= 0x2601,
 	PARAMETER_VALUE_INVALID					= 0x2602,
 	THRESHOLD_PARAMETERS_NOT_SUPPORTED			= 0x2603,
@@ -369,7 +369,7 @@ enum scsi_sense_code {
 	COPY_SOURCE_OR_COPY_DESTINATION_NOT_AUTHORIZED		= 0x2615,
 	FAST_COPY_NOT_POSSIBLE					= 0x2616,
 
-	ASC(WRITE_PROTECTED,					0x27),
+	SCSI_ASC(WRITE_PROTECTED,				0x27),
 	HW_WRITE_PROTECTED					= 0x2701,
 	LU_SOFTWARE_WRITE_PROTECTED				= 0x2702,
 	ASSOCIATED_WRITE_PROTECT				= 0x2703,
@@ -379,12 +379,12 @@ enum scsi_sense_code {
 	SPACE_ALLOCATION_FAILED_WRITE_PROTECT			= 0x2707,
 	ZONE_IS_READ_ONLY					= 0x2708,
 
-	ASC(NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED,	0x28),
+	SCSI_ASC(NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED, 0x28),
 	IMPORT_OR_EXPORT_ELEMENT_ACCESSED			= 0x2801,
 	FORMAT_LAYER_MAY_HAVE_CHANGED				= 0x2802,
 	IMPORT_EXPORT_ELEMENT_ACCESSED_MEDIUM_CHANGED		= 0x2803,
 
-	ASC(POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED,	0x29),
+	SCSI_ASC(POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED,	0x29),
 	POWER_ON_OCCURRED					= 0x2901,
 	SCSI_BUS_RESET_OCCURRED					= 0x2902,
 	BUS_DEVICE_RESET_FUNCTION_OCCURRED			= 0x2903,
@@ -393,7 +393,7 @@ enum scsi_sense_code {
 	TRANSCEIVER_MODE_CHANGED_TO_LVD				= 0x2906,
 	I_T_NEXUS_LOSS_OCCURRED					= 0x2907,
 
-	ASC(PARAMETERS_CHANGED,					0x2A),
+	SCSI_ASC(PARAMETERS_CHANGED,				0x2A),
 	MODE_PARAMETERS_CHANGED					= 0x2A01,
 	LOG_PARAMETERS_CHANGED					= 0x2A02,
 	RESERVATIONS_PREEMPTED					= 0x2A03,
@@ -415,9 +415,9 @@ enum scsi_sense_code {
 	MEDIUM_REMOVAL_PREVENTION_PREEMPTED			= 0x2A15,
 	ZONE_RESET_WRITE_POINTER_RECOMMENDED			= 0x2A16,
 
-	ASC(COPY_CANNOT_EXECUTE_SINCE_HOST_CANNOT_DISCONNECT,	0x2B),
+	SCSI_ASC(COPY_CANNOT_EXECUTE_SINCE_HOST_CANNOT_DISCONNECT, 0x2B),
 
-	ASC(COMMAND_SEQUENCE_ERROR,				0x2C),
+	SCSI_ASC(COMMAND_SEQUENCE_ERROR,			0x2C),
 	TOO_MANY_WINDOWS_SPECIFIED				= 0x2C01,
 	INVALID_COMBINATION_OF_WINDOWS_SPECIFIED		= 0x2C02,
 	CURRENT_PROGRAM_AREA_IS_NOT_EMPTY			= 0x2C03,
@@ -438,19 +438,19 @@ enum scsi_sense_code {
 	ZONE_IS_INACTIVE					= 0x2C12,
 	WELL_KNOWN_LU_ACCESS_REQUIRED				= 0x2C13,
 
-	ASC(OVERWRITE_ERROR_ON_UPDATE_IN_PLACE,			0x2D),
+	SCSI_ASC(OVERWRITE_ERROR_ON_UPDATE_IN_PLACE,		0x2D),
 
-	ASC(INSUFFICIENT_TIME_FOR_OPERATION,			0x2E),
+	SCSI_ASC(INSUFFICIENT_TIME_FOR_OPERATION,		0x2E),
 	COMMAND_TIMEOUT_BEFORE_PROCESSING			= 0x2E01,
 	COMMAND_TIMEOUT_DURING_PROCESSING			= 0x2E02,
 	COMMAND_TIMEOUT_DURING_PROCESSING_DUE_TO_ERROR_RECOVERY	= 0x2E03,
 
-	ASC(COMMANDS_CLEARED_BY_ANOTHER_INITIATOR,		0x2F),
+	SCSI_ASC(COMMANDS_CLEARED_BY_ANOTHER_INITIATOR,		0x2F),
 	COMMANDS_CLEARED_BY_POWER_LOSS_NOTIFICATION		= 0x2F01,
 	COMMANDS_CLEARED_BY_DEVICE_SERVER			= 0x2F02,
 	SOME_COMMANDS_CLEARED_BY_QUEUING_LAYER_EVENT		= 0x2F03,
 
-	ASC(INCOMPATIBLE_MEDIUM_INSTALLED,			0x30),
+	SCSI_ASC(INCOMPATIBLE_MEDIUM_INSTALLED,			0x30),
 	CANNOT_READ_MEDIUM_UNKNOWN_FORMAT			= 0x3001,
 	CANNOT_READ_MEDIUM_INCOMPATIBLE_FORMAT			= 0x3002,
 	CLEANING_CARTRIDGE_INSTALLED				= 0x3003,
@@ -468,32 +468,32 @@ enum scsi_sense_code {
 	INCOMPATIBLE_VOLUME_QUALIFIER				= 0x3012,
 	CLEANING_VOLUME_EXPIRED					= 0x3013,
 
-	ASC(MEDIUM_FORMAT_CORRUPTED,				0x31),
+	SCSI_ASC(MEDIUM_FORMAT_CORRUPTED,			0x31),
 	FORMAT_COMMAND_FAILED					= 0x3101,
 	ZONED_FORMATTING_FAILED_DUE_TO_SPARE_LINKING		= 0x3102,
 	SANITIZE_COMMAND_FAILED					= 0x3103,
 	DEPOPULATION_FAILED					= 0x3104,
 	DEPOPULATION_RESTORATION_FAILED				= 0x3105,
 
-	ASC(NO_DEFECT_SPARE_LOCATION_AVAILABLE,			0x32),
+	SCSI_ASC(NO_DEFECT_SPARE_LOCATION_AVAILABLE,		0x32),
 	DEFECT_LIST_UPDATE_FAILURE				= 0x3201,
 
-	ASC(TAPE_LENGTH_ERROR,					0x33),
+	SCSI_ASC(TAPE_LENGTH_ERROR,				0x33),
 
-	ASC(ENCLOSURE_FAILURE,					0x34),
+	SCSI_ASC(ENCLOSURE_FAILURE,				0x34),
 
-	ASC(ENCLOSURE_SERVICES_FAILURE,				0x35),
+	SCSI_ASC(ENCLOSURE_SERVICES_FAILURE,			0x35),
 	UNSUPPORTED_ENCLOSURE_FUNCTION				= 0x3501,
 	ENCLOSURE_SERVICES_UNAVAILABLE				= 0x3502,
 	ENCLOSURE_SERVICES_TRANSFER_FAILURE			= 0x3503,
 	ENCLOSURE_SERVICES_TRANSFER_REFUSED			= 0x3504,
 	ENCLOSURE_SERVICES_CHECKSUM_ERROR			= 0x3505,
 
-	ASC(RIBBON_INK_OR_TONER_FAILURE,			0x36),
+	SCSI_ASC(RIBBON_INK_OR_TONER_FAILURE,			0x36),
 
-	ASC(ROUNDED_PARAMETER,					0x37),
+	SCSI_ASC(ROUNDED_PARAMETER,				0x37),
 
-	ASC(EVENT_STATUS_NOTIFICATION,				0x38),
+	SCSI_ASC(EVENT_STATUS_NOTIFICATION,			0x38),
 	ESN_POWER_MANAGEMENT_CLASS_EVENT			= 0x3802,
 	ESN_MEDIA_CLASS_EVENT					= 0x3804,
 	ESN_DEVICE_BUSY_CLASS_EVENT				= 0x3806,
@@ -501,15 +501,15 @@ enum scsi_sense_code {
 	DEPOPULATION_INTERRUPTED				= 0x3808,
 	DEPOPULATION_RESTORATION_INTERRUPTED			= 0x3809,
 
-	ASC(SAVING_PARAMETERS_NOT_SUPPORTED,			0x39),
+	SCSI_ASC(SAVING_PARAMETERS_NOT_SUPPORTED,		0x39),
 
-	ASC(MEDIUM_NOT_PRESENT,					0x3A),
+	SCSI_ASC(MEDIUM_NOT_PRESENT,				0x3A),
 	MEDIUM_NOT_PRESENT_TRAY_CLOSED				= 0x3A01,
 	MEDIUM_NOT_PRESENT_TRAY_OPEN				= 0x3A02,
 	MEDIUM_NOT_PRESENT_LOADABLE				= 0x3A03,
 	MEDIUM_NOT_PRESENT_MEDIUM_AUXILIARY_MEMORY_ACCESSIBLE	= 0x3A04,
 
-	ASC(SEQUENTIAL_POSITIONING_ERROR,			0x3B),
+	SCSI_ASC(SEQUENTIAL_POSITIONING_ERROR,			0x3B),
 	TAPE_POSITION_ERROR_AT_BEGINNING_OF_MEDIUM		= 0x3B01,
 	TAPE_POSITION_ERROR_AT_END_OF_MEDIUM			= 0x3B02,
 	TAPE_OR_ELECTRONIC_VERTICAL_FORMS_UNIT_NOT_READY	= 0x3B03,
@@ -539,15 +539,15 @@ enum scsi_sense_code {
 	TOO_MANY_LOGICAL_OBJECTS_ON_PARTITION_TO_SUPPORT_OP	= 0x3B1C,
 	ELEMENT_STATIC_INFORMATION_CHANGED			= 0x3B20,
 
-	ASC(INVALID_BITS_IN_IDENTIFY_MESSAGE,			0x3D),
+	SCSI_ASC(INVALID_BITS_IN_IDENTIFY_MESSAGE,		0x3D),
 
-	ASC(LU_HAS_NOT_SELF_CONFIGURED_YET,			0x3E),
+	SCSI_ASC(LU_HAS_NOT_SELF_CONFIGURED_YET,		0x3E),
 	LU_FAILURE						= 0x3E01,
 	TIMEOUT_ON_LOGICAL_UNIT					= 0x3E02,
 	LU_FAILED_SELF_TEST					= 0x3E03,
 	LU_UNABLE_TO_UPDATE_SELFTEST_LOG			= 0x3E04,
 
-	ASC(TARGET_OPERATING_CONDITIONS_HAVE_CHANGED,		0x3F),
+	SCSI_ASC(TARGET_OPERATING_CONDITIONS_HAVE_CHANGED,	0x3F),
 	MICROCODE_HAS_BEEN_CHANGED				= 0x3F01,
 	CHANGED_OPERATING_DEFINITION				= 0x3F02,
 	INQUIRY_DATA_HAS_CHANGED				= 0x3F03,
@@ -575,24 +575,24 @@ enum scsi_sense_code {
 	BIND_REDIRECTED						= 0x3F19,
 	SUBSIDIARY_BINDING_CHANGED				= 0x3F1A,
 
-	ASC(RAM_FAILURE,					0x40),
+	SCSI_ASC(RAM_FAILURE,					0x40),
 	/* DIAGNOSTIC_FAILURE_ON_COMPONENT_NN			= 0x40NN */
 
-	ASC(DATA_PATH_FAILURE,					0x41),
+	SCSI_ASC(DATA_PATH_FAILURE,				0x41),
 
-	ASC(POWER_ON_OR_SELFTEST_FAILURE,			0x42),
+	SCSI_ASC(POWER_ON_OR_SELFTEST_FAILURE,			0x42),
 
-	ASC(MESSAGE_ERROR,					0x43),
+	SCSI_ASC(MESSAGE_ERROR,					0x43),
 
-	ASC(INTERNAL_TARGET_FAILURE,				0x44),
+	SCSI_ASC(INTERNAL_TARGET_FAILURE,			0x44),
 	PERSISTENT_RESERVATION_INFORMATION_LOST			= 0x4401,
 	ATA_DEVICE_FAILED_SET_FEATURES				= 0x4471,
 
-	ASC(SELECT_OR_RESELECT_FAILURE,				0x45),
+	SCSI_ASC(SELECT_OR_RESELECT_FAILURE,			0x45),
 
-	ASC(UNSUCCESSFUL_SOFT_RESET,				0x46),
+	SCSI_ASC(UNSUCCESSFUL_SOFT_RESET,			0x46),
 
-	ASC(SCSI_PARITY_ERROR,					0x47),
+	SCSI_ASC(SCSI_PARITY_ERROR,				0x47),
 	DATA_PHASE_CRC_ERROR_DETECTED				= 0x4701,
 	SCSI_PARITY_ERROR_DETECTED_DURING_ST_DATA_PHASE		= 0x4702,
 	INFORMATION_UNIT_iuCRC_ERROR_DETECTED			= 0x4703,
@@ -601,13 +601,13 @@ enum scsi_sense_code {
 	PHY_TEST_FUNCTION_IN_PROGRESS				= 0x4706,
 	SOME_COMMANDS_CLEARED_BY_ISCSI_PROTOCOL_EVENT		= 0x477F,
 
-	ASC(INITIATOR_DETECTED_ERROR_MESSAGE_RECEIVED,		0x48),
+	SCSI_ASC(INITIATOR_DETECTED_ERROR_MESSAGE_RECEIVED,	0x48),
 
-	ASC(INVALID_MESSAGE_ERROR,				0x49),
+	SCSI_ASC(INVALID_MESSAGE_ERROR,				0x49),
 
-	ASC(COMMAND_PHASE_ERROR,				0x4A),
+	SCSI_ASC(COMMAND_PHASE_ERROR,				0x4A),
 
-	ASC(DATA_PHASE_ERROR,					0x4B),
+	SCSI_ASC(DATA_PHASE_ERROR,				0x4B),
 	INVALID_TARGET_PORT_TRANSFER_TAG_RECEIVED		= 0x4B01,
 	TOO_MUCH_WRITE_DATA					= 0x4B02,
 	ACK_NAK_TIMEOUT						= 0x4B03,
@@ -630,22 +630,22 @@ enum scsi_sense_code {
 	PCIE_ACS_VIOLATION					= 0x4B14,
 	PCIE_TLP_PREFIX_BLOCKED					= 0x4B15,
 
-	ASC(LU_FAILED_SELF_CONFIGURATION,			0x4C),
+	SCSI_ASC(LU_FAILED_SELF_CONFIGURATION,			0x4C),
 
-	ASC(TAGGED_OVERLAPPED_COMMANDS,				0x4D),
+	SCSI_ASC(TAGGED_OVERLAPPED_COMMANDS,			0x4D),
 
-	ASC(OVERLAPPED_COMMANDS_ATTEMPTED,			0x4E),
+	SCSI_ASC(OVERLAPPED_COMMANDS_ATTEMPTED,			0x4E),
 
-	ASC(WRITE_APPEND_ERROR,					0x50),
+	SCSI_ASC(WRITE_APPEND_ERROR,				0x50),
 	WRITE_APPEND_POSITION_ERROR				= 0x5001,
 	POSITION_ERROR_RELATED_TO_TIMING			= 0x5002,
 
-	ASC(ERASE_FAILURE,					0x51),
+	SCSI_ASC(ERASE_FAILURE,					0x51),
 	ERASE_FAILURE_INCOMPLETE_ERASE_OP_DETECTED		= 0x5101,
 
-	ASC(CARTRIDGE_FAULT,					0x52),
+	SCSI_ASC(CARTRIDGE_FAULT,				0x52),
 
-	ASC(MEDIA_LOAD_OR_EJECT_FAILED,				0x53),
+	SCSI_ASC(MEDIA_LOAD_OR_EJECT_FAILED,			0x53),
 	UNLOAD_TAPE_FAILURE					= 0x5301,
 	MEDIUM_REMOVAL_PREVENTED				= 0x5302,
 	MEDIUM_REMOVAL_PREVENTED_BY_DATA_TRANSFER_ELEMENT	= 0x5303,
@@ -660,9 +660,9 @@ enum scsi_sense_code {
 	DATA_TRANSFER_DEVICE_ERR_EJECT_FAILED			= 0x530C,
 	DATA_TRANSFER_DEVICE_ERR_LIBRARY_COMMUNICATION_FAILED	= 0x530D,
 
-	ASC(SCSI_TO_HOST_SYSTEM_INTERFACE_FAILURE,		0x54),
+	SCSI_ASC(SCSI_TO_HOST_SYSTEM_INTERFACE_FAILURE,		0x54),
 
-	ASC(SYSTEM_RESOURCE_FAILURE,				0x55),
+	SCSI_ASC(SYSTEM_RESOURCE_FAILURE,			0x55),
 	SYSTEM_BUFFER_FULL					= 0x5501,
 	INSUFFICIENT_RESERVATION_RESOURCES			= 0x5502,
 	INSUFFICIENT_RESOURCES					= 0x5503,
@@ -681,27 +681,27 @@ enum scsi_sense_code {
 	MAXIMUM_NUMBER_OF_STREAMS_OPEN				= 0x5510,
 	INSUFFICIENT_RESOURCES_TO_BIND				= 0x5511,
 
-	ASC(UNABLE_TO_RECOVER_TABLE_OF_CONTENTS,		0x57),
+	SCSI_ASC(UNABLE_TO_RECOVER_TABLE_OF_CONTENTS,		0x57),
 
-	ASC(GENERATION_DOES_NOT_EXIST,				0x58),
+	SCSI_ASC(GENERATION_DOES_NOT_EXIST,			0x58),
 
-	ASC(UPDATED_BLOCK_READ,					0x59),
+	SCSI_ASC(UPDATED_BLOCK_READ,				0x59),
 
-	ASC(OPERATOR_REQUEST_OR_STATE_CHANGE_INPUT,		0x5A),
+	SCSI_ASC(OPERATOR_REQUEST_OR_STATE_CHANGE_INPUT,	0x5A),
 	OPERATOR_MEDIUM_REMOVAL_REQUEST				= 0x5A01,
 	OPERATOR_SELECTED_WRITE_PROTECT				= 0x5A02,
 	OPERATOR_SELECTED_WRITE_PERMIT				= 0x5A03,
 
-	ASC(LOG_EXCEPTION,					0x5B),
+	SCSI_ASC(LOG_EXCEPTION,					0x5B),
 	THRESHOLD_CONDITION_MET					= 0x5B01,
 	LOG_COUNTER_AT_MAXIMUM					= 0x5B02,
 	LOG_LIST_CODES_EXHAUSTED				= 0x5B03,
 
-	ASC(RPL_STATUS_CHANGE,					0x5C),
+	SCSI_ASC(RPL_STATUS_CHANGE,				0x5C),
 	SPINDLES_SYNCHRONIZED					= 0x5C01,
 	SPINDLES_NOT_SYNCHRONIZED				= 0x5C02,
 
-	ASC(FAILURE_PREDICTION_THRESHOLD_EXCEEDED,		0x5D),
+	SCSI_ASC(FAILURE_PREDICTION_THRESHOLD_EXCEEDED,		0x5D),
 	MEDIA_FAILURE_PREDICTION_THRESHOLD_EXCEEDED		= 0x5D01,
 	LU_FAILURE_PREDICTION_THRESHOLD_EXCEEDED		= 0x5D02,
 	SPARE_AREA_EXHAUSTION_PREDICTION_THRESHOLD_EXCEEDED	= 0x5D03,
@@ -787,7 +787,7 @@ enum scsi_sense_code {
 	MEDIA_IMPENDING_FAILURE_ENDURANCE_LIMIT_MET		= 0x5D73,
 	FAILURE_PREDICTION_THRESHOLD_EXCEEDED_FALSE		= 0x5DFF,
 
-	ASC(LOW_POWER_CONDITION_ON,				0x5E),
+	SCSI_ASC(LOW_POWER_CONDITION_ON,			0x5E),
 	IDLE_CONDITION_ACTIVATED_BY_TIMER			= 0x5E01,
 	STANDBY_CONDITION_ACTIVATED_BY_TIMER			= 0x5E02,
 	IDLE_CONDITION_ACTIVATED_BY_COMMAND			= 0x5E03,
@@ -804,28 +804,28 @@ enum scsi_sense_code {
 	POWER_STATE_CHANGE_TO_SLEEP				= 0x5E45,
 	POWER_STATE_CHANGE_TO_DEVICE_CONTROL			= 0x5E47,
 
-	ASC(LAMP_FAILURE,					0x60),
+	SCSI_ASC(LAMP_FAILURE,					0x60),
 
-	ASC(VIDEO_ACQUISITION_ERROR,				0x61),
+	SCSI_ASC(VIDEO_ACQUISITION_ERROR,			0x61),
 	UNABLE_TO_ACQUIRE_VIDEO					= 0x6101,
 	OUT_OF_FOCUS						= 0x6102,
 
-	ASC(SCAN_HEAD_POSITIONING_ERROR,			0x62),
+	SCSI_ASC(SCAN_HEAD_POSITIONING_ERROR,			0x62),
 
-	ASC(END_OF_USER_AREA_ENCOUNTERED_ON_THIS_TRACK,		0x63),
+	SCSI_ASC(END_OF_USER_AREA_ENCOUNTERED_ON_THIS_TRACK,	0x63),
 	PACKET_DOES_NOT_FIT_IN_AVAILABLE_SPACE			= 0x6301,
 
-	ASC(ILLEGAL_MODE_FOR_THIS_TRACK,			0x64),
+	SCSI_ASC(ILLEGAL_MODE_FOR_THIS_TRACK,			0x64),
 	INVALID_PACKET_SIZE					= 0x6401,
 
-	ASC(VOLTAGE_FAULT,					0x65),
+	SCSI_ASC(VOLTAGE_FAULT,					0x65),
 
-	ASC(AUTOMATIC_DOCUMENT_FEEDER_COVER_UP,			0x66),
+	SCSI_ASC(AUTOMATIC_DOCUMENT_FEEDER_COVER_UP,		0x66),
 	AUTOMATIC_DOCUMENT_FEEDER_LIFT_UP			= 0x6601,
 	DOCUMENT_JAM_IN_AUTOMATIC_DOCUMENT_FEEDER		= 0x6602,
 	DOCUMENT_MISS_FEED_AUTOMATIC_IN_DOCUMENT_FEEDER		= 0x6603,
 
-	ASC(CONFIG_FAILURE,					0x67),
+	SCSI_ASC(CONFIG_FAILURE,				0x67),
 	CONFIG_OF_INCAPABLE_LOGICAL_UNITS_FAILED		= 0x6701,
 	ADD_LU_FAILED						= 0x6702,
 	MODIFICATION_OF_LU_FAILED				= 0x6703,
@@ -841,26 +841,26 @@ enum scsi_sense_code {
 	EXPLICIT_BIND_NOT_ALLOWED				= 0x670D,
 	FEATURE_NOT_ENABLED					= 0x670E,
 
-	ASC(LU_NOT_CONFIGURED,					0x68),
+	SCSI_ASC(LU_NOT_CONFIGURED,				0x68),
 	SUBSIDIARY_LU_NOT_CONFIGURED				= 0x6801,
 
-	ASC(DATA_LOSS_ON_LOGICAL_UNIT,				0x69),
+	SCSI_ASC(DATA_LOSS_ON_LOGICAL_UNIT,			0x69),
 	MULTIPLE_LU_FAILURES					= 0x6901,
 	PARITY_DATA_MISMATCH					= 0x6902,
 
-	ASC(INFORMATIONAL_REFER_TO_LOG,				0x6A),
+	SCSI_ASC(INFORMATIONAL_REFER_TO_LOG,			0x6A),
 
-	ASC(STATE_CHANGE_HAS_OCCURRED,				0x6B),
+	SCSI_ASC(STATE_CHANGE_HAS_OCCURRED,			0x6B),
 	REDUNDANCY_LEVEL_GOT_BETTER				= 0x6B01,
 	REDUNDANCY_LEVEL_GOT_WORSE				= 0x6B02,
 
-	ASC(REBUILD_FAILURE_OCCURRED,				0x6C),
+	SCSI_ASC(REBUILD_FAILURE_OCCURRED,			0x6C),
 
-	ASC(RECALCULATE_FAILURE_OCCURRED,			0x6D),
+	SCSI_ASC(RECALCULATE_FAILURE_OCCURRED,			0x6D),
 
-	ASC(COMMAND_TO_LU_FAILED,				0x6E),
+	SCSI_ASC(COMMAND_TO_LU_FAILED,				0x6E),
 
-	ASC(COPY_PROTECTION_KEY_EXCHANGE_FAILURE_AUTHENTICATION_FAILURE, 0x6F),
+	SCSI_ASC(COPY_PROTECTION_KEY_EXCHANGE_FAILURE_AUTHENTICATION_FAILURE, 0x6F),
 	COPY_PROTECTION_KEY_EXCHANGE_FAILURE_KEY_NOT_PRESENT	= 0x6F01,
 	COPY_PROTECTION_KEY_EXCHANGE_FAILURE_KEY_NOT_ESTABLISHED = 0x6F02,
 	READ_OF_SCRAMBLED_SECTOR_WITHOUT_AUTHENTICATION		= 0x6F03,
@@ -872,11 +872,11 @@ enum scsi_sense_code {
 	INVALID_DRIVE_HOST_PAIRING_SERVER			= 0x6F09,
 	DRIVE_HOST_PAIRING_SUSPENDED				= 0x6F0A,
 
-	ASC(DECOMPRESSION_EXCEPTION_SHORT_ALGORITHM_ID,		0x70),
+	SCSI_ASC(DECOMPRESSION_EXCEPTION_SHORT_ALGORITHM_ID,	0x70),
 
-	ASC(DECOMPRESSION_EXCEPTION_LONG_ALGORITHM_ID,		0x71),
+	SCSI_ASC(DECOMPRESSION_EXCEPTION_LONG_ALGORITHM_ID,	0x71),
 
-	ASC(SESSION_FIXATION_ERROR,				0x72),
+	SCSI_ASC(SESSION_FIXATION_ERROR,			0x72),
 	SESSION_FIXATION_ERROR_WRITING_LEAD_IN			= 0x7201,
 	SESSION_FIXATION_ERROR_WRITING_LEAD_OUT			= 0x7202,
 	SESSION_FIXATION_ERROR_INCOMPLETE_TRACK_IN_SESSION	= 0x7203,
@@ -885,7 +885,7 @@ enum scsi_sense_code {
 	RMZ_EXTENSION_IS_NOT_ALLOWED				= 0x7206,
 	NO_MORE_TEST_ZONE_EXTENSIONS_ARE_ALLOWED		= 0x7207,
 
-	ASC(CD_CONTROL_ERROR,					0x73),
+	SCSI_ASC(CD_CONTROL_ERROR,				0x73),
 	POWER_CALIBRATION_AREA_ALMOST_FULL			= 0x7301,
 	POWER_CALIBRATION_AREA_IS_FULL				= 0x7302,
 	POWER_CALIBRATION_AREA_ERROR				= 0x7303,
@@ -896,7 +896,7 @@ enum scsi_sense_code {
 	CURRENT_POWER_CALIBRATION_AREA_IS_FULL			= 0x7311,
 	RDZ_IS_FULL						= 0x7317,
 
-	ASC(SECURITY_ERROR,					0x74),
+	SCSI_ASC(SECURITY_ERROR,				0x74),
 	UNABLE_TO_DECRYPT_DATA					= 0x7401,
 	UNENCRYPTED_DATA_ENCOUNTERED_WHILE_DECRYPTING		= 0x7402,
 	INCORRECT_DATA_ENCRYPTION_KEY				= 0x7403,
@@ -926,8 +926,8 @@ enum scsi_sense_code {
 	SECURITY_CONFLICT_IN_TRANSLATED_DEVICE			= 0x7479,
 };
 
-#undef ASC_DEF
-#undef ASC
+#undef SCSI_ASC_DEF
+#undef SCSI_ASC
 
 /*
  * Use this to build non-standard sense codes.
author maintainer
#2136 lore raw

PATCH 2134/2151 kernfs: avoid READ_ONCE() on a kgid_t in kernfs_new_node()

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Shakeel Butt <[email protected]>

commit ef179363b04306dbc645c53207b9ad3516ebc75f upstream.

kernfs_new_node() reads the parent's gid with READ_ONCE(attrs->ia_gid). That gid is a kgid_t, which is a struct.

On SMP alpha, READ_ONCE() ends by casting the value it loaded back to the type of its argument. Here that is a cast from a struct to the same struct. GCC accepts that as an extension, but ISO C does not allow a cast to or from a struct type, so sparse warns:

fs/kernfs/dir.c:751:31: sparse: sparse: cast to non-scalar fs/kernfs/dir.c:751:31: sparse: sparse: cast from non-scalar

Read the gid_t inside the kgid_t instead, and wrap it back up with KGIDT_INIT(). This is still a single marked load of the same four bytes.

There is no functional change. With GCC 12 for alpha (the config from the report) and GCC 14 for x86-64 (with and without KCSAN), fs/kernfs/dir.o has the same object code before and after this change.

---
 fs/kernfs/dir.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/kernfs/dir.c +1 -1
@@ -714,7 +714,7 @@ struct kernfs_node *kernfs_new_node(stru
 		struct kernfs_iattrs *attrs = READ_ONCE(parent->iattr);
 
 		if (attrs)
-			gid = READ_ONCE(attrs->ia_gid);
+			gid = KGIDT_INIT(READ_ONCE(attrs->ia_gid.val));
 
 		if (flags & KERNFS_DIR)
 			mode |= S_ISGID;
author maintainer
#2137 lore raw

PATCH 2135/2151 zloop: fix block size query

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Christoph Hellwig <[email protected]>

commit 8fbee85a90789d367c347b1cfd5a5ef37f3a934a upstream.

The block size obviously needs to be queried when it is not set, not when it already is set.

Reported: Damien Le Moal <[email protected]>

Fixes 5e9929e2f03c ("zloop: share more code for opening a zone backing file")
---
 drivers/block/zloop.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/zloop.c +1 -1
@@ -841,7 +841,7 @@ static int zloop_init_zone(struct zloop_
 		goto out_fput;
 	}
 
-	if (zlo->block_size) {
+	if (!zlo->block_size) {
 		ret = zloop_get_block_size(zlo, zone);
 		if (ret)
 			goto out_fput;
author maintainer
#2138 lore raw

PATCH 2136/2151 nvmet-auth: reject incomplete DHCHAP messages

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jérémy Jean <[email protected]>

commit 29e027774324dbd5321a67bbd16840e8f7bcd189 upstream.

Commit c9359401036e ("nvmet-auth: reject undersized AUTH_SEND payloads") only ensures that AUTH_SEND has auth_type and auth_id before nvmet_execute_auth_send() starts parsing the payload, but the DHCHAP path reads t_id before it verifies message lengths. A two-byte DHCHAP NEGOTIATE payload can therefore still trigger an OOB read that KASAN reports as:

  BUG: KASAN: slab-out-of-bounds in nvmet_execute_auth_send
  Read of size 2 at addr ffff8880030d8364

Require the payload to cover the minimum DHCHAP message length before parsing it.

Fixes c9359401036e ("nvmet-auth: reject undersized AUTH_SEND payloads")
---
 drivers/nvme/target/fabrics-cmd-auth.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/fabrics-cmd-auth.c +1 -1
@@ -303,7 +303,7 @@ void nvmet_execute_auth_send(struct nvme
 		nvmet_check_transfer_len(req, tl);
 		return;
 	}
-	if (tl < offsetof(struct nvmf_auth_dhchap_success2_data, rsvd1)) {
+	if (tl < sizeof(struct nvmf_auth_dhchap_failure_data)) {
 		status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
 		req->error_loc =
 			offsetof(struct nvmf_auth_send_command, tl);
author maintainer
#2139 lore raw

PATCH 2137/2151 PM: runtime: Only queue an idle check for RPM-linked suppliers (part 2)

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Brian Norris <[email protected]>

commit bd56424ce808fb1f92a4dc5bdeedc45b85c5d6cd upstream.

Commit be5755f023e7 ("PM: runtime: Only queue an idle check for RPM-linked suppliers") was incomplete. There are two other cases where we perform idle checks on non-DL_FLAG_PM_RUNTIME suppliers -- in pm_runtime_set_suspended(), and in cases where we failed to resume suppliers.

Fixes be5755f023e7 ("PM: runtime: Only queue an idle check for RPM-linked suppliers")
Fixes 5244f5e2d801 ("PM: runtime: Defer suspending suppliers")
---
 drivers/base/power/runtime.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/base/power/runtime.c +3 -0
@@ -343,6 +343,9 @@ static void __rpm_put_suppliers(struct d
 
 	list_for_each_entry_rcu(link, &dev->links.suppliers, c_node,
 				device_links_read_lock_held()) {
+		if (!device_link_test(link, DL_FLAG_PM_RUNTIME))
+			continue;
+
 		pm_runtime_release_supplier(link);
 		if (try_to_suspend)
 			pm_request_idle(link->supplier);
author maintainer
#2140 lore raw

PATCH 2138/2151 selftests/x86: Add selftests include path for kselftest.h after centralization

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Bala-Vignesh-Reddy <[email protected]>

commit d9b40d7262a227442bf402ea0708dc94f438bb52 upstream.

The previous change centralizing kselftest.h include path in lib.mk caused x86 selftests to fail, as x86 Makefile overwrites CFLAGS using ":=", dropping the include path added in lib.mk. Therefore, helpers.h could not find kselftest.h during compilation.

Fix this by adding the tools/testing/sefltest to CFLAGS in x86 Makefile.

[ bp: Correct commit ID in Fixes: ]

---
 tools/testing/selftests/x86/Makefile |    1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/x86/Makefile +1 -0
@@ -36,6 +36,7 @@ BINARIES_32 := $(patsubst %,$(OUTPUT)/%,
 BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64))
 
 CFLAGS := -O2 -g -std=gnu99 -pthread -Wall $(KHDR_INCLUDES)
+CFLAGS += -I $(top_srcdir)/tools/testing/selftests/
 
 # call32_from_64 in thunks.S uses absolute addresses.
 ifeq ($(CAN_BUILD_WITH_NOPIE),1)
author maintainer
#2141 lore raw

PATCH 2139/2151 perf pmu: fix duplicate conditional statement

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Anubhav Shelat <[email protected]>

commit 87c75fa75559f5501b5a03caf442f18899e388be upstream.

Remove duplicate check for PERF_PMU_TYPE_DRM_END in perf_pmu__kind.

---
 tools/perf/util/pmu.h |    2 --
 1 file changed, 2 deletions(-)
tools/perf/util/pmu.h +0 -2
@@ -333,8 +333,6 @@ static inline enum pmu_kind perf_pmu__ki
 		return PERF_PMU_KIND_PE;
 	if (type <= PERF_PMU_TYPE_DRM_END)
 		return PERF_PMU_KIND_DRM;
-	if (type <= PERF_PMU_TYPE_DRM_END)
-		return PERF_PMU_KIND_DRM;
 	if (type <= PERF_PMU_TYPE_HWMON_END)
 		return PERF_PMU_KIND_HWMON;
 	if (type == PERF_PMU_TYPE_TOOL)
author maintainer
#2142 lore raw

PATCH 2140/2151 perf auxtrace: Include sys/types.h for pid_t

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Arnaldo Carvalho de Melo <[email protected]>

commit e28f834f57131be2cfd60a1c9c580f0a71995dc9 upstream.

In 754187ad73b73bcb ("perf build: Remove NO_AUXTRACE build option") sys/types.h was removed, which broke the build in all Alpine Linux releases, as musl libc has pid_t defined via sys/types.h, add it back.

Fixes 754187ad73b73bcb ("perf build: Remove NO_AUXTRACE build option")
---
 tools/perf/util/auxtrace.h |    1 +
 1 file changed, 1 insertion(+)
tools/perf/util/auxtrace.h +1 -0
@@ -7,6 +7,7 @@
 #ifndef __PERF_AUXTRACE_H
 #define __PERF_AUXTRACE_H
 
+#include <sys/types.h>
 #include <stdio.h> // FILE
 #include <linux/perf_event.h>
 #include <linux/types.h>
author maintainer
#2143 lore raw

PATCH 2141/2151 fs/ntfs3: fix deadlock in ni_read_folio_cmpr

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Szymon Wilczek <[email protected]>

commit e37a75bb866c29da954b51d0dd7670406246d9ee upstream.

Syzbot reported a task hung in ni_readpage_cmpr (now ni_read_folio_cmpr). This is caused by a lock inversion deadlock involving the inode mutex (ni_lock) and page locks.

Scenario:
1. Task A enters ntfs_read_folio() for page X. It acquires ni_lock.
2. Task A calls ni_read_folio_cmpr(), which attempts to lock all pages in the compressed frame (including page Y).
3. Concurrently, Task B (e.g., via readahead) has locked page Y and calls ntfs_read_folio().
4. Task B waits for ni_lock (held by A).
5. Task A waits for page Y lock (held by B).
-> DEADLOCK.

The fix is to restructure locking: do not take ni_lock in ntfs_read_folio(). Instead, acquire ni_lock inside ni_read_folio_cmpr() ONLY AFTER all required page locks for the frame have been successfully acquired. This restores the correct lock ordering (Page Lock -> ni_lock) consistent with VFS.

Reported-by [email protected]
Fixes f35590ee26f5 ("fs/ntfs3: remove ntfs_bio_pages and use page cache for compressed I/O")
[[email protected]: ni_readpage_cmpr was renamed to ni_read_folio_cmpr]
---
 fs/ntfs3/frecord.c |    2 ++
 fs/ntfs3/inode.c   |    3 +--
 2 files changed, 3 insertions(+), 2 deletions(-)
fs/ntfs3/frecord.c +2 -0
@@ -2119,7 +2119,9 @@ int ni_read_folio_cmpr(struct ntfs_inode
 		pages[i] = pg;
 	}
 
+	ni_lock(ni);
 	err = ni_read_frame(ni, frame_vbo, pages, pages_per_frame, 0);
+	ni_unlock(ni);
 
 out1:
 	for (i = 0; i < pages_per_frame; i++) {
fs/ntfs3/inode.c +1 -2
@@ -761,9 +761,8 @@ static int ntfs_read_folio(struct file *
 	}
 
 	if (is_compressed(ni)) {
-		ni_lock(ni);
+		/* ni_lock is taken inside ni_read_folio_cmpr after page locks */
 		err = ni_read_folio_cmpr(ni, folio);
-		ni_unlock(ni);
 		return err;
 	}
 
author maintainer
#2144 lore raw

PATCH 2142/2151 PCI/P2PDMA: Add missing struct p2pdma_provider documentation

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Leon Romanovsky <[email protected]>

commit 80d9411c00e805488b631c91034e9b6c14a6dbdc upstream.

Two fields in struct p2pdma_provider were not documented, which resulted in the following kernel-doc warning:

Warning: include/linux/pci-p2pdma.h:26 struct member 'owner' not described in 'p2pdma_provider'
Warning: include/linux/pci-p2pdma.h:26 struct member 'bus_offset' not described in 'p2pdma_provider'

Repro:

  $ scripts/kernel-doc -none include/linux/pci-p2pdma.h
---
 include/linux/pci-p2pdma.h |    2 ++
 1 file changed, 2 insertions(+)
include/linux/pci-p2pdma.h +2 -0
@@ -20,6 +20,8 @@ struct scatterlist;
  * struct p2pdma_provider
  *
  * A p2pdma provider is a range of MMIO address space available to the CPU.
+ * @owner: Device to which this provider belongs.
+ * @bus_offset: Bus offset for p2p communication.
  */
 struct p2pdma_provider {
 	struct device *owner;
author maintainer
#2145 lore raw

PATCH 2143/2151 btrfs: do not reject a valid running dev-replace

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Qu Wenruo <[email protected]>

commit 3c0c45a4dff73845ba93d41365fc14e45ee32bd7 upstream.

[BUG]
There is a bug report that a btrfs with running dev-replace got rejected with the following messages:

BTRFS error (device sdk1): devid 0 path /dev/sdk1 is registered but not found in chunk tree
BTRFS error (device sdk1): remove the above devices or use 'btrfs device scan --forget <dev>' to unregister them before mount BTRFS error (device sdk1): open_ctree failed: -117

[CAUSE]
The tree and super block dumps show the fs is completely sane, except one thing, there is no dev item for devid 0 in chunk tree.

However this is not a bug, as we do not insert dev item for devid 0 in the first place.
Since the devid 0 is only there temporarily we do not really need to insert a dev item for it and then later remove it again.

It is the commit 34308187395f ("btrfs: add extra device item checks at mount") adding a overly strict check that triggers a false alert and rejected the valid filesystem.

[FIX]
Add a special handling for devid 0, and doesn't require devid 0 to have a device item in chunk tree.

---
 fs/btrfs/volumes.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/btrfs/volumes.c +6 -1
@@ -8462,7 +8462,12 @@ bool btrfs_verify_dev_items(const struct
 
 	mutex_lock(&uuid_mutex);
 	list_for_each_entry(dev, &fs_info->fs_devices->devices, dev_list) {
-		if (!test_bit(BTRFS_DEV_STATE_ITEM_FOUND, &dev->dev_state)) {
+		/*
+		 * Replace target dev item (devid 0) is not inserted into chunk tree.
+		 * So skip the DEV_STATE_ITEM check.
+		 */
+		if (dev->devid != BTRFS_DEV_REPLACE_DEVID &&
+		    !test_bit(BTRFS_DEV_STATE_ITEM_FOUND, &dev->dev_state)) {
 			btrfs_err(fs_info,
 			"devid %llu path %s is registered but not found in chunk tree",
 				  dev->devid, btrfs_dev_name(dev));
author maintainer
#2146 lore raw

PATCH 2144/2151 scsi: scsi_debug: Add missing newline in scsi_debug_device_reset()

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Ewan D. Milne <[email protected]>

commit e4bb73bf3ac11b4a93634660345b9d764a4a80df upstream.

A "\n" at the end of the sdev_printk() string appears to have been inadvertently removed. Add it back for correct log message formatting.

Fixes a743b120227a ("scsi: scsi_debug: Stop printing extra function name in debug logs")
Assisted-by Claude:claude-opus-4-6
---
 drivers/scsi/scsi_debug.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_debug.c +1 -1
@@ -6939,7 +6939,7 @@ static int scsi_debug_device_reset(struc
 	++num_dev_resets;
 
 	if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
-		sdev_printk(KERN_INFO, sdp, "doing device reset");
+		sdev_printk(KERN_INFO, sdp, "doing device reset\n");
 
 	scsi_debug_stop_all_queued(sdp);
 	if (devip) {
author maintainer
#2147 lore raw

PATCH 2145/2151 net: lwtunnel: Drop skb metadata before LWT encapsulation

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jakub Sitnicki <[email protected]>

commit c00320b0e355c4bf0ae4743a53b4180fea237546 upstream.

skb metadata is meant for passing information between XDP and TC. It lives in the skb headroom, immediately before skb->data. LWT programs cannot access the __sk_buff->data_meta pseudo-pointer to metadata.

However, LWT encapsulation prepends outer headers, moving skb->data back over the headroom where the metadata sits. On an RX-originated (forwarded) packet that still carries XDP metadata this goes wrong in two different ways, depending on the encap type:

1. Non-BPF LWT encaps (mpls, seg6, ioam6 ...) call skb_push()/skb_pull() and silently overwrite the metadata that sits in the headroom.

2) BPF LWT xmit calls bpf_skb_change_head(), which uses skb_data_move(). That helper expects metadata immediately before skb->data. But since the IP output path runs LWT xmit before neighbour output has built the outgoing L2 header, for forwarded packets skb->data points at the L3 header while skb_mac_header() still points at the old L2 header. skb_data_move() sees metadata ending at skb_mac_header(), not before skb->data, warns and clears metadata:

  WARNING: CPU: 21 PID: 454557 at include/linux/skbuff.h:4609 skb_data_move+0x47/0x90
  CPU: 21 UID: 0 PID: 454557 Comm: napi/iconduit-g Tainted: G           O        6.18.21 #1
  RIP: 0010:skb_data_move+0x47/0x90
  Call Trace:
   <IRQ>
   bpf_skb_change_head+0xe6/0x1a0
   bpf_prog_...+0x213/0x2e3
   run_lwt_bpf.isra.0+0x1d3/0x360
   bpf_xmit+0x46/0xe0
   lwtunnel_xmit+0xa1/0xf0
   ip_finish_output2+0x1e7/0x5e0
   ip_output+0x63/0x100
   __netif_receive_skb_one_core+0x85/0xa0
   process_backlog+0x9c/0x150
   __napi_poll+0x2b/0x190
   net_rx_action+0x40b/0x7f0
   handle_softirqs+0xd2/0x270
   do_softirq+0x3f/0x60
   </IRQ>

That is what happens, as for how to fix it - a received packet that carries metadata can reach an encap through any of the three LWT redirect modes:

LWTUNNEL_STATE_INPUT_REDIRECT
ip6_rcv_finish
dst_input
lwtunnel_input

LWTUNNEL_STATE_OUTPUT_REDIRECT
ip6_rcv_finish
dst_input
ip6_forward
ip6_forward_finish
dst_output
lwtunnel_output

LWTUNNEL_STATE_XMIT_REDIRECT
ip6_rcv_finish
dst_input
ip6_forward
ip6_forward_finish
dst_output
ip6_output
ip6_finish_output
ip6_finish_output2
lwtunnel_xmit

Every encap funnels through the three LWT dispatch helpers, so drop the metadata there, right before handing the skb to the encap op. This single chokepoint covers all encap types and all three redirect modes:

- lwtunnel_input(): seg6, rpl, ila, seg6_local
- lwtunnel_output(): ioam6
- lwtunnel_xmit(): mpls, LWT BPF xmit

Alternatively, we could clear the metadata right after TC ingress hook. That would require a compromise, however. Metadata would become inaccessible from TC egress (in setups where it actually reaches the hook it tact, that is without any L2 tunnels on path).

---
 net/core/lwtunnel.c |    6 ++++++
 1 file changed, 6 insertions(+)
net/core/lwtunnel.c +6 -0
@@ -350,6 +350,8 @@ int lwtunnel_output(struct net *net, str
 	rcu_read_lock();
 	ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
 	if (likely(ops && ops->output)) {
+		/* Encap pushes outer headers over the metadata; drop it. */
+		skb_metadata_clear(skb);
 		dev_xmit_recursion_inc();
 		ret = ops->output(net, sk, skb);
 		dev_xmit_recursion_dec();
@@ -404,6 +406,8 @@ int lwtunnel_xmit(struct sk_buff *skb)
 	rcu_read_lock();
 	ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
 	if (likely(ops && ops->xmit)) {
+		/* Encap pushes outer headers over the metadata; drop it. */
+		skb_metadata_clear(skb);
 		dev_xmit_recursion_inc();
 		ret = ops->xmit(skb);
 		dev_xmit_recursion_dec();
@@ -455,6 +459,8 @@ int lwtunnel_input(struct sk_buff *skb)
 	rcu_read_lock();
 	ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
 	if (likely(ops && ops->input)) {
+		/* Encap pushes outer headers over the metadata; drop it. */
+		skb_metadata_clear(skb);
 		dev_xmit_recursion_inc();
 		ret = ops->input(skb);
 		dev_xmit_recursion_dec();
author maintainer
#2148 lore raw

PATCH 2146/2151 serial: 8250_hub6: add missing include for hub6_match_port()

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Hugo Villeneuve <[email protected]>

commit da7b5fd4e17f8e44c5590f2d603c01d499f056e6 upstream.

Add missing include to fix compile warning:

drivers/tty/serial/8250/8250_hub6.c:44:6: warning: no previous prototype for 'hub6_match_port' [-Wmissing-prototypes]

---
 drivers/tty/serial/8250/8250_hub6.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/tty/serial/8250/8250_hub6.c +2 -0
@@ -7,6 +7,8 @@
 #include <linux/init.h>
 #include <linux/serial_8250.h>
 
+#include "8250.h"
+
 #define HUB6(card, port)						\
 	{								\
 		.iobase		= 0x302,				\
author maintainer
#2149 lore raw

PATCH 2147/2151 selftests/cgroup: set the test plan after the setup checks

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Hemanth Selam <[email protected]>

commit 0c893d170ff8efe7b4067552932d26e7defba307 upstream.

The cgroup tests announce their plan before checking whether cgroup v2 is available, so on a host without it they promise a number of results and then skip out after the first one:

	TAP version 13
	1..3
	ok 1 # SKIP cgroup v2 isn't mounted
	# Planned tests != run tests (3 != 1)
	# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0

ksft_exit_skip() can only emit a well formed "1..0 # SKIP" line while no plan has been printed, as the comment above it in kselftest.h points out.

Move ksft_set_plan() below the setup checks that can skip, so that a skipped run reports:

TAP version 13
1..0 # SKIP cgroup v2 isn't mounted

Several of the tests skip more than once while setting up, for a missing or unwritable controller as well, so the plan goes after the last of them. test_core joins its two setup paths at the post_v2_setup label and sets the plan there.

Reporting each planned test as skipped instead would keep the plan where it is, but the setup failures here mean the whole test cannot run rather than its individual cases being skipped, which is what "1..0 # SKIP" is for.

Fixes 1dc830ee4c15 ("selftests/cgroup: conform test to KTAP format output")
---
 tools/testing/selftests/cgroup/test_core.c       |    2 +-
 tools/testing/selftests/cgroup/test_cpu.c        |    2 +-
 tools/testing/selftests/cgroup/test_cpuset.c     |    2 +-
 tools/testing/selftests/cgroup/test_freezer.c    |    2 +-
 tools/testing/selftests/cgroup/test_kill.c       |    2 +-
 tools/testing/selftests/cgroup/test_kmem.c       |    2 +-
 tools/testing/selftests/cgroup/test_memcontrol.c |    2 +-
 tools/testing/selftests/cgroup/test_pids.c       |    2 +-
 tools/testing/selftests/cgroup/test_zswap.c      |    2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)
tools/testing/selftests/cgroup/test_core.c +1 -1
@@ -926,7 +926,6 @@ int main(int argc, char *argv[])
 	int i;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), &nsdelegate)) {
 		if (setup_named_v1_root(root, sizeof(root), CG_NAMED_NAME))
 			ksft_exit_skip("cgroup v2 isn't mounted and could not setup named v1 hierarchy\n");
@@ -939,6 +938,7 @@ int main(int argc, char *argv[])
 			ksft_exit_skip("Failed to set memory controller\n");
 
 post_v2_setup:
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_cpu.c +1 -1
@@ -830,7 +830,6 @@ int main(int argc, char *argv[])
 	int i;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
 
@@ -838,6 +837,7 @@ int main(int argc, char *argv[])
 		if (cg_write(root, "cgroup.subtree_control", "+cpu"))
 			ksft_exit_skip("Failed to set cpu controller\n");
 
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_cpuset.c +1 -1
@@ -250,7 +250,6 @@ int main(int argc, char *argv[])
 	int i;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
 
@@ -258,6 +257,7 @@ int main(int argc, char *argv[])
 		if (cg_write(root, "cgroup.subtree_control", "+cpuset"))
 			ksft_exit_skip("Failed to set cpuset controller\n");
 
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_freezer.c +1 -1
@@ -1491,9 +1491,9 @@ int main(int argc, char *argv[])
 	int i;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_kill.c +1 -1
@@ -277,9 +277,9 @@ int main(int argc, char *argv[])
 	int i;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_kmem.c +1 -1
@@ -424,7 +424,6 @@ int main(int argc, char **argv)
 	int i;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
 
@@ -439,6 +438,7 @@ int main(int argc, char **argv)
 		if (cg_write(root, "cgroup.subtree_control", "+memory"))
 			ksft_exit_skip("Failed to set memory controller\n");
 
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_memcontrol.c +1 -1
@@ -1662,7 +1662,6 @@ int main(int argc, char **argv)
 	int i, proc_status;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
 
@@ -1687,6 +1686,7 @@ int main(int argc, char **argv)
 		ksft_exit_skip("Failed to query cgroup mount option\n");
 	has_localevents = proc_status;
 
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_pids.c +1 -1
@@ -148,7 +148,6 @@ int main(int argc, char **argv)
 	char root[PATH_MAX];
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
 
@@ -163,6 +162,7 @@ int main(int argc, char **argv)
 		if (cg_write(root, "cgroup.subtree_control", "+pids"))
 			ksft_exit_skip("Failed to set pids controller\n");
 
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (int i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_zswap.c +1 -1
@@ -770,7 +770,6 @@ int main(int argc, char **argv)
 		page_size = BUF_SIZE;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
 
@@ -787,6 +786,7 @@ int main(int argc, char **argv)
 		if (cg_write(root, "cgroup.subtree_control", "+memory"))
 			ksft_exit_skip("Failed to set memory controller\n");
 
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
author maintainer
#2150 lore raw

PATCH 2148/2151 ACPI: extlog: Avoid populating software AER metadata from raw hardware buffer

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Dave Jiang <[email protected]>

commit 31333d134afb13e3942867d48efbcf8d6b88c849 upstream.

extlog_print_pcie() casts pcie_err->aer_info straight to struct aer_capability_regs *. That struct embeds struct pcie_tlp_log, whose software-only header_len and flit fields sit at offset 84 - inside the 96-byte aer_info buffer - so the cast fills them with raw firmware bytes. pcie_print_tlp_log() uses both to bound a loop over dw[], and a large header_len walks past the end of the array.

Copy into a zeroed local struct, and only as far as aer_info maps onto it:
the leading registers and the four Header Log DWORDs. Place the TLP Prefix Log separately, from the offset the hardware keeps it at. The rest stays zero, which covers header_len and flit and keeps the Root Error registers out of the prefix log, where pcie_print_tlp_log() would print them as end-to-end prefixes.

---
 drivers/acpi/acpi_extlog.c |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/acpi/acpi_extlog.c +17 -3
@@ -137,7 +137,7 @@ static void extlog_print_pcie(struct cpe
 			      int severity)
 {
 #ifdef ACPI_APEI_PCIEAER
-	struct aer_capability_regs *aer;
+	struct aer_capability_regs aer_regs = {};
 	struct pci_dev *pdev;
 	unsigned int devfn;
 	unsigned int bus;
@@ -149,7 +149,21 @@ static void extlog_print_pcie(struct cpe
 		return;
 
 	aer_severity = cper_severity_to_aer(severity);
-	aer = (struct aer_capability_regs *)pcie_err->aer_info;
+
+	/*
+	 * struct pcie_tlp_log is larger than the hardware layout, so aer_info
+	 * only maps onto the struct up to the four Header Log DWORDs. Copy that
+	 * much, then place the TLP Prefix Log from where the hardware keeps it.
+	 * Everything else stays zero: nothing reads root_command, root_status or
+	 * the error source IDs, and header_len and flit are software-only.
+	 */
+	memcpy(&aer_regs, pcie_err->aer_info,
+	       offsetof(struct aer_capability_regs, header_log) +
+	       PCIE_STD_NUM_TLP_HEADERLOG * sizeof(u32));
+	memcpy(aer_regs.header_log.prefix,
+	       pcie_err->aer_info + PCI_ERR_PREFIX_LOG,
+	       sizeof(aer_regs.header_log.prefix));
+
 	domain = pcie_err->device_id.segment;
 	bus = pcie_err->device_id.bus;
 	devfn = PCI_DEVFN(pcie_err->device_id.device,
@@ -158,7 +172,7 @@ static void extlog_print_pcie(struct cpe
 	if (!pdev)
 		return;
 
-	pci_print_aer(pdev, aer_severity, aer);
+	pci_print_aer(pdev, aer_severity, &aer_regs);
 	pci_dev_put(pdev);
 #endif
 }
author maintainer
#2151 lore raw

PATCH 2149/2151 ACPI: extlog: Validate PCIe error section length before payload access

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Dave Jiang <[email protected]>

commit 5eefd849e26506170552e614496d094230650e78 upstream.

extlog_print_pcie() reads pcie_err->validation_bits and device_id and copies the 96-byte aer_info buffer without checking that gdata->error_data_length is big enough for a struct cper_sec_pcie. The cper_estatus_check() call added earlier keeps the read inside the estatus block, but a short section still gets stale adjacent bytes treated as PCIe error data.

Reject a section too small to hold the record before touching any field, and warn: a truncated section means firmware is emitting malformed records.

---
 drivers/acpi/acpi_extlog.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/acpi/acpi_extlog.c +9 -2
@@ -134,7 +134,7 @@ static int print_extlog_rcd(const char *
 }
 
 static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
-			      int severity)
+			      int severity, u32 len)
 {
 #ifdef ACPI_APEI_PCIEAER
 	struct aer_capability_regs aer_regs = {};
@@ -144,6 +144,12 @@ static void extlog_print_pcie(struct cpe
 	int aer_severity;
 	int domain;
 
+	if (len < sizeof(*pcie_err)) {
+		pr_warn_ratelimited(FW_WARN
+				    "PCIe error section too small (%u)\n", len);
+		return;
+	}
+
 	if (!(pcie_err->validation_bits & CPER_PCIE_VALID_DEVICE_ID &&
 	      pcie_err->validation_bits & CPER_PCIE_VALID_AER_INFO))
 		return;
@@ -247,7 +253,8 @@ static int extlog_print(struct notifier_
 		} else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
 			struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata);
 
-			extlog_print_pcie(pcie_err, gdata->error_severity);
+			extlog_print_pcie(pcie_err, gdata->error_severity,
+					  gdata->error_data_length);
 		} else {
 			void *err = acpi_hest_get_payload(gdata);
 
author maintainer
#2152 lore raw

PATCH 2150/2151 ACPI: extlog: Fix CONFIG_ACPI_APEI_PCIEAER guard typo

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Dave Jiang <[email protected]>

commit 44a8d464d79b60883f7bd386049a1ffff32ca690 upstream.

The guard reads "#ifdef ACPI_APEI_PCIEAER" rather than "#ifdef CONFIG_ACPI_APEI_PCIEAER". That symbol is never defined, so the extlog PCIe AER handling is always compiled out.

Use the CONFIG_ prefixed symbol.

---
 drivers/acpi/acpi_extlog.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpi_extlog.c +1 -1
@@ -136,7 +136,7 @@ static int print_extlog_rcd(const char *
 static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,
 			      int severity, u32 len)
 {
-#ifdef ACPI_APEI_PCIEAER
+#ifdef CONFIG_ACPI_APEI_PCIEAER
 	struct aer_capability_regs aer_regs = {};
 	struct pci_dev *pdev;
 	unsigned int devfn;
author maintainer
#2153 lore raw

PATCH 2151/2151 scsi: core: Balance the pseudo target reap reference

In reply to Greg Kroah-Hartman

6.18-stable review patch. If anyone has any objections, please let me know.

------------------

From: Giuseppe Piscitelli <[email protected]>

commit 8a832fb632da303cdf0704e0d56722ec47799f19 upstream.

With memory allocation profiling enabled, unloading scsi_debug reports allocations left at module unload. A stock Linux 7.2.11 VM without OpenZFS emitted the following on each of three load/unload cycles:

[    1.644665] drivers/scsi/scsi_debug.c:8863 module scsi_debug func:sdebug_add_host_helper has 1024 allocated at module unload
[    1.656260] drivers/scsi/scsi_debug.c:1261 module scsi_debug func:sdebug_target_alloc has 16 allocated at module unload

scsi_alloc_target() supplies a reap reference for its caller. The SCSI device initializer takes another reference, which device removal drops. scsi_get_pseudo_sdev() drops its caller reference only when device allocation fails. On success the target cannot be destroyed, retaining its driver-private data and its parent host and adapter.

Drop the caller reference in the common cleanup path, as the other scsi_alloc_target() callers do.

---
 drivers/scsi/scsi_scan.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/scsi_scan.c +2 -3
@@ -2141,14 +2141,13 @@ struct scsi_device *scsi_get_pseudo_sdev
 		goto out;
 
 	sdev = scsi_alloc_sdev(starget, U64_MAX, NULL);
-	if (!sdev) {
-		scsi_target_reap(starget);
+	if (!sdev)
 		goto put_target;
-	}
 
 	sdev->borken = 0;
 
 put_target:
+	scsi_target_reap(starget);
 	/* See also the get_device(dev) call in scsi_alloc_target(). */
 	put_device(&starget->dev);
 
#2154 lore raw
In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.18.65 release. There are 2151 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 20 Nov 2026 14:55:45 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
	https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.18.65-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.18.y
and the diffstat can be found below.

thanks,

greg k-h

perf fails to build with:

util/annotate-data.c: In function 'global_var__collect':
util/annotate-data.c:765:30: warning: implicit declaration of function 'die_get_type_die'; did you mean 'die_get_typename'? [-Wimplicit-function-declaration]
765 | if (!die_get_type_die(dwarf,
pos->die_off, pos->die_tag,

      |                              ^~~~~~~~~~~~~~~~
      |                              die_get_typename
util/annotate-data.c:765:71: error: 'struct die_var_type' has no member named 'die_tag'
  765 |                         if (!die_get_type_die(dwarf, 
pos->die_off, pos->die_tag,
      | 
      ^~

util/annotate-data.c:766:50: error: 'struct die_var_type' has no member named 'from_alt'
766 | pos->from_alt,
&type_die))
| ^~
util/annotate-data.c:777:44: error: 'struct die_var_type' has no member named 'from_alt'
777 | pos->from_alt);
| ^~
util/annotate-data.c: In function 'get_global_var_type':
util/annotate-data.c:835:26: warning: implicit declaration of function 'die_same_file' [-Wimplicit-function-declaration]

  835 |                         !die_same_file(cu_die, type_die));
      |                          ^~~~~~~~~~~~~

util/annotate-data.c: In function 'update_var_state':
util/annotate-data.c:873:42: error: 'struct die_var_type' has no member named 'die_tag'
873 | var->die_tag,
var->from_alt, &mem_die))
| ^~
util/annotate-data.c:873:56: error: 'struct die_var_type' has no member named 'from_alt'
873 | var->die_tag,
var->from_alt, &mem_die))
| ^~

Signature · 1 line
Florian
Tested-by on the v1 series
#2155 lore raw
In reply to Greg Kroah-Hartman

Am 18.11.2026 um 15:28 schrieb Greg Kroah-Hartman:

Quoted 4 lines

This is the start of the stable review cycle for the 6.18.65 release. There are 2151 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Builds, boots and works on my 2-socket Ivy Bridge Xeon E5-2697v2 server. No dmesg oddities or regressions found.

Beste Grüße,
Peter Schneider

Signature · 8 lines
Climb the mountain not to plant your flag, but to embrace the challenge,
enjoy the air and behold the view. Climb it so you can see the world,
not so the world can see you.                    -- David McCullough Jr.

OpenPGP:  0xA3828BD796CCE11A8CADE8866E3A92C92C3FF244
Download: https://www.peters-netzplatz.de/download/pschneider1968_pub.asc
https://keys.mailvelope.com/pks/lookup?op=get&[email protected]
https://keys.mailvelope.com/pks/lookup?op=get&[email protected]
Tested-by on the v1 series
#2156 lore raw
In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.18.65 release. There are 2151 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 20 Nov 2026 14:55:45 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 9 lines
	https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.18.65-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.18.y
and the diffstat can be found below.

thanks,

greg k-h

Hi, Greg:

6.18.65-rc1 successfully built and booted in my system but a dmesg regression was found that was not observed in 6.18.64-rc1.

[    0.000000] Linux version 6.18.65-rc1-900-myllvm+
(user1@gentoo-zenbook) (clang version 23.1.6, LLD 23.1.6) #1 SMP
PREEMPT_DYNAMIC Thu Nov 19 15:35:28 KST 2026
[    3.060808] genirq: Setting trigger mode 3 for irq 87 failed

(amd_gpio_irq_set_type+0x0/0x180)

Distribution: Gentoo Linux
Architecture: x86_64 (ASUS Zenbook UM3504DA)
CPU: AMD Ryzen 7 7735U
iGPU: AMD Radeon 680M

Best,
Joungmin

maintainer
#2157 lore raw
Quoted 2 lines · Joungmin Lee
[    3.060808] genirq: Setting trigger mode 3 for irq 87 failed

(amd_gpio_irq_set_type+0x0/0x180)

That line comes from 44c232e80adc ("pinctrl: amd: add timeout to irq-enable readback"): with it amd_gpio_irq_set_type() gives up after 1 ms and returns -ETIMEDOUT. It is dropped from the 7.3, 6.18, 6.12, 6.6 and 6.1 queues.

Signature · 2 lines
Thanks,
Sasha
Tested-by on the v1 series
#2158 lore raw
In reply to Greg Kroah-Hartman

Build tested in our x86,arm64,loongarch,riscv config successfully without error.

Best Regards
Wentao Guan

Log:
Linux version 6.18.65-rc1-gb8cc618d685d (guanwentao@uos-PC) (aarch64-linux-gnu-gcc-12 (Deepin 12.3.0-17deepin8) 12.3.0, GNU ld (GNU Binutils for Deepin) 2.41) #2 SMP PREEMPT_DYNAMIC Thu Nov 19 15:59:55 CST 2026 Linux version 6.18.65-rc1-gb8cc618d685d (guanwentao@uos-PC) (loongarch64-linux-gnu-gcc-12 (Deepin 12.3.0-17deepin8) 12.3.0, GNU ld (GNU Binutils for Deepin) 2.41) #3 SMP PREEMPT_DYNAMIC Thu Nov 19 16:17:18 CST 2026 Linux version 6.18.65-rc1+ (guanwentao@uos-PC) (riscv64-linux-gnu-gcc-12 (Deepin 12.3.0-17deepin8) 12.3.0, GNU ld (GNU Binutils for Deepin) 2.41) #4 SMP PREEMPT Thu Nov 19 16:34:22 CST 2026 Linux version 6.18.65-rc1-gb8cc618d685d (guanwentao@uos-PC) (gcc (Deepin 12.3.0-17deepin18) 12.3.0, GNU ld (GNU Binutils for Deepin) 2.41) #1 SMP PREEMPT_DYNAMIC Thu Nov 19 15:39:59 CST 2026

Tested-by on the v1 series
#2159 lore raw
In reply to Greg Kroah-Hartman
Quoted 4 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.18.65 release. There are 2151 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Native arm64 build on Arch Linux ARM with 7.3 uapi headers and CONFIG_DEBUG_INFO_BTF=y works fine, without my local __u128 patch.

Booted on an Odroid HC4 (Amlogic S905X3). No regressions noticed.

Thanks,
Marco

Tested-by on the v1 series
#2160 lore raw
In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.18.65 release. There are 2151 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 20 Nov 2026 14:55:45 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 9 lines
	https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.18.65-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.18.y
and the diffstat can be found below.

thanks,

greg k-h

Compiled and booted on my test system. No dmesg regressions.

thanks,
-- Shuah

Tested-by on the v1 series
#2161 lore raw
In reply to Greg Kroah-Hartman
Quoted 4 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.18.65 release. There are 2151 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Built, booted, and tested on hardware for x86_64:

- AMD Ryzen 9 5900X, Nvidia RTX 3080 (nouveau)
- Intel N100

No regressions found.

Thanks!
Sean

Tested-by on the v1 series
#2162 lore raw
In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.18.65 release. There are 2151 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 20 Nov 2026 14:55:45 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
	https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.18.65-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.18.y
and the diffstat can be found below.

thanks,

greg k-h

Built and booted successfully on RISC-V RV64 (HiFive Unmatched).