Return-Path: Received: from wtarreau.pck.nerim.net ([62.212.114.60]:9155 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754961AbbILXLr (ORCPT ); Sat, 12 Sep 2015 19:11:47 -0400 Message-Id: <20150912225607.725561395@1wt.eu> Date: Sun, 13 Sep 2015 00:56:33 +0200 From: Willy Tarreau To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ben Hutchings , Jan Kara , Willy Tarreau Subject: [PATCH 2.6.32 27/62] x86_64: Fix strnlen_user() to not touch memory after specified maximum MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 In-Reply-To: <08d3b586eb2e764308c3de9ee398a17c@local> Sender: stable-owner@vger.kernel.org List-ID: 2.6.32-longterm review patch. If anyone has any objections, please let me know. ------------------ From: Ben Hutchings Inspired by commit f18c34e483ff ("lib: Fix strnlen_user() to not touch memory after specified maximum") upstream. This version of strnlen_user(), no longer present upstream, has a similar off-by-one error. Signed-off-by: Ben Hutchings Cc: Jan Kara (cherry picked from commit 4797489ce83a5f42d0b38089695a48d4a3d1ee0b) Signed-off-by: Willy Tarreau --- arch/x86/lib/usercopy_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c index b7c2849..3428d91 100644 --- a/arch/x86/lib/usercopy_64.c +++ b/arch/x86/lib/usercopy_64.c @@ -113,7 +113,7 @@ long __strnlen_user(const char __user *s, long n) char c; while (1) { - if (res>n) + if (res >= n) return n+1; if (__get_user(c, s)) return 0; -- 1.7.12.2.21.g234cd45.dirty