Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp105032yba; Wed, 17 Apr 2019 20:42:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVEAPCSA5yNG4iCF8tfELbjJ14AEl8AsIXdRmYMAP8Lt68tK1DVFtCZmvdEoXaRlnVKILV X-Received: by 2002:a62:ab14:: with SMTP id p20mr93355548pff.23.1555558946804; Wed, 17 Apr 2019 20:42:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555558946; cv=none; d=google.com; s=arc-20160816; b=W4d6Mf/mqh3e2CRxALAlMsGJFnp2ZQbDR/nw2sVpNicFFQTbZKs+TOsvx4+BFCT+Qz arMJBgtl6UU0fUKoVssx3TLX3Se1wqXeUhCgHeLYU52ONtCDj7jnFHYrmPK5f6XEZTCD 5eazsFx59hZ/xaA0tPSQXicCkIEeUWMO8e20ijm5yRTurq+d2dSb3OC8+4tPl47w3WAc DQ6oNCkPW3VXxKU1Hocd399yMiKrSeleeY54IuYf7UAyGzYgYnHq6/zcb9yNBzP5avRJ i3jLOfqWk+hkrLUo3IymP0vrmziyrsnG+z303HQkVGA6DC7wPVjk4qOiIVPp7uujWQsv eJdA== 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:mime-version :message-id:date:subject:cc:to:from; bh=ydcSIj39wCnJ1CPDWntPdXmT0dEIRTHf4XW6J28fHoo=; b=QeeHNB5Da9JWhRsPpX6CJRglFBHovjYpPV9st4yHg3Kt3C2Hpsmrmvv7OgWIFiGC4G vb5BAiv0TxZJpLtZrJBFeafE/Uf/FW/H+FyOhPQq7p2zYvD7oDA6wh1jFWX0yt0cY+DR wNdBbnF3olOsV5EPRPiCKLKzLWHm97hC9YVOARnJww2G/HOYcICrS1evgW6W95udlzQ2 q8/kHY8mL/V71ISQASd1FxTPdIuZAGQyJsdsWuO2IST/A9/NLn41MNN75DGjs7hUnGd9 eVVIoR7MN/tE4oAhG6th5WJGWQ9bmSt7cqGbO3miq6avtA3gpMBgiNZmSMjokiyyw1/W a10Q== 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=ucloud.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si790849pgo.563.2019.04.17.20.42.11; Wed, 17 Apr 2019 20:42:26 -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=ucloud.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387961AbfDRDlU (ORCPT + 99 others); Wed, 17 Apr 2019 23:41:20 -0400 Received: from m97188.mail.qiye.163.com ([220.181.97.188]:9916 "EHLO m97188.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732325AbfDRDlU (ORCPT ); Wed, 17 Apr 2019 23:41:20 -0400 Received: from localhost (unknown [117.48.120.186]) by m97188.mail.qiye.163.com (Hmail) with ESMTPA id 3903F962848; Thu, 18 Apr 2019 11:41:17 +0800 (CST) From: WANG Chao To: Borislav Petkov Cc: Tony Luck , linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org Subject: [PATCH 1/3] RAS/CEC: fix __find_elem Date: Thu, 18 Apr 2019 11:41:13 +0800 Message-Id: <20190418034115.75954-1-chao.wang@ucloud.cn> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kIGBQJHllBS1VLV1koWUFJQjdXWS1ZQUlXWQkOFx4IWUFZMjUtOjcyP0 FLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MD46Nww*Qjg3CDAiHyovCUhL LxYaFChVSlVKTk5OTk5DQ0xMT0tJVTMWGhIXVRgTGhRVDBoVHDsOGBcUDh9VGBVFWVdZEgtZQVlK SkxVT0NVSklLVUpDTVlXWQgBWUFKSE1JNwY+ X-HM-Tid: 0a6a2e88c83c20bckuqy3903f962848 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A left over pfn (because we don't clear) at ca->array[n] can be a match in __find_elem. Later it'd cause a memmove size overflow in del_elem. Signed-off-by: WANG Chao --- drivers/ras/cec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c index 2d9ec378a8bc..2e0bf1269c31 100644 --- a/drivers/ras/cec.c +++ b/drivers/ras/cec.c @@ -206,7 +206,7 @@ static int __find_elem(struct ce_array *ca, u64 pfn, unsigned int *to) this_pfn = PFN(ca->array[min]); - if (this_pfn == pfn) + if (this_pfn == pfn && ca->n > min) return min; return -ENOKEY; -- 2.21.0