From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756154AbcKBTe1 (ORCPT ); Wed, 2 Nov 2016 15:34:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56066 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754554AbcKBTeZ (ORCPT ); Wed, 2 Nov 2016 15:34:25 -0400 From: Andreas Gruenbacher To: Casey Schaufler Cc: Andreas Gruenbacher , Al Viro , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Stephen Smalley Subject: [PATCH] Re: Problem with setxattr on sockfs with Smack after 971df15bd54ad46e907046ff33750a137b2f0096 Date: Wed, 2 Nov 2016 20:34:21 +0100 Message-Id: <1478115261-29669-1-git-send-email-agruenba@redhat.com> References: In-Reply-To: X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 02 Nov 2016 19:34:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Casey, does this patch help? (The way how security xattrs are handled by LSM is pretty ugly. I'm not convinced that it doesn't break something else, yet.) Thanks, Andreas --- fs/xattr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/xattr.c b/fs/xattr.c index 3368659..bf09836 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -183,11 +183,13 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const char *name, security_inode_post_setxattr(dentry, name, value, size, flags); } - } else if (issec) { - const char *suffix = name + XATTR_SECURITY_PREFIX_LEN; - + } else { if (unlikely(is_bad_inode(inode))) return -EIO; + } + if (issec && error == -EOPNOTSUPP) { + const char *suffix = name + XATTR_SECURITY_PREFIX_LEN; + error = security_inode_setsecurity(inode, suffix, value, size, flags); if (!error) -- 2.7.4