 vsock/virtio: Validate length in packet header before skb_put() · gregkh/linux@ee438c4 · GitHub Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Platform AI CODE CREATION GitHub Copilot Write better code with AI GitHub Spark Build and deploy intelligent apps GitHub Models Manage and compare prompts MCP Registry New Integrate external tools DEVELOPER WORKFLOWS Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes APPLICATION SECURITY GitHub Advanced Security Find and fix vulnerabilities Code security Secure your code as you build Secret protection  EXPLORE Why GitHub Documentation Blog Changelog Marketplace View all features Solutions BY COMPANY SIZE Enterprises Small and medium teams Startups Nonprofits BY USE CASE App Modernization DevSecOps DevOps CI/CD View all use cases BY INDUSTRY Healthcare Financial services Manufacturing Government View all industries View all solutions Resources EXPLORE BY TOPIC AI Software Development DevOps Security View all topics EXPLORE BY TYPE Customer stories Events &amp; webinars Ebooks &amp; reports Business insights GitHub Skills SUPPORT &amp; SERVICES Documentation Customer support Community forum Trust center Partners View all resources Open Source COMMUNITY GitHub Sponsors Fund open source developers PROGRAMS Security Lab Maintainer Community Accelerator GitHub Stars Archive Program REPOSITORIES Topics Trending Collections Enterprise ENTERPRISE SOLUTIONS Enterprise platform AI-powered developer platform AVAILABLE ADD-ONS GitHub Advanced Security Enterprise-grade security features Copilot for Business Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... --> Search Clear Search syntax tips Provide feedback --> We read every piece of feedback, and take your input very seriously.  Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly --> Name Query To see all available qualifiers, see our documentation . Cancel Create saved search Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} gregkh / linux Public Notifications You must be signed in to change notification settings Fork 676 Star 636 Code Actions Security and quality 0 Insights Additional navigation options Code Actions Security and quality Insights Commit ee438c4 Browse files Browse files willdeacon authored and gregkh committed vsock/virtio: Validate length in packet header before skb_put() commit 0dab924 upstream. When receiving a vsock packet in the guest, only the virtqueue buffer size is validated prior to virtio_vsock_skb_rx_put(). Unfortunately, virtio_vsock_skb_rx_put() uses the length from the packet header as the length argument to skb_put(), potentially resulting in SKB overflow if the host has gone wonky. Validate the length as advertised by the packet header before calling virtio_vsock_skb_rx_put(). Cc: &lt;stable@vger.kernel.org&gt; Fixes: 71dc9ec ("virtio/vsock: replace virtio_vsock_pkt with sk_buff") Signed-off-by: Will Deacon &lt;will@kernel.org&gt; Message-Id: &lt;20250717090116.11987-3-will@kernel.org&gt; Signed-off-by: Michael S. Tsirkin &lt;mst@redhat.com&gt; Reviewed-by: Stefano Garzarella &lt;sgarzare@redhat.com&gt; Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt; 1 parent 6ee4578 commit ee438c4 Copy full SHA for ee438c4 1 file changed + 10 - 2 Lines changed: 10 additions &amp; 2 deletions File tree Expand file tree Collapse file tree Open diff view settings Filter options net/vmw_vsock virtio_transport.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ net/vmw_vsock/virtio_transport.c ‎ Copy file name to clipboard Expand all lines: net/vmw_vsock/virtio_transport.c + 10 - 2 Lines changed: 10 additions &amp; 2 deletions Original file line number Diff line number Diff line change @@ -497,8 +497,9 @@ static void virtio_transport_rx_work(struct work_struct *work) 497 497 do { 498 498 virtqueue_disable_cb ( vq ); 499 499 for (;;) { 500 + unsigned int len , payload_len ; 501 + struct virtio_vsock_hdr * hdr ; 500 502 struct sk_buff * skb ; 501 - unsigned int len ; 502 503 503 504 if (! virtio_transport_more_replies ( vsock )) { 504 505 /* Stop rx until the device processes already @@ -515,12 +516,19 @@ static void virtio_transport_rx_work(struct work_struct *work) 515 516 vsock -&gt; rx_buf_nr -- ; 516 517 517 518 /* Drop short/long packets */ 518 - if ( unlikely ( len &lt; sizeof ( struct virtio_vsock_hdr ) || 519 + if ( unlikely ( len &lt; sizeof ( * hdr ) || 519 520 len &gt; virtio_vsock_skb_len ( skb ))) { 520 521 kfree_skb ( skb ); 521 522 continue ; 522 523 } 523 524 525 + hdr = virtio_vsock_hdr ( skb ); 526 + payload_len = le32_to_cpu ( hdr -&gt; len ); 527 + if ( unlikely ( payload_len &gt; len - sizeof ( * hdr ))) { 528 + kfree_skb ( skb ); 529 + continue ; 530 + } 531 + 524 532 virtio_vsock_skb_rx_put ( skb ); 525 533 virtio_transport_deliver_tap_pkt ( skb ); 526 534 virtio_transport_recv_pkt ( &amp; virtio_transport , skb ); 0 commit comments Comments 0 ( 0 ) Footer &copy; 2026 GitHub,&nbsp;Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. 