Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967257AbdD0Lyk (ORCPT ); Thu, 27 Apr 2017 07:54:40 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:33916 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967575AbdD0LyT (ORCPT ); Thu, 27 Apr 2017 07:54:19 -0400 To: Linus Torvalds Subject: [PATCH] statx: correct error handling of NULL pathname Cc: mtk.manpages@gmail.com, David Howells , Al Viro , linux-man , Linux API , Eric Sandeen , Linux Kernel Mailing List , fstests , linux-fsdevel , Michael Kerrisk , hch@infradead.org From: "Michael Kerrisk (man-pages)" Message-ID: Date: Thu, 27 Apr 2017 13:54:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1093 Lines: 36 The change in 1e2f82d1e9d1 to error on a NULL pathname to statx() is inconsistent. It results in the error EINVAL for a NULL pathname. Consistent with similar APIs (fchownat(), fstatat(), linkat()), the error should be EFAULT. The solution is simply to remove the EINVAL check. As I already pointed out in https://lkml.org/lkml/2017/4/26/561, user_path_at*() and filename_lookup() will handle the NULL pathname as per the other APIs, to correctly produce the error EFAULT. Signed-off-by: Michael Kerrisk --- fs/stat.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index 3d85747..a257b87 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -567,8 +567,6 @@ SYSCALL_DEFINE5(statx, return -EINVAL; if ((flags & AT_STATX_SYNC_TYPE) == AT_STATX_SYNC_TYPE) return -EINVAL; - if (!filename) - return -EINVAL; error = vfs_statx(dfd, filename, flags, &stat, mask); if (error) -- 2.5.5 -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/