Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp580230ybm; Wed, 27 May 2020 02:54:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrm9TpRjAoHYpqFUm9+9Jkayjqbyq6bE9ozHwMrToyYV5eVULhG35DN1ajCs0xW3gqeM5t X-Received: by 2002:a05:6402:617:: with SMTP id n23mr23497515edv.107.1590573290096; Wed, 27 May 2020 02:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590573290; cv=none; d=google.com; s=arc-20160816; b=RQwtHagCy5h0+vA6PqrbfaLVRYksxC1NFYCJZEWa/++gSVMfMAfkdf6Jc1aER1Q09q euF49D9mS0odfwXnJBvAS/P3p7tEwnk8zMcJmUmFi+4Cd8QVz9sXKKPCIoMhlIUfhcHk adn93ShFrG6Gl3NWZUq41Lg2PSZEnmHMSzcX3PjuFopMiJaWQn9IsMu/AK0EM/mEE6vq 5k05GhyWhFFChZ9R0AIU3i1p4OiI1e+WZw2aI1/1FhDcsCndaJjRFI2MgJ/5Ib7T1IIS bhyRuUZMaoFHxvQ7peP/JTvJbe2KhnLzCcu43uqploSAYNXO3Dm2dfMyjePWWvEYgqIV 9daA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=62bWFuqjjYRHCtiXetCYD/KJZfcErk/k0VhDChgAXO8=; b=iUUeAAgoGGJpunnjp9XIMxzuISSMkbodvOkywh0nEL5VWHiBIyjDVa0+AIeOavJlQJ IJpkfp9gtYvgPgo36H1zOMvgUVUireqHqjhG5xmpii3MD0o7Fy14k2UAb3FaqUNttfK4 0sVpPcNnKfbvsA38oI+lIaO/KWqRmQeL3dyd6tWF1m78iW5Ntyxu1JfXaVOJbTMP0OMS QgXLgZJXXMs3/6yV7yWIc4Y+8/BiExesuRfB3y+Heich9sV7c55Kos9+tmjs/YQpEmE6 mkWiZXdzBlljSQltlw/U1I/jBqjXqZC4YnkU2odwhM4qUwHoFzz1Xzj926d8iuWP4/RI 0zpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dwJEyyvS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si1518508ejb.294.2020.05.27.02.54.27; Wed, 27 May 2020 02:54:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dwJEyyvS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727050AbgE0ElB (ORCPT + 99 others); Wed, 27 May 2020 00:41:01 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:26930 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725294AbgE0ElB (ORCPT ); Wed, 27 May 2020 00:41:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590554459; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=62bWFuqjjYRHCtiXetCYD/KJZfcErk/k0VhDChgAXO8=; b=dwJEyyvSETF9zX3PtBrzHLr22eVX34elyMtkFqnM7uFvcw1qXDQLOBuggb3gYgwY9oz+Sr b9U+qg3PdSRcjtYpzgA2VI5C8uF3PGMd6jNNqS+7LvvLyfN1q+vAKx1kLeyzYEPscf5y+3 DWUY2IDceWHQgDZrA3VeLzlk5TePNyE= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327-xqNSEbk6MrGVzz-G0Lg49A-1; Wed, 27 May 2020 00:40:55 -0400 X-MC-Unique: xqNSEbk6MrGVzz-G0Lg49A-1 Received: by mail-pj1-f72.google.com with SMTP id m7so1519408pjh.9 for ; Tue, 26 May 2020 21:40:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=62bWFuqjjYRHCtiXetCYD/KJZfcErk/k0VhDChgAXO8=; b=YRooqK42a4O5T/bJA7TIOa6Q+TfMXRZgCOa/kwlDiQqo0i4TGhWbGbSTQl3zwNR34z ylK0buHatdWe36q7bUEpkyFMgrm7f+5Ah6STT/XSZZngErtTqHxyGl9FpWPLyotN/67B MqLl17tRc1JeJoOMeD+DynN7PvxQjAf1OXPS+b3P+d8SFURblkuFVd49paeqbf/FvjsX S1IWsARFP3UWJ5HomC1+1hT3B2g4ZPqs+BC5WRbiahjvo/xV6ee1nKBDpQnmSg5+ak7R PvU3EiJpoYhnh+FYXIx5SPVyVE72ngTFdDKoHXd8Y5dvlVXOWOI55/Z7ZBAoMi55TBiP rCHw== X-Gm-Message-State: AOAM533eJFbC5LdOspfx2LM/S73svY+jeaGz+5AtMhDLEmo6OISYfCK7 veYo4VrcPmd2XHzOGqxqJyowYIn5rGZPM2of/HFRFJA0T+9Y8dDGVj/eaL45kB0RW9fEijBWURo RftLPiNM+zdJuJ8dy07N+sVA8 X-Received: by 2002:a17:90a:f0d8:: with SMTP id fa24mr2767946pjb.93.1590554454367; Tue, 26 May 2020 21:40:54 -0700 (PDT) X-Received: by 2002:a17:90a:f0d8:: with SMTP id fa24mr2767930pjb.93.1590554454100; Tue, 26 May 2020 21:40:54 -0700 (PDT) Received: from hsiangkao-HP-ZHAN-66-Pro-G1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id mt3sm926663pjb.23.2020.05.26.21.40.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 21:40:53 -0700 (PDT) From: Gao Xiang To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, LKML , Gao Xiang , Stephen Smalley , Chengguang Xu , Chao Yu Subject: [PATCH] xattr: fix EOPNOTSUPP if fs and security xattrs disabled Date: Wed, 27 May 2020 12:40:37 +0800 Message-Id: <20200527044037.30414-1-hsiangkao@redhat.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit f549d6c18c0e ("[PATCH] Generic VFS fallback for security xattrs") introduces a behavior change of listxattr path therefore listxattr(2) won't report EOPNOTSUPP correctly if fs and security xattrs disabled. However it was clearly recorded in manpage all the time. Cc: Alexander Viro Cc: Stephen Smalley Cc: Chengguang Xu Cc: Chao Yu Signed-off-by: Gao Xiang --- Noticed when reviewing Chengguang's patch for erofs [1] (together with ext2, f2fs). I'm not sure if it's the best approach but it seems that security_inode_listsecurity() has other users and it mainly focus on reporting these security xattrs... [1] https://lore.kernel.org/r/20200526090343.22794-1-cgxu519@mykernel.net Thanks, Gao Xiang fs/xattr.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/xattr.c b/fs/xattr.c index 91608d9bfc6a..f339a67db521 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -352,13 +352,15 @@ vfs_listxattr(struct dentry *dentry, char *list, size_t size) error = security_inode_listxattr(dentry); if (error) return error; - if (inode->i_op->listxattr && (inode->i_opflags & IOP_XATTR)) { - error = inode->i_op->listxattr(dentry, list, size); - } else { - error = security_inode_listsecurity(inode, list, size); - if (size && error > size) - error = -ERANGE; - } + + if (inode->i_op->listxattr && (inode->i_opflags & IOP_XATTR)) + return inode->i_op->listxattr(dentry, list, size); + + if (!IS_ENABLED(CONFIG_SECURITY)) + return -EOPNOTSUPP; + error = security_inode_listsecurity(inode, list, size); + if (size && error > size) + error = -ERANGE; return error; } EXPORT_SYMBOL_GPL(vfs_listxattr); -- 2.24.0