From patchwork Wed Jul 22 13:03:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Gr=C3=BCnbacher?= X-Patchwork-Id: 6843211 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7E7359F380 for ; Wed, 22 Jul 2015 13:13:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F4FA2053A for ; Wed, 22 Jul 2015 13:13:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B0E44204F6 for ; Wed, 22 Jul 2015 13:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933518AbbGVNM4 (ORCPT ); Wed, 22 Jul 2015 09:12:56 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:38557 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756866AbbGVNEe (ORCPT ); Wed, 22 Jul 2015 09:04:34 -0400 Received: by wibxm9 with SMTP id xm9so101353024wib.1; Wed, 22 Jul 2015 06:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cqp0tShQCy0WVAgxxcsWgnr4Vin09tWrHAAJmRWd/mg=; b=beRAgIEuRmbcUzKlrbeecCn0UDExdoxWgeKrSEf5hNhsQzOg7H899X1aYF9qOCGf1d RGqpMyYIa7ZqQB754Q9IgXziygdWepYtkQSPa2uXbo8hdQCO31wq37Xp4QKqi/vN26hy hktB8+xMg+wSWqZbsVVSl8fFjfpJrSe2GV7X7T1sqh4su7cXyeimdkLF4rkMCjzhjyl9 +ozJjXijIs9IjV5xAPlt1mNPQrEpyDa56+7tkSDs5k/9jVe3cSdKjXJEdbzaJ+qjLfDA 3lX2w6Ai7ci2iB5tKwM3LRso91G+d27IC5N+bEKX8YP0ZFDUy+QJKsbLcD/rUHc2mmCS na8g== X-Received: by 10.194.110.100 with SMTP id hz4mr5056349wjb.6.1437570272991; Wed, 22 Jul 2015 06:04:32 -0700 (PDT) Received: from schleppi.home.com ([149.14.88.26]) by smtp.gmail.com with ESMTPSA id u7sm21992628wif.3.2015.07.22.06.04.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jul 2015 06:04:32 -0700 (PDT) From: Andreas Gruenbacher To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-api@vger.kernel.org, samba-technical@lists.samba.org, linux-security-module@vger.kernel.org, Andreas Gruenbacher Subject: [PATCH v5 24/39] richacl: Set the other permissions to the other mask Date: Wed, 22 Jul 2015 15:03:14 +0200 Message-Id: <1437570209-29832-25-git-send-email-andreas.gruenbacher@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1437570209-29832-1-git-send-email-andreas.gruenbacher@gmail.com> References: <1437570209-29832-1-git-send-email-andreas.gruenbacher@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andreas Gruenbacher Change the acl so that everyone@ is granted the permissions set in the other mask. Signed-off-by: Andreas Gruenbacher --- fs/richacl_compat.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/fs/richacl_compat.c b/fs/richacl_compat.c index db33b63..438859c 100644 --- a/fs/richacl_compat.c +++ b/fs/richacl_compat.c @@ -441,3 +441,36 @@ richacl_set_owner_permissions(struct richacl_alloc *alloc) } return 0; } + +/** + * richacl_set_other_permissions - set the other permissions to the other mask + * + * Change the acl so that everyone@ is granted the permissions set in the other + * mask. This leaves at most one efective everyone@ allow entry at the end of + * the acl. + */ +static int +richacl_set_other_permissions(struct richacl_alloc *alloc) +{ + struct richacl *acl = alloc->acl; + unsigned int x = RICHACE_POSIX_ALWAYS_ALLOWED; + unsigned int other_mask = acl->a_other_mask & ~x; + struct richace *ace = acl->a_entries + acl->a_count - 1; + + if (!other_mask) + return 0; + + if (acl->a_count == 0 || + !richace_is_everyone(ace) || + richace_is_inherit_only(ace)) { + ace++; + if (richacl_insert_entry(alloc, &ace)) + return -1; + ace->e_type = RICHACE_ACCESS_ALLOWED_ACE_TYPE; + ace->e_flags = RICHACE_SPECIAL_WHO; + ace->e_mask = other_mask; + ace->e_id.special = RICHACE_EVERYONE_SPECIAL_ID; + } else + richace_change_mask(alloc, &ace, other_mask); + return 0; +}