From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751201AbdAOO5Y (ORCPT ); Sun, 15 Jan 2017 09:57:24 -0500 Received: from mout.web.de ([217.72.192.78]:58814 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751036AbdAOO5W (ORCPT ); Sun, 15 Jan 2017 09:57:22 -0500 Subject: [PATCH 01/46] selinux: Use kmalloc_array() in cond_init_bool_indexes() 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: <68a423a9-2f89-55f9-fb4c-97dd4df4bb1d@users.sourceforge.net> Date: Sun, 15 Jan 2017 15:56:59 +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:dFEd79xP/k1dEVHwjTlt/8ZIUA2fnTrBzLnyCbHbcVWpEFHeDbg 9XX2Ly1h9nJ67x5ck0EzrEVD9pMicSgrrWnc5RwV5A1UrCRMrV0wrl/sjT6F9ARMOtDTnVf pnZ6C6iVEylWfdgFRpxXh3foJpmcOEsbseW9nYwN3a1gnPiUn2A2PxXumMqOnW7ebMOHCs5 j+EVFIBmlDODGO2Glfq+Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:jxRp9QB41O4=:sxSLhBVDlb2cMLVbL0/RQe QKWCoMzIlqtgK0ydu8q4iOR9xPE3tbbue2gKR9ukmHnt1TtCgv+OHp40DKNZl81iMBoxotKmz knySb56ddj5w/0Veb4NjKLnFeqjBU+4p7bW9ih2ZZTmtN4Xu3lvIpckxrR3tzkjMC9Ww9AslM exA9rKu1bGYfZXXvcf4b0DDyhweVgHO6E4HayzL3FFFgri/1FR/FsZUxiIip9+y1VH/e4g48r OFhKpwaKaymnGmcJks5Fm/YH73hjH/0Y1Bbr0oDwCtGXVtA5G1X4QbS5uhPcOp6GRUuNNwHTz dgcvnJ6QmLK8yesj/bsHOEYd4Qwux4MPxrVHzUaqMgTBSkjN9A8Xk4KosHsS05t6uR8KPFKQc Csm/drscLLMxDy/i03n0q3uHaBKJ2cUPFVB5mVSUON0hzSvjdLgkxP/bFysuGv54Qng3kg9Rk nHqdgdvJz//3GoQZhltL+rT+J03S8898mPIuN0p/q+bAgnw1sP8a+oQubWJnZ+JH0ydAE+9LH mTFgG5KsZWaEW9+qwD6PyEt23fIBzO+Y+wg7ajRvPkqKwLk4iWvR7qjo15Bqm5tPw1BSDfyG7 8cC33k10cXonurrStFs+WvELG17QP+pJwBvBz9izsw688qCSF4SNGABe2KeItXoTaMEwRu0cw 5HaBoDFIpvEFC/ftDlJzJ6dB8noKGWd0DXERz0GdCHlD4msgQeYjw7W4Auhg63EklVUC0g+4b 62+jf/oAq+ZgsU4wzd2EMWUPqkQBu3gjXh6pC9b7PK3pkdsAMliuW9X5CahwihRHtRhNRdClq ZiWoLFr 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 10:48:28 +0100 * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. * Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- security/selinux/ss/conditional.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c index 34afeadd9e73..fcfab2635c11 100644 --- a/security/selinux/ss/conditional.c +++ b/security/selinux/ss/conditional.c @@ -176,8 +176,9 @@ void cond_policydb_destroy(struct policydb *p) int cond_init_bool_indexes(struct policydb *p) { kfree(p->bool_val_to_struct); - p->bool_val_to_struct = - kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum *), GFP_KERNEL); + p->bool_val_to_struct = kmalloc_array(p->p_bools.nprim, + sizeof(*p->bool_val_to_struct), + GFP_KERNEL); if (!p->bool_val_to_struct) return -ENOMEM; return 0; -- 2.11.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: SF Markus Elfring Date: Sun, 15 Jan 2017 14:56:59 +0000 Subject: [PATCH 01/46] selinux: Use kmalloc_array() in cond_init_bool_indexes() Message-Id: <68a423a9-2f89-55f9-fb4c-97dd4df4bb1d@users.sourceforge.net> 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 10:48:28 +0100 * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. * Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- security/selinux/ss/conditional.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c index 34afeadd9e73..fcfab2635c11 100644 --- a/security/selinux/ss/conditional.c +++ b/security/selinux/ss/conditional.c @@ -176,8 +176,9 @@ void cond_policydb_destroy(struct policydb *p) int cond_init_bool_indexes(struct policydb *p) { kfree(p->bool_val_to_struct); - p->bool_val_to_struct - kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum *), GFP_KERNEL); + p->bool_val_to_struct = kmalloc_array(p->p_bools.nprim, + sizeof(*p->bool_val_to_struct), + GFP_KERNEL); if (!p->bool_val_to_struct) return -ENOMEM; return 0; -- 2.11.0