 vsock/virtio: Validate length in packet header before skb_put() · gregkh/linux@969b06b · 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 969b06b 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 85ea58d commit 969b06b Copy full SHA for 969b06b 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 @@ -494,8 +494,9 @@ static void virtio_transport_rx_work(struct work_struct *work) 494 494 do { 495 495 virtqueue_disable_cb ( vq ); 496 496 for (;;) { 497 + unsigned int len , payload_len ; 498 + struct virtio_vsock_hdr * hdr ; 497 499 struct sk_buff * skb ; 498 - unsigned int len ; 499 500 500 501 if (! virtio_transport_more_replies ( vsock )) { 501 502 /* Stop rx until the device processes already @@ -512,12 +513,19 @@ static void virtio_transport_rx_work(struct work_struct *work) 512 513 vsock -&gt; rx_buf_nr -- ; 513 514 514 515 /* Drop short/long packets */ 515 - if ( unlikely ( len &lt; sizeof ( struct virtio_vsock_hdr ) || 516 + if ( unlikely ( len &lt; sizeof ( * hdr ) || 516 517 len &gt; virtio_vsock_skb_len ( skb ))) { 517 518 kfree_skb ( skb ); 518 519 continue ; 519 520 } 520 521 522 + hdr = virtio_vsock_hdr ( skb ); 523 + payload_len = le32_to_cpu ( hdr -&gt; len ); 524 + if ( unlikely ( payload_len &gt; len - sizeof ( * hdr ))) { 525 + kfree_skb ( skb ); 526 + continue ; 527 + } 528 + 521 529 virtio_vsock_skb_rx_put ( skb ); 522 530 virtio_transport_deliver_tap_pkt ( skb ); 523 531 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. 