Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3069086imm; Sun, 1 Jul 2018 11:31:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpczTNMhHjmwqwqxUNg5PT+ZspLOeKryi//Vl3cC/2g6Kh7yzbsj608+o0Aod+E/WMD3o4La X-Received: by 2002:a63:4924:: with SMTP id w36-v6mr4462603pga.143.1530469885980; Sun, 01 Jul 2018 11:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530469885; cv=none; d=google.com; s=arc-20160816; b=rCuqeC9Gop83g4gdBan8x8E17ranoz2AotkZgW82+XNssJTrgvxF6ALh7ewH0WhZwT ofTIDlPOqDvUSyLAs/FGBVtFOk4piuZSIlcvwWTjwyju5N2jRzav69pmxgcy0a8YjJVR veAJO7qzK7giJDFrGBrvJdGH9xAGM6gjDExEB4FxmRzUjKJDTuzMUsX2oMvwn55+0nMP lb58jzzAeTzWu+M8ATVt4lIdJxjSIeOwzIFWyugGo04CuyoMLOf3VWpkapdO3C+IshXh riJV1DejXVkXl/Wj+6T5yYvk4LSBBht3rqIgh1dx7qnLOajpsRB+ucHxpRJSDfXwd19t W0DA== 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=9XVSs6COKXb+vvznn7GG2haDbEMk4Cu47AhhybQzqd4=; b=dwlUOFAHvwHbwkUnEnaTwXqosLJ5o1tZqXwz+a0ZyHhGwz6B4AfqeSiyzIPnf6taqn TlEddeAy19wria6VInsocpUrSIntqODecjRipNzxnHhoDC22E5mOe22yWdRS150nnu5J QxPpO8mUTqg5AkowZOIJVUMyJmtLboaNH3LGzombv99refF+XJXqzWavPgIpLOIk/VEG SywBklFNuetv2Lrm2ZOLQvoDeXy+AEU7nBLWrVwjVZbmzb8Am3r9VAmsPOiVyYxF/XSV lqYOqwAUOcM/qpvdPLm0KMPviIWoA32Ln5DYo7KqromTQbpE7+rFvRjEDlLUrAmjERAd xPeA== 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 p18-v6si14139960pfe.150.2018.07.01.11.31.11; Sun, 01 Jul 2018 11:31:25 -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 S964911AbeGASaG (ORCPT + 99 others); Sun, 1 Jul 2018 14:30:06 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60994 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753101AbeGAQRQ (ORCPT ); Sun, 1 Jul 2018 12:17:16 -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 22F3386A; Sun, 1 Jul 2018 16:17:15 +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.4 054/105] mtd: cfi_cmdset_0002: fix SEGV unlocking multiple chips Date: Sun, 1 Jul 2018 18:02:04 +0200 Message-Id: <20180701153153.446058390@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701153149.382300170@linuxfoundation.org> References: <20180701153149.382300170@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.4-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 @@ -2533,7 +2533,7 @@ static int cfi_atmel_unlock(struct mtd_i struct ppb_lock { struct flchip *chip; - loff_t offset; + unsigned long adr; int locked; }; @@ -2669,7 +2669,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); @@ -2713,7 +2713,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); }