Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3007131imm; Sun, 1 Jul 2018 10:10:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd1o+KmoulBcwIXdrogYnYCZCFB6pBg/B9c3mpRZGkcpFRX1zo0INNt5v7Smvgltj3b88tP X-Received: by 2002:a62:5984:: with SMTP id k4-v6mr7775930pfj.116.1530465016723; Sun, 01 Jul 2018 10:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530465016; cv=none; d=google.com; s=arc-20160816; b=wk2yH+ryX+VkbfCBSHaKtiUV7cS8WJ9MSEh8fB2ufPfZV0PXqRSUQOtNeRrvjN8Qrk DkAJEfCp91Xiyh6pi9bLn3QibKaHj2j7BE2A9qOO0lEHM+BJZ7HBq/hRUs2paTKAEDLw +13JTW9vd2bkxXcGnhT4MQVofR9/24KmQQQTyhKpFM8gT2u7GZMPQ4sGkLKi36BZabRl JZHU5uqHapL0/6nn8YgqrbgRJJTKmknIDnU07qVi7+hKBiboeSpaz1Zh96N7FCs5vybT bsuFBx4Nr39jdp09iQE1EUljd0LU9GpKYqIRe6Rm3++hFy3QSjyS27/jOeGdyZXPqbk9 X6Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=csUFTu+kMbLOcvBhzePqOXMO3w2xto2RZzH2PaTG7so=; b=vvP5rP3aWHISLGWhKQXafGqgl8hIABOb9vRDewS/qWbALQ4USoqGpRZ9emCrmww5bB dSbVximDbeZRjDK6fDMZdLZ+fovUKpoZCONbqx8S2ZTQIPa00D5NHOnMI7lrVVc+iz6u TfXrHH9/O2ERIV8aa4cxS+CF2nT37lmCkwJ1/SMnAOTVyx0hJA2CUBMnYcK+SMwMWQlL BAlBAkiLZ4b2dWQ3+RA7SN6FmKDkWHC8JCW4MeUWvozxBTmTaXaQGVJSD26zefDE1xqW q65snZjKyu9zQQ4LE7V8rmNOlT1VEwU7WQRvVF+jCcx2ZUmSPjtAz3HtG3DQ7O8C2aHX e8fg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2-v6si14173854plq.372.2018.07.01.10.10.02; Sun, 01 Jul 2018 10:10:16 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031731AbeGAQlh (ORCPT + 99 others); Sun, 1 Jul 2018 12:41:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37396 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031508AbeGAQlb (ORCPT ); Sun, 1 Jul 2018 12:41:31 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0A298AA6; Sun, 1 Jul 2018 16:41:30 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joakim Tjernlund , Boris Brezillon Subject: [PATCH 4.17 107/220] mtd: cfi_cmdset_0002: fix SEGV unlocking multiple chips Date: Sun, 1 Jul 2018 18:22:11 +0200 Message-Id: <20180701160912.851657387@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joakim Tjernlund commit 5fdfc3dbad099281bf027a353d5786c09408a8e5 upstream. cfi_ppb_unlock() tries to relock all sectors that were locked before unlocking the whole chip. This locking used the chip start address + the FULL offset from the first flash chip, thereby forming an illegal address. Fix that by using the chip offset(adr). Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking") Cc: stable@vger.kernel.org Signed-off-by: Joakim Tjernlund Signed-off-by: Boris Brezillon Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/chips/cfi_cmdset_0002.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -2515,7 +2515,7 @@ static int cfi_atmel_unlock(struct mtd_i struct ppb_lock { struct flchip *chip; - loff_t offset; + unsigned long adr; int locked; }; @@ -2651,7 +2651,7 @@ static int __maybe_unused cfi_ppb_unlock */ if ((adr < ofs) || (adr >= (ofs + len))) { sect[sectors].chip = &cfi->chips[chipnum]; - sect[sectors].offset = offset; + sect[sectors].adr = adr; sect[sectors].locked = do_ppb_xxlock( map, &cfi->chips[chipnum], adr, 0, DO_XXLOCK_ONEBLOCK_GETLOCK); @@ -2695,7 +2695,7 @@ static int __maybe_unused cfi_ppb_unlock */ for (i = 0; i < sectors; i++) { if (sect[i].locked) - do_ppb_xxlock(map, sect[i].chip, sect[i].offset, 0, + do_ppb_xxlock(map, sect[i].chip, sect[i].adr, 0, DO_XXLOCK_ONEBLOCK_LOCK); }