From patchwork Fri Mar 27 16:50:01 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: 6110751 Return-Path: X-Original-To: patchwork-linux-nfs@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 577D69F39E for ; Fri, 27 Mar 2015 17:05:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7E86520251 for ; Fri, 27 Mar 2015 17:05:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B9C8203AD for ; Fri, 27 Mar 2015 17:05:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753862AbbC0Qvp (ORCPT ); Fri, 27 Mar 2015 12:51:45 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:36742 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753000AbbC0Qvn (ORCPT ); Fri, 27 Mar 2015 12:51:43 -0400 Received: by wgra20 with SMTP id a20so105268074wgr.3; Fri, 27 Mar 2015 09:51:41 -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:in-reply-to :references; bh=nstFCCbbThycoY2VJAQeeLe5Up14lMgr12pMz7WPy18=; b=yJlgdOXbsNog4NvO+XOrk1CsAh82aBnoEU/vqkK/6KVR2fFH0bkgh4I8d+MiYenb6f yJZ5QwAOBe1msxUfanKyX5HAJxXa+sHCGBMoQam2OE7GyHDVSReb2naCPTr1gciArSIh Gp10KsK+lRWY5zFeQef0vkspbyr65urgbkdDta78PvYpr/NzZ/12tY7F103y5R9XfyCU /WCN+ge6p+896HieLsKage1Y5QBDtVJK9kSr06mpwp/76OaYWPQEcMBaXy/iarhJA6zi RfqRgQyAa1ElLm+r9yBQiUQj1PCRp9LnVI1OK/SwySwIxTaPxxY7VkKoeFgT4lFfbmi+ KDSQ== X-Received: by 10.180.74.47 with SMTP id q15mr56936369wiv.49.1427475101370; Fri, 27 Mar 2015 09:51:41 -0700 (PDT) Received: from nuc.home.com (80-110-94-70.cgn.dynamic.surfer.at. [80.110.94.70]) by mx.google.com with ESMTPSA id j7sm3592306wix.4.2015.03.27.09.51.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2015 09:51:40 -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 Subject: [RFC 03/39] vfs: Shrink struct posix_acl Date: Fri, 27 Mar 2015 17:50:01 +0100 Message-Id: X-Mailer: git-send-email 2.1.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 There is a hole in struct posix_acl because its struct rcu_head member is too large; at least on on 64-bit architectures, the hole cannot be closed by changing the definition of struct posix_acl. So instead, remove the struct rcu_head member from struct posix_acl, make sure that acls are always big enough to fit a struct rcu_head, and cast to struct rcu_head * when disposing of an acl. Signed-off-by: Andreas Gruenbacher --- fs/posix_acl.c | 5 +++-- include/linux/posix_acl.h | 7 ++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 3a48bb7..efe983e 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c @@ -140,8 +140,9 @@ EXPORT_SYMBOL(posix_acl_init); struct posix_acl * posix_acl_alloc(int count, gfp_t flags) { - const size_t size = sizeof(struct posix_acl) + - count * sizeof(struct posix_acl_entry); + const size_t size = max(sizeof(struct rcu_head), + sizeof(struct posix_acl) + + count * sizeof(struct posix_acl_entry)); struct posix_acl *acl = kmalloc(size, flags); if (acl) posix_acl_init(acl, count); diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h index 3e96a6a..66cf477 100644 --- a/include/linux/posix_acl.h +++ b/include/linux/posix_acl.h @@ -43,10 +43,7 @@ struct posix_acl_entry { }; struct posix_acl { - union { - atomic_t a_refcount; - struct rcu_head a_rcu; - }; + atomic_t a_refcount; unsigned int a_count; struct posix_acl_entry a_entries[0]; }; @@ -73,7 +70,7 @@ static inline void posix_acl_release(struct posix_acl *acl) { if (acl && atomic_dec_and_test(&acl->a_refcount)) - kfree_rcu(acl, a_rcu); + __kfree_rcu((struct rcu_head *)acl, 0); }