Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1547124pxu; Thu, 17 Dec 2020 12:35:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzybJYiS1llF8zjoZ3yFUl/EK6IPI9vAZIWajKtIQb+R/gMfiIRYouyB/Fh8HWjSpwe2OOI X-Received: by 2002:a17:906:f9da:: with SMTP id lj26mr742950ejb.467.1608237325767; Thu, 17 Dec 2020 12:35:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608237325; cv=none; d=google.com; s=arc-20160816; b=vERZ82s0cjFNkiHtJAnXnuVOeXliVY3dHEKCse9qAoofAedEWNRit/09omXLboDRDu bHAFkYrbsjQLJGn/suglwPuVgMWhHhaTii2+A/OHUbYOsR/GBDLDAaK4ORLh3ralN6+C Y6NyTlzp7nNXLXO5WypMJFAv7JSNnqRTPsMQ693tUf2gwy5CopohJNxSEZyBnSPrnUuP fiBhqBSlYPr0OMjoMQLzB3hAvVJ+kXomE/z8LJ5++nIEnDHqNu9F1dd2+PUVpC2uNvc5 DSCgbNypOmKoycqQwKtf6epjMF5G++HevmcRBF6m5qgJjDCFXqAkG6cIYfAPWi0Vfbna V3/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gQGWPM/sf8+J1RLMjv3ZaWA/7DvHetdsTdc1DOQtFJQ=; b=WcGOJ7gxAVAwm0pcRmBdfVmF7ULCBG9hTVdhTd9GG5nlipMSjU1m8kKCZOHgPO+3zA 52Z3xo4SFq54bDBGijdcDjzajrmF9bP1bNzx0GQMOeaWjvFUZQx55Pw9WCADoFeMM6o6 W+ikNgIIFvg3afH+jrYA4jN0I2MMcZ99vtRe9oS5rZJtkYQjsWuUg0LaU5L/pSOtFS+R Idz0DRDk9Qtvkb2J1v/XEh//TKc8BxC+IrxlV0pTeSJ+KdVq4TXlV6IImZwUz6I62VjZ mtwt3vve/8Mr0VxBpofQ8e32zizLgcexPd1G/CnlwfQEmKvTmdGA4nV727t0HZd+gyJT ruKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qQikXu51; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn1si4749632edb.113.2020.12.17.12.35.02; Thu, 17 Dec 2020 12:35:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qQikXu51; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731602AbgLQUeg (ORCPT + 99 others); Thu, 17 Dec 2020 15:34:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731595AbgLQUef (ORCPT ); Thu, 17 Dec 2020 15:34:35 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 484DFC06138C; Thu, 17 Dec 2020 12:33:55 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id r4so163543wmh.5; Thu, 17 Dec 2020 12:33:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gQGWPM/sf8+J1RLMjv3ZaWA/7DvHetdsTdc1DOQtFJQ=; b=qQikXu51Qi9p3EQTAoWNtLzcEEHx9Kz0wZB/60aM5LTsJCBfmY6s87JDfUxpYcF5Cm U1sIg7LPP64Rn1Ox2oOwk8xsX4H47lWqfM9K95gsaz96Onhi/hWiRDXiCNqP3AoWBNZm XeZnXJMbAy/tkoIpb7DcKMJnIjSkz54Rvm19/BdeTj5HW6fflJf05Yt5CcN+811CS2x6 1N1KQo9awFYDJvAqDDIjJmbAaqZ3VaYg3cnzGfTQDFGKblBXTl0qAU0TQpbJAI+4Wf54 wtx94CGODvCKpaY9PJWPZeYaz/42GwxhSIaGI/HoLkinsD4rvyJx6tIiMvIXJaAekrpr k+kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gQGWPM/sf8+J1RLMjv3ZaWA/7DvHetdsTdc1DOQtFJQ=; b=GQnSiu5jwwEXsx794a4EYLK1R9wq9qdL7JimL3GxKi+jt8mqLmsKf/G+UuMieBUXRx IZJu16rqxqXObpt3jsQMNTbpSDTQVwH+1PSetctNTbYGZvdepn9aSnh+BFFuGuJbOAoJ jS5R/30k8x9Q8iY3g2F/GzznJjxBlo9iKLQPGCcZF48i3njhhHNVIN3ab95hvMu28MBd OL9P5CptlJWQrPGU8MTF9WdSKcAACtVCcx0vtyCezKz1uHuL8JSVQgQR7HuF3PTr4EhS Bd0cXA5tvCWTydTEnD9nnq4NkcYpDWuZxqGQdkA2r/hR+bvYbJbku91KyiZ0Mg0PeHkq 1d8Q== X-Gm-Message-State: AOAM531Qet9EQSFA+ReI+4/9yXqM15/YMbrpljnxNEqTGp8N1FDflRGh 23CQH6SDlXZjD6FwRr3TOfWIEqvOrtYbvd79 X-Received: by 2002:a1c:770d:: with SMTP id t13mr1036395wmi.153.1608237233745; Thu, 17 Dec 2020 12:33:53 -0800 (PST) Received: from localhost.localdomain (host-95-239-64-30.retail.telecomitalia.it. [95.239.64.30]) by smtp.gmail.com with ESMTPSA id a62sm11729128wmh.40.2020.12.17.12.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 12:33:53 -0800 (PST) From: "Andrea Parri (Microsoft)" To: linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Cc: "K . Y . Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Michael Kelley , Saruhan Karademir , Juan Vazquez , "Andrea Parri (Microsoft)" , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 3/3] scsi: storvsc: Validate length of incoming packet in storvsc_on_channel_callback() Date: Thu, 17 Dec 2020 21:33:21 +0100 Message-Id: <20201217203321.4539-4-parri.andrea@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201217203321.4539-1-parri.andrea@gmail.com> References: <20201217203321.4539-1-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Check that the packet is of the expected size at least, don't copy data past the packet. Reported-by: Saruhan Karademir Signed-off-by: Andrea Parri (Microsoft) Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org --- drivers/scsi/storvsc_drv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 8714355cb63e7..4b8bde2750fac 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -1250,6 +1250,12 @@ static void storvsc_on_channel_callback(void *context) request = (struct storvsc_cmd_request *) ((unsigned long)desc->trans_id); + if (hv_pkt_datalen(desc) < sizeof(struct vstor_packet) - + stor_device->vmscsi_size_delta) { + dev_err(&device->device, "Invalid packet len\n"); + continue; + } + if (request == &stor_device->init_request || request == &stor_device->reset_request) { memcpy(&request->vstor_packet, packet, -- 2.25.1