From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9DD84B048B; Mon, 17 Aug 2026 14:19:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786976381; cv=none; b=teq7zPL32OL0PDR5LYqoIvWhDYlEVTxp27Gnmw1Ik+CItyXJUKrVAHYGyh7JFnPeeLDias8AyQOtDA1aiBycOLSlUntEa32DDZZ6vcP8fFKpJpyqppH2PxtWOo0MbYWa1FKyqIq3fNchRAEoEpbcvjBkIWTDcoYfXlZPtrv+Va8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786976381; c=relaxed/simple; bh=rkpIoYDaMJgqAjx5JM8PKSS51RG+bAcCtZvNRfRMSkw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U3r2ObKt4Db9gGvJ1v7h/T6kQx6tfttsv7RFeUwa/fg3nuzG6ZB3eqXrcx5exIiC3dfpWWAvDSxzT8HaUH05yj9lN7GKzHEGZcS+2VHZJ4zAzCr5HJ243oY39+KItYwaf9T7YuXYWgKejVSneTJrVpcPAH05XZT1sTdiLexCMVg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DjFKT8ic; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DjFKT8ic" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C7511F000E9; Mon, 17 Aug 2026 14:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786976379; bh=X4z940EtzNupnmJSVU+bM90Bd14+xAXz+rIhpUX1sdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DjFKT8ica7rvc+vN1kE+Nr1ZGxqNJucegYBShE4jYtsGB6tEmjHn7CmMF0JkF8miF EzmZyFbloKLXDeo86pRw9p8lUoWHcFbL/3o0zRax31sHJAxV8H3yopjLULOofygeoG Ab8vc/NPP2wOu0YxpfFkpUy18CLMblWqHv0VP5KA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Willem de Bruijn , Qihang Tang , Jakub Kicinski Subject: [PATCH 5.10 352/389] net: remove CAP_SYS_RAWIO zero-padding in dev_validate_header Date: Mon, 17 Aug 2026 15:33:11 +0200 Message-ID: <20260817132552.505510528@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132538.796021292@linuxfoundation.org> References: <20260817132538.796021292@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qihang Tang commit 3b9a324e646d3657a8d9806dfbfe4f3e4066e882 upstream. dev_validate_header() reads dev->hard_header_len directly when zero-padding short link layer headers for CAP_SYS_RAWIO holders: if (capable(CAP_SYS_RAWIO)) { memset(ll_header + len, 0, dev->hard_header_len - len); return true; } Packet send paths call dev_validate_header() on skbs whose headroom was allocated from an earlier hard_header_len read. If the device is reconfigured so that dev->hard_header_len increases before validation, the memset writes past the reserved buffer, an out-of-bounds write. This out-of-bounds write is masked in some SOCK_RAW paths today because the same concurrent increase can first make skb_push() exceed the reserved headroom and trigger skb_under_panic(). Remove the zero-padding branch before making those hard_header_len reads consistent, so the snapshot fixes do not turn a loud panic into a silent overwrite. This path is only reached for variable length L2 protocols, where len < hard_header_len but len >= min_header_len. No remaining in-tree variable length L2 protocol implements header_ops->validate, and the CAP_SYS_RAWIO bypass that zero-pads and accepts short headers has no real value beyond allowing testing of intentionally malformed input. Drop the CAP_SYS_RAWIO branch. The remaining reads of dev->hard_header_len in dev_validate_header() are comparisons only and have no memory safety impact. Suggested-by: Willem de Bruijn Fixes: 2793a23aacbd ("net: validate variable length ll headers") Cc: stable@vger.kernel.org Signed-off-by: Qihang Tang Reviewed-by: Willem de Bruijn Link: https://patch.msgid.link/20260805125729.19220-2-q.h.hack.winter@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- include/linux/netdevice.h | 5 ----- 1 file changed, 5 deletions(-) --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3208,11 +3208,6 @@ static inline bool dev_validate_header(c if (len < dev->min_header_len) return false; - if (capable(CAP_SYS_RAWIO)) { - memset(ll_header + len, 0, dev->hard_header_len - len); - return true; - } - if (dev->header_ops && dev->header_ops->validate) return dev->header_ops->validate(ll_header, len);