Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp968112img; Mon, 18 Mar 2019 19:39:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwq6iFJ3rMYvNb9MT0MorqpJ1sN6dfSBcbYRGyWAvfXT48jD+uXfexuiOr/7gZiVbbY7Hqy X-Received: by 2002:a17:902:32b:: with SMTP id 40mr58085pld.122.1552963190620; Mon, 18 Mar 2019 19:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552963190; cv=none; d=google.com; s=arc-20160816; b=cxZhpqJ76MKsz4+HT73EHLUYJm0NeQv/wjBNRHbceDALWB1XU+HfKV1deCWm4DH99B +47HKopGrNDhDgTI+AFCO6ZWblQnLpbdGkAfdt/htkDo5ciYWFc3bbB6DV6Kk2mgOZwz Nl5SovuWhSiGw31iOuxfZNt9LlpJaBfmF5YH4w0eBqfTkB9RNB0GX9Cav48ybFKG/FXt mhjTr1bmzozoUwIeQz2FEe9Utleo7mCXIR21V8KLqeS3HyvKAL6oPRnTAdrJQqLr2Ao1 hjhqbgJPin2fCGHOfCj0mjGSIgT2pzx5VbTxSypsgNDXdlNFBKD0A1KNplC3IGKQHKIw FuXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=SrWCrmloewbKXSPqrcNLcMLvFQIickS8gB6OQnyLIqE=; b=YCexoEAqm0cFwTsjnMdL5bUBF9OGesLmnOC2k7XP4BFb52PQgSdNQfmE85XPaNzxo8 AJczPsqcFKm9NneXPNIbWFRgv6p2Iwdt+/lSYRYr4t6NCLlAWdHUrBwrmDWDJU7rBDej oxIU2AFP6i+hD27sMRauPRX7CfjAH+EL6RjroY40AzECnC8QtwCcjOGyiMn0ndacrcaQ B0xinZBr3hUSpSyLM0PHG1ZmGZikqIqfNnY07UedYL2I+NS1Mt1SUIhDtnsvDFfe5WSu SkPk3w4QQsySkZTugNTylpcL8+GbSlU4d06ExQ7wZJkSEeQD11krz83AWujN5gFC2giV jXRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Ugw3hlPw; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j19si4952651pfh.124.2019.03.18.19.39.35; Mon, 18 Mar 2019 19:39:50 -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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Ugw3hlPw; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727482AbfCSCjA (ORCPT + 99 others); Mon, 18 Mar 2019 22:39:00 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:34750 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbfCSCjA (ORCPT ); Mon, 18 Mar 2019 22:39:00 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2J2XtGG039801; Tue, 19 Mar 2019 02:38:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=SrWCrmloewbKXSPqrcNLcMLvFQIickS8gB6OQnyLIqE=; b=Ugw3hlPwueaNL/T1bU800q/ff+UsRfVTIrCf2CxmJq4G/i0tMEZRQdms3HZvzIB32NEk 51LNBg5YkCemtKXxPft5OLpj6ITT6Z0VRIvJuPWf1zuNbRkIy9rhmm5WnUxyIWRHIdil pSYtEVACapZtG1jfH1wK9fOJ60hFmFEP1MVvzUR6qd+LTlHRMmCEkcXq5l1/cfxp9KpT VnOGcrshsPCsjt0stR2OOxsyRZb5BKkx8wA88Woa6p1yHylq1cJEOtvt1xYpihSI4ESf lNlewIk4LlZcsZTQHL9f1nJpwtYqa40QfHH/04GYGzZL1Ze29iwrkRtL5AnnE6biS2Af nA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2r8rjuhyvs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Mar 2019 02:38:55 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x2J2cnOu020920 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Mar 2019 02:38:50 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x2J2cn5X023967; Tue, 19 Mar 2019 02:38:49 GMT Received: from [10.182.69.118] (/10.182.69.118) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Mar 2019 19:38:49 -0700 Subject: Re: [BUG] scsi: ses: out of bound accessing in ses_enclosure_data_process To: "Ewan D. Milne" , "Martin K. Petersen" Cc: jejb@linux.ibm.com, "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Junxiao Bi , diego.gonzalez@oracle.com References: <78dd3eca-7e8a-72f9-07f9-e2c7cc4569b0@oracle.com> <3b2542225e519a8cf8e329745b0ee2e2464787c7.camel@redhat.com> From: "jianchao.wang" Message-ID: <92bf2380-626c-d51a-3f8b-de30462d4dd3@oracle.com> Date: Tue, 19 Mar 2019 10:41:58 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <3b2542225e519a8cf8e329745b0ee2e2464787c7.camel@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9199 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903190018 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/18/19 11:22 PM, Ewan D. Milne wrote: > On Mon, 2019-03-18 at 01:01 -0400, Martin K. Petersen wrote: >> Jianchao, >> >>> When our customer probe the lpfc devices, they encountered odd memory >>> corruption issues, and we get 'out of bound' access warning at >>> following position after open KASAN >> >> Please provide the output of: >> >> # sg_ses -p 1 /dev/sgN >> # sg_ses -p 7 /dev/sgN >> >> for the enclosure device in question. >> > > The ses driver is allocating kernel buffers based upon the size > reported by RECEIVE DIAGNOSTIC commands, and is iterating through > them based on sizes in the individual descriptors. It appears to > be vulnerable to incorrect data from the device causing out-of-bounds > memory access, because the for() test does not prevent the use of > the pointer in subsequent code, e.g.: > > for (i = 0; i < num_enclosures && type_ptr < buf + len; i++) { > types += type_ptr[2]; > type_ptr += type_ptr[3] + 4; > } > > ses_dev->page1_types = type_ptr; > ses_dev->page1_num_types = types; > > Whether or not this is the current problem, it's wrong. > Yes, I definitely agree with this. There should be some change here. Thanks Jianchao