From patchwork Fri Oct 19 12:20:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1618251 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 3AA4F3FC1A for ; Fri, 19 Oct 2012 12:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757769Ab2JSMVB (ORCPT ); Fri, 19 Oct 2012 08:21:01 -0400 Received: from mail-ye0-f174.google.com ([209.85.213.174]:51130 "EHLO mail-ye0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757034Ab2JSMVA (ORCPT ); Fri, 19 Oct 2012 08:21:00 -0400 Received: by mail-ye0-f174.google.com with SMTP id m12so20411yen.19 for ; Fri, 19 Oct 2012 05:20:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=3kDR/VsdydfhcfjHxvl0CgDeKf0w2N24VlNuyCGpjko=; b=V/mgXv3Dj1r2Uc7Oa2+GWjUKz2p9Av7wc9zUwvR5oE/iGP0+c4k9qlpYhtEXe42DeF W59WbCtSrHbYXX17G0Jq3yRtvXaDwoIIRMpdfMk+X8fplZR0xTEkbgYpWeI92hBPsnsG 8naQU20ZhLq3R07JaIUUghIM5c6KQqU5S7WCnDLM2up3TZwy0i1VeZFVPy94nc6cRj+O JL+XuK+tBUdtBILbBc4+DxsgGZOU+zVJrNgfvAODkrl6kTFYBsLwrK5GSUQPPFtK1Kbc /FddYCE4qpe/fp4dSZB4G6LT2uE18mE52lcppVXXIchzudZz3qK5P80vjIhuMH9Erxfx YoaA== Received: by 10.236.83.103 with SMTP id p67mr852883yhe.78.1350649258632; Fri, 19 Oct 2012 05:20:58 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-110-129.nc.res.rr.com. [107.15.110.129]) by mx.google.com with ESMTPS id o9sm504022anp.14.2012.10.19.05.20.57 (version=SSLv3 cipher=OTHER); Fri, 19 Oct 2012 05:20:58 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org Subject: [PATCH v2 2/9] cifs: redefine NUM_SUBAUTH constant from 5 to 15 Date: Fri, 19 Oct 2012 08:20:43 -0400 Message-Id: <1350649250-5343-3-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1350649250-5343-1-git-send-email-jlayton@redhat.com> References: <1350649250-5343-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQm7dusRI6slLrssqvnVEoUltYmtEfaxqVgx8cTo7yxTk6zu+oGGzsJhTWuWNRfXM0Hw9Kcj Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org According to several places on the Internet and the samba winbind code, this is hard limited to 15 in windows, not 5. This does balloon out the allocation of each by 40 bytes, but I don't see any alternative. Also, rename it to SID_MAX_SUB_AUTHORITIES to match the alleged name of this constant in the windows header files Finally, rename SIDLEN to SID_STRING_MAX, fix the value to reflect the change to SID_MAX_SUB_AUTHORITIES and document how it was determined. Signed-off-by: Jeff Layton --- fs/cifs/cifsacl.c | 6 +++--- fs/cifs/cifsacl.h | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 141a944..dd8d3df 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -280,7 +280,7 @@ cifs_copy_sid(struct cifs_sid *dst, const struct cifs_sid *src) int i; dst->revision = src->revision; - dst->num_subauth = min_t(u8, src->num_subauth, NUM_SUBAUTHS); + dst->num_subauth = min_t(u8, src->num_subauth, SID_MAX_SUB_AUTHORITIES); for (i = 0; i < NUM_AUTHS; ++i) dst->authority[i] = src->authority[i]; for (i = 0; i < dst->num_subauth; ++i) @@ -383,7 +383,7 @@ id_to_sid(unsigned long cid, uint sidtype, struct cifs_sid *ssid) if (!npsidid) return -ENOMEM; - npsidid->sidstr = kmalloc(SIDLEN, GFP_KERNEL); + npsidid->sidstr = kmalloc(SID_STRING_MAX, GFP_KERNEL); if (!npsidid->sidstr) { kfree(npsidid); return -ENOMEM; @@ -500,7 +500,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid, if (!npsidid) return -ENOMEM; - npsidid->sidstr = kmalloc(SIDLEN, GFP_KERNEL); + npsidid->sidstr = kmalloc(SID_STRING_MAX, GFP_KERNEL); if (!npsidid->sidstr) { kfree(npsidid); return -ENOMEM; diff --git a/fs/cifs/cifsacl.h b/fs/cifs/cifsacl.h index 7e52f19..8b980cd 100644 --- a/fs/cifs/cifsacl.h +++ b/fs/cifs/cifsacl.h @@ -24,7 +24,7 @@ #define NUM_AUTHS 6 /* number of authority fields */ -#define NUM_SUBAUTHS 5 /* number of sub authority fields */ +#define SID_MAX_SUB_AUTHORITIES (15) /* max number of sub authority fields */ #define NUM_WK_SIDS 7 /* number of well known sids */ #define SIDNAMELENGTH 20 /* long enough for the ones we care about */ #define DEFSECDESCLEN 192 /* sec desc len contaiting a dacl with three aces */ @@ -41,7 +41,20 @@ #define SIDOWNER 1 #define SIDGROUP 2 -#define SIDLEN 150 /* S- 1 revision- 6 authorities- max 5 sub authorities */ + +/* + * Maximum size of a string representation of a SID: + * + * The fields are unsigned values in decimal. So: + * + * u8: max 3 bytes in decimal + * u32: max 10 bytes in decimal + * + * "S-" + 3 bytes for version field + 4 bytes for each authority field (3 bytes + * per number + 1 for '-') + 11 bytes for each subauthority field (10 bytes + * per number + 1 for '-') + NULL terminator. + */ +#define SID_STRING_MAX (195) #define SID_ID_MAPPED 0 #define SID_ID_PENDING 1 @@ -61,7 +74,7 @@ struct cifs_sid { __u8 revision; /* revision level */ __u8 num_subauth; __u8 authority[NUM_AUTHS]; - __le32 sub_auth[NUM_SUBAUTHS]; /* sub_auth[num_subauth] */ + __le32 sub_auth[SID_MAX_SUB_AUTHORITIES]; /* sub_auth[num_subauth] */ } __attribute__((packed)); /* size of a struct cifs_sid, sans sub_auth array */