From patchwork Wed Sep 30 12:33:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 7297601 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D37759F536 for ; Wed, 30 Sep 2015 12:37:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 06880206B6 for ; Wed, 30 Sep 2015 12:37:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2136B206A1 for ; Wed, 30 Sep 2015 12:37:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZhGcC-0003Pq-Gg; Wed, 30 Sep 2015 12:36:08 +0000 Received: from mail-wi0-f169.google.com ([209.85.212.169]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZhGbU-00028K-J5 for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2015 12:35:25 +0000 Received: by wicfx3 with SMTP id fx3so195108283wic.1 for ; Wed, 30 Sep 2015 05:35:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8uazZ6VHY8K7kbhmHnWagKH44pkYnWaNM5a1x/f7bEo=; b=Duka2CEGz1a/RwUK+3/EJXTYZlExjcaVcRceSQ1BObe0DZe9z5rYN7XPsLvMxLUpBN wqPAZ/m2opuSo4qmBvlMSvgznwYTwIsB9uouU8JR+Q7TU7kv9MO8dyfZdfeZwyfepvnP HRJERhU3uGVgLaWjkZryLS19AvQ7ITjZPbCmC3oN6Az2tnbZWL8uJ7IsWPGK9fIM/cIM NgyC2AsOitIyl16S99sTdzYqtxy2aSSDmEUMZ0MFwNyef03pZ62Tz00DBnDpIcaObKRR a7JOumDR0JeTyZeyF2V+whNH50twytp2HhV1UFEYSi88tfKe1yB9YTej78S2SgBwcNBe QAAA== X-Gm-Message-State: ALoCoQmqLsIq4lCzcpWppH5v6V+j5sFsCklUrUke4z3VX7/q7IYZMRY/A7yrazZXHNbTV2VB9u7V X-Received: by 10.180.198.178 with SMTP id jd18mr32201559wic.34.1443616502701; Wed, 30 Sep 2015 05:35:02 -0700 (PDT) Received: from localhost.localdomain (host-92-13-246-184.as43234.net. [92.13.246.184]) by smtp.gmail.com with ESMTPSA id s1sm17152218wik.16.2015.09.30.05.34.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Sep 2015 05:35:02 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Subject: [PATCH 1/4] nvmem: core: fix the out-of-range leak in read/write() Date: Wed, 30 Sep 2015 13:33:56 +0100 Message-Id: <1443616436-17565-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1443616298-17389-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1443616298-17389-1-git-send-email-srinivas.kandagatla@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150930_053524_790773_4D89DBA0 X-CRM114-Status: GOOD ( 13.38 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ZhengShunQian , maxime.ripard@free-electrons.com, srinivas.kandagatla@linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: ZhengShunQian The position to read/write must be less than max register size. Signed-off-by: ZhengShunQian Acked-by: Srinivas Kandagatla Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index d3c6676..f4af8e5 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -67,7 +67,7 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj, int rc; /* Stop the user from reading */ - if (pos > nvmem->size) + if (pos >= nvmem->size) return 0; if (pos + count > nvmem->size) @@ -92,7 +92,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj, int rc; /* Stop the user from writing */ - if (pos > nvmem->size) + if (pos >= nvmem->size) return 0; if (pos + count > nvmem->size)