Received: by 2002:a17:90a:2044:0:0:0:0 with SMTP id n62csp526081pjc; Mon, 20 May 2019 11:15:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYPDlBEVPVQt9l1av9zIPTLzi0+BfTuZJtb08fE2uiVR1wGHpXrpUQW8wGtUE9GAO7HWNY X-Received: by 2002:a63:87c6:: with SMTP id i189mr74776633pge.367.1558376133462; Mon, 20 May 2019 11:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558376133; cv=none; d=google.com; s=arc-20160816; b=zaGl7t4+ku6vr65TXsqwr04itmzDxfY+vdFnz72/NIh/hP9WOinK8twmNgb8rzTZO8 0btsxt223kDtqdAm9cHPSHO9WBXgmlQ7mGwLW4WxUiiDFA0hRWLqL9ozpcWp/kCzebah jx7UJKydvYEibX6EFd4BmMyCqC8xNTOIsf80vL8wI/sjlfgSbuF5CG7RFADVKzOBHwNg pV9aiyMQ82ZUGJaGGACFAYVqk/D4UyH07LutJ3iRzS/wcf7UrNJmXnwzxXmetsUMaC3c 6Ce1u41cok4mjL+DBbgqvy8V4LFXF8Gdhiq7WhvqztgLJYSImgDeLN1+TA17d2xXyedD dGwg== 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=YFGG2yPhbwhPZKsR8o0Q8xEmjgbdCM17wqnt4ereL78=; b=B/RjyYK1rWTAt5ZosdW5B7CklzBR69hu8tUgLw9szjkDycL1KYRNO7pzvuMHeTRpY3 wkIpmwW8NPLeZKoyHlJKlGIruv1fmQSJTqF7UoxoqUga/MCyPZww69BHaKy3cUtlsEgf oHO+DtJtSeR1pv50s/m85aFfTzzzLIzN+zUFiZlsFx4/yOzKLTzCZDkqCffTyHEdbXUC iGmpD1XST9tTR2dVk2AgZXm+e84O1tNIxprsqdEk366dFb5pv1g6Jtuag2IMYLmxsniM MeUHq/GaQE/bPISRX6kqKD8UyzctSQEDH/k6OtCTpnD6JinI7oXh3dmuGcPBL4ERNp31 CAFw== 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 b188si18545627pga.223.2019.05.20.11.15.17; Mon, 20 May 2019 11:15:33 -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 S2390918AbfETPYl (ORCPT + 99 others); Mon, 20 May 2019 11:24:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38346 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730766AbfETPYl (ORCPT ); Mon, 20 May 2019 11:24:41 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3FA22369CC; Mon, 20 May 2019 15:24:41 +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 C49D717DD0; Mon, 20 May 2019 15:24:39 +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> From: Waiman Long Organization: Red Hat Message-ID: <3385cf54-7b6c-3f28-e037-f0d4037368eb@redhat.com> Date: Mon, 20 May 2019 11:24:39 -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: <1558363938.3742.1.camel@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 20 May 2019 15:24:41 +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 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. Cheers, Longman