From patchwork Sun Jan 15 15:00:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9517441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2BC3460571 for ; Sun, 15 Jan 2017 15:00:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1ED7828420 for ; Sun, 15 Jan 2017 15:00:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12A0B2842D; Sun, 15 Jan 2017 15:00:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB75D28420 for ; Sun, 15 Jan 2017 15:00:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751092AbdAOPAX (ORCPT ); Sun, 15 Jan 2017 10:00:23 -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 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MVtqS-1bvtJZ2zpw-00X7DY; Sun, 15 Jan 2017 16:00:10 +0100 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: 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: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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;