Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3055950imm; Sun, 1 Jul 2018 11:12:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdXbEHbq//BZEA7I2FF+bRnYeGfAQxKTv8mkKzhcsXjT1MIbiu3ph0wRZldzLkK7Xp5jlWY X-Received: by 2002:a62:5601:: with SMTP id k1-v6mr22494450pfb.212.1530468749285; Sun, 01 Jul 2018 11:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530468749; cv=none; d=google.com; s=arc-20160816; b=if5dst1dFHLwRbhdrlS5n38ZJ5kQlZD8xJK5izN60FcIS0tx8tISc6uZlwDiyd4jvZ C8dYBMk1FPPMPogVvFcUqb8yViJRJGTVTbKBA27RF4haJ4l9w56Qhr6qBGYNxIud3Ww+ OnyD05rGFnG35lOfqOZjSD3rJKf8WrWakZxsbbIYJGMzQ7dO7vvrQeDVEw9pv7ipJmMk F2eExx9ri7uWEFPfU7nJ17q/H7/7tAqePeGjnS/YGfRZqJJdRInb76risf1k6PPL677o hPt5rWnIR8SPGSi10ExyOyazW2Ku8gQ3Uy0a4O/LFr239TLsiPEaMZKdvxjs9xWznKQZ 2kxg== 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=S2Bgpkpk2MVh4y+To7OoqXE8afeU/AAAoeCrqa90JDs=; b=Zuvc5zaxxVpwAQUmafgpZMyDjLTlTJjSUEu8ZgQmVvuUwat2aiqCPYXkyEmT7mMPB+ 6NV8sWiJDOzLGyhkeIKCNNV2E9GF204BgPsBVAbsBzFAMD1EHtVCC2Q76C+5o15pBHYd UxxwDEflKs6WVov9ysg5oabWLlPPsb8cXKQWTzLGOBsFkjX/PQtwMpAI0jTvxk+Juq60 rNPGOdGhmkGlTLfoh47tHlnKjQiia4OzyoAmGOpTpJRjJ42uZV+rjs1lvFQKClCeKfPZ PdtqLdtDaZJ5UyhTiRuWsAE78M0ni+7l3Ulvctjb/xMvEcjZ0kzsxomfp1HnndnqpQZ7 Emfw== 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 y20-v6si13996509pfm.186.2018.07.01.11.12.15; Sun, 01 Jul 2018 11:12:29 -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 S1030196AbeGASKp (ORCPT + 99 others); Sun, 1 Jul 2018 14:10:45 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34176 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753269AbeGAQ1s (ORCPT ); Sun, 1 Jul 2018 12:27:48 -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 095CA92B; Sun, 1 Jul 2018 16:27:46 +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.9 042/101] mtd: cfi_cmdset_0002: fix SEGV unlocking multiple chips Date: Sun, 1 Jul 2018 18:21:28 +0200 Message-Id: <20180701160758.843631570@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160757.138608453@linuxfoundation.org> References: <20180701160757.138608453@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.9-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 @@ -2531,7 +2531,7 @@ static int cfi_atmel_unlock(struct mtd_i struct ppb_lock { struct flchip *chip; - loff_t offset; + unsigned long adr; int locked; }; @@ -2667,7 +2667,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); @@ -2711,7 +2711,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); }