From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751193AbdAOPAY (ORCPT ); Sun, 15 Jan 2017 10:00:24 -0500 Received: from mout.web.de ([212.227.15.4]:63447 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751085AbdAOPAW (ORCPT ); Sun, 15 Jan 2017 10:00:22 -0500 Subject: [PATCH 03/46] selinux: Improve size determinations in four functions To: linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Eric Paris , James Morris , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Sun, 15 Jan 2017 16:00:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:V4xHEGkYKIgNk8rOwhMCSLE49kOUJiuOs2W4o1asB4oJ5plTh1t cDumKiG1tE+xQquX1oMKFkD7WWDYnaa5WryMB+0Geafkgl0vLlbcMrMKSfNHKBtfaL9NU84 tMTPf0ZcZRWDMLIjZKaLJdYole9CnutuBQMLtcCHS2U4JrS3xtReaYx9HCaC/nBhO/qYLJ3 cV/3RGakw12zGYTKU0qvw== X-UI-Out-Filterresults: notjunk:1;V01:K0:YFdXFsNjqLQ=:fEAuhZdxAio7T0b58xAvJs AtmYHyKHllGfhxsGgnlxbJJtCZW813o7wuRo2RjY4lw/E9+qn8xSknZp4/57gYQ/30lxJWCAm GEyPkblEzfp4kmo4Khiq7eQURtfwfG9laDs4JUFfW2RsnUB13O3pTiWT7tPhsfSIPfsv9YhRJ n1ocy3cQ8EKI1gRu7dIdsguauHhpSngTAcgPZfW4iczntH8CpcJCd//Bfn3UphCn8u4V2vmJn AVaJhIDvRpoS0DXQOS36xd58lGdF6jcuA0BbzdL2iWWfhwTIFFSmGyC6HSRwM2m+mOPkKjkHf 0PD6Vc4NlVZs+2BSkLtA2DIafAy6GXmvqNaJFRuA7A47rBY0gWtPfBtCQuKnjxhhjWSDgfRtU YYe6U16BkllV7zxVs6QVimOIrgyMdaNu2pzMq/Vs9W6F5Wphuazm1kzEqPhYK0/JAPw9u6BHC j5YozNK5iiS3MX7LNCLNyINTKnBO2AknspBVPr7oP2GfmfFOxFIx2IEUNDj+8Qb0SRFNMxHiR OO9uECzmJuOQ0eKgT8fTBu1Il8fazCKzmn3IzMejlBidjLqY39QiiN0m9/1jcMFbIJfccPEG7 Q94e+jQKLz4dnnO6PaL3O1Y6Lxeo++0sZwpm6PXr3R+5r2kwIyNviE26YZ+98lymuQMvskh2z pqxWUuZS1iuRY7RuPnSVzAcYxs3VI0Kw+bWqMQuJVG0SCCcztxLhrawzhwXyKrzlZn5Mb3fG1 KlWgaiFO6MAniKP/ZbtVxEAPK3HKjPCkDJVADL6+2RpLimy25fFpM6nq1vioYM8RaiFq5L2xw 3OvgaoK Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Sat, 14 Jan 2017 11:22:12 +0100 Replace the specification of data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer. Signed-off-by: Markus Elfring --- security/selinux/ss/conditional.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c index 4a3bf29f7565..771c96afe1d5 100644 --- a/security/selinux/ss/conditional.c +++ b/security/selinux/ss/conditional.c @@ -227,7 +227,7 @@ int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp) u32 len; int rc; - booldatum = kzalloc(sizeof(struct cond_bool_datum), GFP_KERNEL); + booldatum = kzalloc(sizeof(*booldatum), GFP_KERNEL); if (!booldatum) return -ENOMEM; @@ -332,7 +332,7 @@ static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum goto err; } - list = kzalloc(sizeof(struct cond_av_list), GFP_KERNEL); + list = kzalloc(sizeof(*list), GFP_KERNEL); if (!list) { rc = -ENOMEM; goto err; @@ -421,7 +421,7 @@ static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp) goto err; rc = -ENOMEM; - expr = kzalloc(sizeof(struct cond_expr), GFP_KERNEL); + expr = kzalloc(sizeof(*expr), GFP_KERNEL); if (!expr) goto err; @@ -472,7 +472,7 @@ int cond_read_list(struct policydb *p, void *fp) for (i = 0; i < len; i++) { rc = -ENOMEM; - node = kzalloc(sizeof(struct cond_node), GFP_KERNEL); + node = kzalloc(sizeof(*node), GFP_KERNEL); if (!node) goto err; -- 2.11.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: SF Markus Elfring Date: Sun, 15 Jan 2017 15:00:04 +0000 Subject: [PATCH 03/46] selinux: Improve size determinations in four functions Message-Id: List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Eric Paris , James Morris , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts Cc: LKML , kernel-janitors@vger.kernel.org From: Markus Elfring Date: Sat, 14 Jan 2017 11:22:12 +0100 Replace the specification of data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer. Signed-off-by: Markus Elfring --- security/selinux/ss/conditional.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c index 4a3bf29f7565..771c96afe1d5 100644 --- a/security/selinux/ss/conditional.c +++ b/security/selinux/ss/conditional.c @@ -227,7 +227,7 @@ int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp) u32 len; int rc; - booldatum = kzalloc(sizeof(struct cond_bool_datum), GFP_KERNEL); + booldatum = kzalloc(sizeof(*booldatum), GFP_KERNEL); if (!booldatum) return -ENOMEM; @@ -332,7 +332,7 @@ static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum goto err; } - list = kzalloc(sizeof(struct cond_av_list), GFP_KERNEL); + list = kzalloc(sizeof(*list), GFP_KERNEL); if (!list) { rc = -ENOMEM; goto err; @@ -421,7 +421,7 @@ static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp) goto err; rc = -ENOMEM; - expr = kzalloc(sizeof(struct cond_expr), GFP_KERNEL); + expr = kzalloc(sizeof(*expr), GFP_KERNEL); if (!expr) goto err; @@ -472,7 +472,7 @@ int cond_read_list(struct policydb *p, void *fp) for (i = 0; i < len; i++) { rc = -ENOMEM; - node = kzalloc(sizeof(struct cond_node), GFP_KERNEL); + node = kzalloc(sizeof(*node), GFP_KERNEL); if (!node) goto err; -- 2.11.0