From patchwork Thu Apr 27 11:54:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael Kerrisk (man-pages)" X-Patchwork-Id: 9702767 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E3A9E602CC for ; Thu, 27 Apr 2017 11:54:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C95D7204C1 for ; Thu, 27 Apr 2017 11:54:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDD2228449; Thu, 27 Apr 2017 11:54:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 770F9204C1 for ; Thu, 27 Apr 2017 11:54:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968559AbdD0Lya (ORCPT ); Thu, 27 Apr 2017 07:54:30 -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 Received: by mail-wr0-f193.google.com with SMTP id 6so3526011wrb.1; Thu, 27 Apr 2017 04:54:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:subject:cc:from:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=M5jMTcZ4ceAdgazgf0qLRBpNvFU1J83qznmvF+SrUKU=; b=S1gzyY+xtUeXECJZhpTeo/6N8Jbvw8RX1u1EodBbFCS6qPA7d09NJ9qTqDLOdZxOrF sWkIujUYvztmF4e9qioxcbqV7/i0Yk7ic2hM8VsT84qmr2PeI3v1pBQbB9qVR/O+MLeT +7Q7ldoX46rHIMilfwFh6z4TajFNG3Xc0v0Nnl6Yv3XdATPVwpnEXIzsxwujyMK58pTM d8VdiJPgRjUq9hHihum4h296a/5VAQghRb8rwTwwweL68cCFI4bLOAq9ZHp4IKw8/JAO FwVRoSErC8kyqNbopchvOSgbC2w5miVuiMc/hOHDMkGFJmE8VRfP8vJRC+0d89xQmtEg cTYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:subject:cc:from:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=M5jMTcZ4ceAdgazgf0qLRBpNvFU1J83qznmvF+SrUKU=; b=bBpKw8YKH0hhdFT7kxE9+d4+KwSV4rnB9VSYqW/etkYc9CYWxHGa9EomTKs+Xl3OIE HY5cjL6R9Wdsov0CgjtoAeznzmSfO/aPRfamf8Hvtu360HKrFlabX4Q83A6DBYBegVEz hz+dXL4aZJbwbA30SyZVSKJ4l1PKT1Jzud2Dh56cihnI5cuzAAq4mNWfMG3l8QThRgBU 3UcQYa2F1igedsGsu4xut+wZM9hydAIUyCH1b3OhiFqC4eNZXsbzcNY9JWW3f5mYoaeQ fjn0gmIgC3t/iIkx2lGW098gHkDjimAH6EnBOS4S8SKP8/bG2TNjaHd8ubDFY2ZihE3f IYmA== X-Gm-Message-State: AN3rC/4G2PIjorCduIk+wt7putY7IfgOXFB+CerTb2aL5dWs2ie8RSLu wnxlCIit/D2u5Q== X-Received: by 10.223.133.200 with SMTP id 8mr3414427wru.94.1493294057376; Thu, 27 Apr 2017 04:54:17 -0700 (PDT) Received: from [192.168.234.154] (mail2.jambit.com. [213.131.239.194]) by smtp.gmail.com with ESMTPSA id l81sm11040539wmi.22.2017.04.27.04.54.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Apr 2017 04:54:15 -0700 (PDT) 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 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)