From patchwork Wed Jun 24 21:57:17 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: 6670291 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B1FF7C05AC for ; Wed, 24 Jun 2015 21:58:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D8FA820569 for ; Wed, 24 Jun 2015 21:58:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCC8C20547 for ; Wed, 24 Jun 2015 21:58:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752774AbbFXV6s (ORCPT ); Wed, 24 Jun 2015 17:58:48 -0400 Received: from mail-wg0-f51.google.com ([74.125.82.51]:34314 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751815AbbFXV6N (ORCPT ); Wed, 24 Jun 2015 17:58:13 -0400 Received: by wgqq4 with SMTP id q4so47258374wgq.1; Wed, 24 Jun 2015 14:58:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=eWPzEVcyidEipMTaRbk+XAUzFuDtVAq7qNCldSwUJdI=; b=LbOt4E7HNLxxQE0/t0sHIDgq5gWCEN3cwSAdpad6fWtpKgHb52zNsx/WiCzotGPb5p JwIqJi8tN8tFB1SAy0rkvmDzkKvDFJ7QBP2Lj5dk2AAQKY5pghVldu9+BvhHDqPIHj1r x/1tVBdrrQbV9V+oBeaLiTsD/b1BFOQLymyTyjmrmTqrNChJQGZwSrwu0aQ4Q5IaWBXK +XgdAaY6u09/6LgtVdcagJNk4SBUPCJJXV+86H5y0Xy9shaq5QCU9CYJe65ahWPplabe ELofMDkqL7wuzm+TeVkId36HN1N9c727jj8cmdWhO4Cno356KK/ziEc1ZeVXjQKEbF6S gPvA== X-Received: by 10.194.222.137 with SMTP id qm9mr75230377wjc.43.1435183090947; Wed, 24 Jun 2015 14:58:10 -0700 (PDT) Received: from nuc.home.com (80-110-112-232.cgn.dynamic.surfer.at. [80.110.112.232]) by mx.google.com with ESMTPSA id lu5sm42559880wjb.9.2015.06.24.14.58.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jun 2015 14:58:10 -0700 (PDT) From: Andreas Gruenbacher X-Google-Original-From: Andreas Gruenbacher To: linux-kernel@vger.kernel.org, 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 Subject: [RFC v4 28/31] nfsd: Keep list of acls to dispose of in compoundargs Date: Wed, 24 Jun 2015 23:57:17 +0200 Message-Id: <1435183040-22726-29-git-send-email-agruenba@redhat.com> X-Mailer: git-send-email 2.4.2 In-Reply-To: <1435183040-22726-1-git-send-email-agruenba@redhat.com> References: <1435183040-22726-1-git-send-email-agruenba@redhat.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SUSPICIOUS_RECIPS, 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 We will decode acls in requests into richacls. Even if unlikely, there can be more than one acl in a single request; those richacls need to be richacl_put() at the end of the request instead of kfree()d, so keep a list of acls in compoundargs for that. Signed-off-by: Andreas Gruenbacher --- fs/nfsd/nfs4xdr.c | 26 ++++++++++++++++++++++++++ fs/nfsd/xdr4.h | 6 ++++++ 2 files changed, 32 insertions(+) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index ba81da1..277d9d8 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "idmap.h" #include "acl.h" @@ -195,6 +196,24 @@ svcxdr_tmpalloc(struct nfsd4_compoundargs *argp, u32 len) return tb->buf; } +static struct richacl * +svcxdr_alloc_richacl(struct nfsd4_compoundargs *argp, u32 nace) +{ + struct svcxdr_richacl *acls; + + acls = kmalloc(sizeof(*acls), GFP_KERNEL); + if (!acls) + return NULL; + acls->acl = richacl_alloc(nace, GFP_KERNEL); + if (!acls->acl) { + kfree(acls); + return NULL; + } + acls->next = argp->acls; + argp->acls = acls; + return acls->acl; +} + /* * For xdr strings that need to be passed to other kernel api's * as null-terminated strings. @@ -4394,6 +4413,12 @@ int nfsd4_release_compoundargs(void *rq, __be32 *p, void *resp) args->to_free = tb->next; kfree(tb); } + while (args->acls) { + struct svcxdr_richacl *acls = args->acls; + args->acls = acls->next; + richacl_put(acls->acl); + kfree(acls); + } return 1; } @@ -4412,6 +4437,7 @@ nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p, struct nfsd4_comp args->pagelen = rqstp->rq_arg.page_len; args->tmpp = NULL; args->to_free = NULL; + args->acls = NULL; args->ops = args->iops; args->rqstp = rqstp; diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 2f8c092..db47af2 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -569,6 +569,11 @@ struct svcxdr_tmpbuf { char buf[]; }; +struct svcxdr_richacl { + struct svcxdr_richacl *next; + struct richacl *acl; +}; + struct nfsd4_compoundargs { /* scratch variables for XDR decode */ __be32 * p; @@ -578,6 +583,7 @@ struct nfsd4_compoundargs { __be32 tmp[8]; __be32 * tmpp; struct svcxdr_tmpbuf *to_free; + struct svcxdr_richacl *acls; struct svc_rqst *rqstp;