Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp366328pxb; Wed, 6 Oct 2021 06:43:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4XRsaZkTSZQ88I0w+5zMKUQ1ofTScj4rrgwjfk8sG14SUfV8zTaxBVMFS3ANQqcaOxyAX X-Received: by 2002:aa7:c948:: with SMTP id h8mr8977480edt.380.1633527787310; Wed, 06 Oct 2021 06:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633527787; cv=none; d=google.com; s=arc-20160816; b=txjjf189jfejAK8BSFmHBjeRLMuD5ZXvvwaYUuGp3CeyXGmPVMud/VgPBXv1J8QIG/ mShib2bm/zGzLCsz3CrRwZuh/0yYEVlRSpltX2j8ioVdjbdYELUuDOtyjN/fH/TBKqm2 s1odIZwnAx6CYGQU5YctZVJoKLIlOxWEiq3zRlN7T53NGku1UcAjmxZKJIRoYBiQgt7Z 99a/78LvE2D3vnt/kk1WGUt1YJ4N72tp2bIMHLGsTcr8e+jgGH463IqaG6KvxlxFF3xN 4yk9R2ANKNcafpS8lTzvD+6XnwJxHSqO0SMCC5ExHYn1ZHFjy4XdyGjhQrv3M+fONBhz fgrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZXUegjCUcjZM3YT3AwpKd2XzjXbHH263VlRYRLyBqyI=; b=oD7EAY51muafofMBK9Kb6AhHReJhzcoJ3XpM7CRpNqwaydmOgletFlZveJzJQTYP8D uHT2gk8plDZFGIkYnbpmX6M55Hq5tUcxef+nh2JTxx/51jHODe9TJ+LqDpjxmf801mAG oMNCSvGpaKy7LFPI1SUhUmMphFmrGbYDKsdfEJhsMcVLRmMMyVEtRhphk58V/+MkUpPA r0lAqLu6VG27tt+jwFBGblTue6HRGy33WAiGmi36v1AUZm0H/XK2a3Y69yrU3vhtp0v4 5fKoFX1c06vM5+PxaMfqvpcRG6bx1yKag+iGfMRiZgfxjlPqBlw8XeqGEFvrpqdokJax IqMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jg2ahWTW; 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 v17si6061501edc.479.2021.10.06.06.42.42; Wed, 06 Oct 2021 06:43:07 -0700 (PDT) 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=20210112 header.b=jg2ahWTW; 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 S231717AbhJFNl3 (ORCPT + 99 others); Wed, 6 Oct 2021 09:41:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231633AbhJFNl2 (ORCPT ); Wed, 6 Oct 2021 09:41:28 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DC66C061749; Wed, 6 Oct 2021 06:39:36 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id b8so10172167edk.2; Wed, 06 Oct 2021 06:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZXUegjCUcjZM3YT3AwpKd2XzjXbHH263VlRYRLyBqyI=; b=jg2ahWTWJvxDuJvvK9KKKXtaOoz55Ep8CjDvuYwSlUbrgfakL8YL0wF6hNOVT3bDcZ vxg0kHknPWi/ItFdt+bDgo0FMnwv8HUI4KmHNH/9wwxMRDeIjih8qT6er8YzlPkKjzRg 6TcIiZGSMpH8h5QMl106xVSmPDaJBeSyydxvd9QTcxQQgIAwLhl6l/50f8AwGUWVOqE3 HYz5sM1GcyXBNjcYppAA7C0kmaf2DO2UJcuOaZnyBOi/SgNzO0aOvEiFBMEOUeUYaG8X QkoiVm2IQkPMakJFANmeNIMMfq8BsyAe6HSZ+z+Rn3m1i8KI0u00WZqUlBBgo7+ammB3 ptvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZXUegjCUcjZM3YT3AwpKd2XzjXbHH263VlRYRLyBqyI=; b=sfj5m2K7M9EA+0ziqEc6l5+9gxKo7EFGgtD4uoNAUkGJPPRjj+eI6Su1g0zeGfDz3W KgYElJDA4R4uBA4fKW3ZApuImQ6d+1oRVzMhsJgNtxLmhoa4cn5GneWihWMtXV41Li6/ HkusAs2bWMT8CicBA2Z5O9e58E+lxz+tWBsZlzehepQ0ZDM67BRmOCJdx48PNh2YjsuW DM5cPy4s3eC57grqMEnxzPvOMlfhZob9/BYj+aX8OOHrY9ZU6v/YXgSqQ/ffZwkMvdj6 oQkqFVgsCCN5Kcco8bRtNzQ4EOw3Q9Odgjm494jtagdRs3mmaDr5TnR+Ztp+htaCGfEh sbNw== X-Gm-Message-State: AOAM530qlBVXvszC3AVXkDNOGzu1izr7ltw7dVs4o5H5sJB5/hYESuGr AfbAXZ1nwPm36mrH48j9RaM= X-Received: by 2002:a50:eb9a:: with SMTP id y26mr24086544edr.186.1633527568128; Wed, 06 Oct 2021 06:39:28 -0700 (PDT) Received: from anparri (host-79-49-65-228.retail.telecomitalia.it. [79.49.65.228]) by smtp.gmail.com with ESMTPSA id r6sm5173259edd.89.2021.10.06.06.39.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 06:39:27 -0700 (PDT) Date: Wed, 6 Oct 2021 15:39:09 +0200 From: Andrea Parri To: Michael Kelley Cc: Long Li , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "linux-scsi@vger.kernel.org" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , "James E . J . Bottomley" , "Martin K . Petersen" , Dexuan Cui Subject: Re: [PATCH] scsi: storvsc: Fix validation for unsolicited incoming packets Message-ID: <20211006133909.GA22926@anparri> References: <20211005114103.3411-1-parri.andrea@gmail.com> <20211005181421.GA1714@anparri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > I know you have determined experimentally that Hyper-V sends > > > unsolicited packets with the above length, so the idea is to validate > > > that the guest actually gets packets at least that big. But I wonder if > > > we should think about this slightly differently. > > > > > > The goal is for the storvsc driver to protect itself against bad or > > > malicious messages from Hyper-V. For the unsolicited messages, the > > > only field that this storvsc driver needs to access is the > > > vstor_packet->operation field. > > > > Eh, this is one piece of information I was looking for... ;-) > > I'm just looking at the code in storvsc_on_receive(). storvsc_on_receive() > itself looks at the "operation" field, but for the REMOVE_DEVICE and > ENUMERATE_BUS operations, you can see that the rest of the vstor_packet > is ignored and is not passed to any called functions. > > > > > > > >So an alternate approach is to set > > > the minimum length as small as possible while ensuring that field is valid. > > > > The fact is, I'm not sure how to do it for unsolicited messages. > > Current code ensures/checks != COMPLETE_IO. Your comment above > > and code audit suggest that we should add a check != FCHBA_DATA. > > I saw ENUMERATE_BUS messages, code only using their "operation". > > I'm not completely sure about FCHBA_DATA. That message does not > seem to be unsolicited, as the guest sends out a message of that type in > storvsc_channel_init() using storvsc_execute_vstor_op(). So any received > messages of that type are presumably in response to the guest request, > and will get handled via the test for rqst_id == VMBUS_RQST_INIT. Long > Li could probably confirm. So if Hyper-V did send a FCHBA_DATA > packet with rqst_id of 0, it would seem to be appropriate to reject > it. > > > > > And, again, this is only based on current code/observations... > > > > So, maybe you mean something like this (on top of this patch)? > > Yes, with a comment to explain what's going on. :-) My (current) best guess is here: https://lkml.kernel.org/r/20211006132026.4089-1-parri.andrea@gmail.com Thanks, Andrea