Received: by 2002:a17:90a:2044:0:0:0:0 with SMTP id n62csp528153pjc; Mon, 20 May 2019 11:17:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJB0pNNgW2u5xg77XxNf/angli6KDD1y+xOGyEI3b/9uKJgOjhM5GdJALwy0Hm8ama39Fy X-Received: by 2002:a17:902:868b:: with SMTP id g11mr5188695plo.183.1558376248517; Mon, 20 May 2019 11:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558376248; cv=none; d=google.com; s=arc-20160816; b=j9dcgn3xDvIpZB+UFKHgif+s8Y/SRdReF8vdAEkmR5sU4p67MUK3wW8UPlBKD02DgO XLkwnxz36OS3EN0BGRJ455TR+ph3JYURUOnNZ79YjilEUiaAxHih4R+yQKFlp8Y4gnFw RUrIPsB0h4BBcbhqki69BWBWg0ysx4+u2uU+j8hkr8cL6mWo5IuINecIojiVbw4xqwvW r8bb7M2+d8h+2NfsQVSnZJh+uhEDMuqGOq5rA0NUduPUSuVaWMuuz5jpa00LLNe0iDfP cqcmosqKLO2wZocqnvPVfmMtB2vzhEst2hPmNmUBebIlTS4Buo3BwKxTUNErq3uiNUf/ QaSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=aqAyyiSOU4XEgvMkffbyRyu+tWg/yZacYVWKwiVrtFU=; b=Nbaer52l5l3gtPge4G7SNUZlQtzzsB0O9PZltf5WPjFlt7Ykre0D/JmGh8sAAfLfIw gAue4MyBgOFW0WhmOYjY/VQ3KiaMKN3LJsfwFSFmVpZOYeISwINEA2z5cRlHthx4BJuy S3grvU/1zSnLDjEXZjJ6srMmmmTRna96ZoWob8Z+oPFnXK08YDhcKYDGxJexU4K7wVAz EI4y3xuwmdE/ab5LwZ2D65vJYorJ+iA15qHReMb75SxQxKzJQyeluWffqdi0xvY6D75A FLOZRDnjkPwfHARTDMNl5TURilCmIh739x+VeXz0uRKFUllJGyMWMgsaq1lc2136jLLT Z2GQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x19si20347496pfr.226.2019.05.20.11.17.13; Mon, 20 May 2019 11:17:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389157AbfETP4C (ORCPT + 99 others); Mon, 20 May 2019 11:56:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25309 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389005AbfETP4C (ORCPT ); Mon, 20 May 2019 11:56:02 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1549785365; Mon, 20 May 2019 15:56:02 +0000 (UTC) Received: from llong.remote.csb (dhcp-17-85.bos.redhat.com [10.18.17.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9437F27C4B; Mon, 20 May 2019 15:56:01 +0000 (UTC) Subject: Re: [PATCH] scsi: ses: Fix out-of-bounds memory access in ses_enclosure_data_process() To: James Bottomley , "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190501180535.26718-1-longman@redhat.com> <1fd39969-4413-2f11-86b2-729787680efa@redhat.com> <1558363938.3742.1.camel@linux.ibm.com> <3385cf54-7b6c-3f28-e037-f0d4037368eb@redhat.com> <1558367212.3742.10.camel@linux.ibm.com> From: Waiman Long Organization: Red Hat Message-ID: <8080a1ae-027e-ecdb-d8f1-5786a6b8853b@redhat.com> Date: Mon, 20 May 2019 11:56:01 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1558367212.3742.10.camel@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 20 May 2019 15:56:02 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/20/19 11:46 AM, James Bottomley wrote: > On Mon, 2019-05-20 at 11:24 -0400, Waiman Long wrote: >> On 5/20/19 10:52 AM, James Bottomley wrote: >>> On Mon, 2019-05-20 at 10:41 -0400, Waiman Long wrote: >>> [...] >>>>> --- a/drivers/scsi/ses.c >>>>> +++ b/drivers/scsi/ses.c >>>>> @@ -605,9 +605,14 @@ static void >>>>> ses_enclosure_data_process(struct >>>>> enclosure_device *edev, >>>>> /* these elements are optional */ >>>>> type_ptr[0] == >>>>> ENCLOSURE_COMPONENT_SCSI_TARGET_PORT || >>>>> type_ptr[0] == >>>>> ENCLOSURE_COMPONENT_SCSI_INITIATOR_PORT || >>>>> - type_ptr[0] == >>>>> ENCLOSURE_COMPONENT_CONTROLLER_ELECTRONICS)) >>>>> + type_ptr[0] == >>>>> ENCLOSURE_COMPONENT_CONTROLLER_ELECTRONICS)) { >>>>> addl_desc_ptr += >>>>> addl_desc_ptr[1] >>>>> + 2; >>>>> >>>>> + /* Ensure no out-of-bounds >>>>> memory >>>>> access */ >>>>> + if (addl_desc_ptr >= ses_dev- >>>>>> page10 + >>>>> + ses_dev- >>>>>> page10_len) >>>>> + addl_desc_ptr = NULL; >>>>> + } >>>>> } >>>>> } >>>>> kfree(buf); >>>> Ping! Any comment on this patch. >>> The update looks fine to me: >>> >>> Reviewed-by: James E.J. Bottomley >>> >>> It might also be interesting to find out how the proliant is >>> structuring this descriptor array to precipitate the out of bounds: >>> Is it just an off by one or something more serious? >> I didn't look into the detail the enclosure message returned by the >> hardware, but I believe it may have more description entries (page7) >> than extended description entries (page10). >> >> I can try to reserve the system and find out what exactly is wrong >> with that system if you really want to find that out. > Please. What I'm interested in is whether this is simply a bug in the > array firmware, in which case the fix is sufficient, or whether there's > some problem with the parser, like mismatched expectations over added > trailing nulls or something. > > James > OK, will let you know once I get hold of the system. Cheers, Longman