From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755161AbbFCNur (ORCPT ); Wed, 3 Jun 2015 09:50:47 -0400 Received: from cantor2.suse.de ([195.135.220.15]:51328 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754532AbbFCNuk (ORCPT ); Wed, 3 Jun 2015 09:50:40 -0400 From: Jan Kara To: Linus Torvalds Cc: LKML , Jan Kara Subject: [PATCH] lib: Clarify the return value of strnlen_user() Date: Wed, 3 Jun 2015 15:50:35 +0200 Message-Id: <1433339435-3181-1-git-send-email-jack@suse.cz> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org strnlen_user() can return a number in a range 0 to count + sizeof(unsigned long) - 1. Clarify the comment at the top of the function so that users don't think the function returns at most count+1. Signed-off-by: Jan Kara --- lib/strnlen_user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c index fd03ae980013..77bc67222b9d 100644 --- a/lib/strnlen_user.c +++ b/lib/strnlen_user.c @@ -89,7 +89,8 @@ static inline long do_strnlen_user(const char __user *src, unsigned long count, * Get the size of a NUL-terminated string in user space. * * Returns the size of the string INCLUDING the terminating NUL. - * If the string is too long, returns 'count+1'. + * If the string is too long, returns a number larger than @count. User + * has to check the return value against "> count". * On exception (or invalid count), returns 0. */ long strnlen_user(const char __user *str, long count) -- 2.1.4