From patchwork Fri Oct 19 12:20:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1618231 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 D01D33FC1A for ; Fri, 19 Oct 2012 12:20:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757188Ab2JSMU6 (ORCPT ); Fri, 19 Oct 2012 08:20:58 -0400 Received: from mail-yh0-f46.google.com ([209.85.213.46]:60915 "EHLO mail-yh0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754045Ab2JSMU6 (ORCPT ); Fri, 19 Oct 2012 08:20:58 -0400 Received: by mail-yh0-f46.google.com with SMTP id m54so44174yhm.19 for ; Fri, 19 Oct 2012 05:20:57 -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=U7agsRZFSMm5gM2eJ0dNX2QjvPg66W0sJKYalCC8b5Y=; b=MFhQC2HoSIg0JCZ1rs+tYPQN2KKaF10ZYFHb5QqMwQ9BzLgEVfsnLw+taeF903uH/y HG4ZW+rEfO3QYVRrwD1z5I8t32bEMKDfRf8u3dDzzzPVEagDEj6PSpvF1hZwUcGPZHuU hWAavqoR3ALuA1wfHnRjVmgV+No7+YqeyLOrCFpXIWT/xVMd0DXlW0UL8DYxrtHrMWhn iY/ZBVuKI1Z8DjeX4uZw4zEU3ibcDhsR/56/gZe7uanyBkGKwMtdszKPtLWUdnjx3D2J M/pQiqBzSimrEQTjAmDGfyopaAhO+G/FiCgyaM0gmXvSLFNrv1N2XnDM+P0lPkBy9pP8 C1LA== Received: by 10.236.117.206 with SMTP id j54mr858144yhh.109.1350649257500; Fri, 19 Oct 2012 05:20:57 -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.56 (version=SSLv3 cipher=OTHER); Fri, 19 Oct 2012 05:20:56 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org Subject: [PATCH v2 1/9] cifs: make cifs_copy_sid handle a source sid with variable size subauth arrays Date: Fri, 19 Oct 2012 08:20:42 -0400 Message-Id: <1350649250-5343-2-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: ALoCoQmb05IjCURWFwYFpE50OZy07WFwrd3nWxpwIFNtbKzENsE2Kp+JGoq+XpC0cRjQE77jYsAn Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org ...and lift the restriction in id_to_sid upcall that the size must be at least as big as a full cifs_sid. Signed-off-by: Jeff Layton --- fs/cifs/cifsacl.c | 10 ++++++++-- fs/cifs/cifsacl.h | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 5a312eb..141a944 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -277,8 +277,14 @@ compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid) static void cifs_copy_sid(struct cifs_sid *dst, const struct cifs_sid *src) { - memcpy(dst, src, sizeof(*dst)); + int i; + + dst->revision = src->revision; dst->num_subauth = min_t(u8, src->num_subauth, NUM_SUBAUTHS); + for (i = 0; i < NUM_AUTHS; ++i) + dst->authority[i] = src->authority[i]; + for (i = 0; i < dst->num_subauth; ++i) + dst->sub_auth[i] = src->sub_auth[i]; } static void @@ -427,7 +433,7 @@ id_to_sid(unsigned long cid, uint sidtype, struct cifs_sid *ssid) if (IS_ERR(sidkey)) { rc = -EINVAL; cFYI(1, "%s: Can't map and id to a SID", __func__); - } else if (sidkey->datalen < sizeof(struct cifs_sid)) { + } else if (sidkey->datalen < CIFS_SID_BASE_SIZE) { rc = -EIO; cFYI(1, "%s: Downcall contained malformed key " "(datalen=%hu)", __func__, sidkey->datalen); diff --git a/fs/cifs/cifsacl.h b/fs/cifs/cifsacl.h index 18c7521..7e52f19 100644 --- a/fs/cifs/cifsacl.h +++ b/fs/cifs/cifsacl.h @@ -64,6 +64,9 @@ struct cifs_sid { __le32 sub_auth[NUM_SUBAUTHS]; /* sub_auth[num_subauth] */ } __attribute__((packed)); +/* size of a struct cifs_sid, sans sub_auth array */ +#define CIFS_SID_BASE_SIZE (1 + 1 + NUM_AUTHS) + struct cifs_acl { __le16 revision; /* revision level */ __le16 size;