Received: by 10.223.185.116 with SMTP id b49csp6348621wrg; Wed, 28 Feb 2018 08:00:21 -0800 (PST) X-Google-Smtp-Source: AH8x224bGmaVtbJvXcRMZv7fptQrpsdPitTR5sqxoeRZwnB2WN9g4qa7YT4BB6vyc1HuQauJSDIp X-Received: by 10.101.97.139 with SMTP id c11mr14543761pgv.435.1519833621006; Wed, 28 Feb 2018 08:00:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519833620; cv=none; d=google.com; s=arc-20160816; b=vHbiiwAPbBfYIOPAJnLRDfLBC3WP0HIQ0FkkVee23R+k0uUzNjjVZaT/VPn5x026OQ Swiu2s070mMvNbKJSy4RglhvgthZ9CGDEDjVZVW2emwCFiaFBMIDbsKRFqLCU5fzKtrP Gzl0w982SLj6SpV7KgzeKnSPemwJG7EdP2c2EgOjTNlSpU6LDKy4H+dYuMZ+XlaxVJqm UAtGqXqSOxop4YPSIM1wsTbU5/B9o9OPldWGLOZm12RqklhgXWgrfjFXUeXLi2tU+pod 5rTbHEPwcX9Q9bJ91q3VEK91GjaaS6mESMPZQXVVhD0l3g8ZEudBsLFZUgmmw/0L1uEc /k3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=RBgcDFn5d2Yte5f+7+V0JVQMz9P9HkiTjvwkP7lo0qY=; b=Ky2HmWfOeA3/pGUm8ZBfyoQQj8E2Ct5P99/OPJyORefm+dEhByBqyzUwp/7u/UmyRv tyBM98onCDr68MM9KzqlbHPF02WCHw+qkSf9nKFR2otavVkXRC59vFuDNgsotVYJaEJV OekF78Ae2gTKMeXdeehXtqVxzuTSqPvNYyD02STewuy3xR24PpyLCEgA6Ct8kZ+sJoXW FEv64QjOy7fJlrzN2Lkt42x1wmnKM6Yy/WVvowBaZVpu6bK5n45xJ1PbnGu3IDJGXRP3 RBkxHOoyQ+IOC6487K7xxNsUDS+4Z3GZEAN89JL4A/LNxSE6Wg67nzGJ3urgaFPvL9Lw lEIQ== 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 n18si1415833pfj.58.2018.02.28.08.00.05; Wed, 28 Feb 2018 08:00:20 -0800 (PST) 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 S934148AbeB1P50 (ORCPT + 99 others); Wed, 28 Feb 2018 10:57:26 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34508 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934008AbeB1P5X (ORCPT ); Wed, 28 Feb 2018 10:57:23 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yu-0006Xf-Bg; Wed, 28 Feb 2018 15:22:32 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yd-0008Oo-Q2; Wed, 28 Feb 2018 15:22:15 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Heiner Kallweit" , "Bartosz Golaszewski" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 032/254] eeprom: at24: check at24_read/write arguments In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Heiner Kallweit commit d9bcd462daf34aebb8de9ad7f76de0198bb5a0f0 upstream. So far we completely rely on the caller to provide valid arguments. To be on the safe side perform an own sanity check. Signed-off-by: Heiner Kallweit Signed-off-by: Bartosz Golaszewski Signed-off-by: Ben Hutchings --- drivers/misc/eeprom/at24.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -274,6 +274,9 @@ static ssize_t at24_read(struct at24_dat if (unlikely(!count)) return count; + if (off + count > at24->chip.byte_len) + return -EINVAL; + /* * Read data from chip, protecting against concurrent updates * from this host, but not from other I2C masters. @@ -396,6 +399,9 @@ static ssize_t at24_write(struct at24_da if (unlikely(!count)) return count; + if (off + count > at24->chip.byte_len) + return -EINVAL; + /* * Write data to chip, protecting against concurrent updates * from this host, but not from other I2C masters.