Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1861435ybd; Thu, 27 Jun 2019 02:51:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBRVhb76XJKwTJiy6u1K7p8FXWuYD38WXDzk+L80KZP4AzMINoPQTYQloHbv0z9epTC1gD X-Received: by 2002:a17:90a:3ae8:: with SMTP id b95mr4894725pjc.68.1561629098876; Thu, 27 Jun 2019 02:51:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561629098; cv=none; d=google.com; s=arc-20160816; b=Eky/0iiRmqGvxRr+dgoI6G2enx47gZXG02GcP/tD/mb82Lf2GSXx9yoBpyP/4xEz9l EU8gGH81KOuErEoOjJpmvsHyZIR+3ZdAAhwrCZRqKqIRj3enRWzZdVOJhgi04DdEO7gP v2917U662w5edZNoGOjpciFMB3CJxb/q2rrfOEXls88BucPG53lDbl6ignbUcQThfxe5 vI2OpSlLIBrbZMeM8o/tHDZcULhppPIFJwCn55/BIivFhP3ckwNp/LGROaBRyAMdBO9B HLQ0XOACpTdy5M15pzqmACnuc8JJWNQnfP2PNEFN5o80kxvzm+Y8Y06CvzRkon8s5IKU XQ3g== 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:message-id:date :subject:cc:to:from; bh=Q0VYhiMls/2dkgb6nYh1gPUW1TvODbOMcaxSF77w8VI=; b=QHeGtRaeY3j9ZzsgwTyXX9ekv65Ea5kLu3fcxzOfVS/O+40sv/3DrcwC7BAkEn/s8N je8zJTdu4XO2uutKYvWGiAOMa3YaTXB9AFE06DlIPc/QlqkrKX3pyBkwQ60wnosenAFA Cy9/P8cmjBdKsjvHcfjEaXqeMDAuim2i1q2KU0ROA6c8prfMpEl+Pkbw4I36rO6T/JEO 51A7XcB7ifzQRezLLOB1EJh5CL5m6udtzFF0NEodzupCMJigKJXQ7UTZcBEnMtIuhTY9 PQ0IjewMEJHr0iycswdQKQ9rblj4Ty0y5X50hWn8gvtax4OT5CEwFrTBXD/LEFsIqYdS MOlQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z17si1651747pgv.485.2019.06.27.02.51.22; Thu, 27 Jun 2019 02:51:38 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726511AbfF0JvB (ORCPT + 99 others); Thu, 27 Jun 2019 05:51:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39074 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726292AbfF0JvB (ORCPT ); Thu, 27 Jun 2019 05:51:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0716830BB367; Thu, 27 Jun 2019 09:51:01 +0000 (UTC) Received: from oldenburg2.str.redhat.com (dhcp-192-180.str.redhat.com [10.33.192.180]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 20F185D71B; Thu, 27 Jun 2019 09:50:59 +0000 (UTC) From: Florian Weimer To: linux-fsdevel@vger.kernel.org Cc: Alexander Viro , linux-kernel@vger.kernel.org Subject: [PATCH] fs: Fix internal type confusion in getdents system calls Date: Thu, 27 Jun 2019 11:50:58 +0200 Message-ID: <878stnwe4d.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 27 Jun 2019 09:51:01 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The callback functions use a signed int type, but the callers have only verified the value as an unsigned type. This should be only a cosmetic change because if the value wraps around, this error check catches it: if (reclen > buf->count) return -EINVAL; But it should be clearer to prevent the wrap-around. Signed-off-by: Florian Weimer --- fs/readdir.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/readdir.c b/fs/readdir.c index 2f6a4534e0df..d344061e387e 100644 --- a/fs/readdir.c +++ b/fs/readdir.c @@ -159,7 +159,7 @@ struct getdents_callback { struct dir_context ctx; struct linux_dirent __user * current_dir; struct linux_dirent __user * previous; - int count; + unsigned int count; int error; }; @@ -246,7 +246,7 @@ struct getdents_callback64 { struct dir_context ctx; struct linux_dirent64 __user * current_dir; struct linux_dirent64 __user * previous; - int count; + unsigned int count; int error; }; @@ -413,7 +413,7 @@ struct compat_getdents_callback { struct dir_context ctx; struct compat_linux_dirent __user *current_dir; struct compat_linux_dirent __user *previous; - int count; + unsigned int count; int error; }; -- 2.21.0