From patchwork Sat Aug 13 20:38:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 9279377 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 63B9060780 for ; Sun, 14 Aug 2016 11:53:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54A3328A06 for ; Sun, 14 Aug 2016 11:53:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 497C528A57; Sun, 14 Aug 2016 11:53:52 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 DE9A228A06 for ; Sun, 14 Aug 2016 11:53:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932415AbcHNLxu (ORCPT ); Sun, 14 Aug 2016 07:53:50 -0400 Received: from nm5-vm0.bullet.mail.bf1.yahoo.com ([98.139.213.150]:55151 "EHLO nm5-vm0.bullet.mail.bf1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932787AbcHNLxs (ORCPT ); Sun, 14 Aug 2016 07:53:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1471120699; bh=olkN5o80lMuB59ckHXA1WeEVhOhsVdMmaoNN+g1RI4U=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From:Subject; b=Zr1ITMq0e3139vbpLJ+VpZ9ziW8/7pvbgWIcDdRYRisbC5t100N9V61Bdosr9q7n/EVQPZHPcCgBBbNkhOR/71ThVpO1AA9/sW9Gfce/qKbUrNug3wf3hqFqf4iNUz4kwHX5fsXYGIJxVAVS8rC/Wn6GQOv5TL/zd0yYXGZ0Lhr2ko64U3zrh8jQ7RgjInbp0Zl+AGa7kxEzhdsONzSrjLs2zoTR9cGYyqYjQgvp0RyDJtXVWiXozUdrvfts4DpD0FjMogStHjbDVIOizPUTW0IgZwiz0PuEosguvgnYefwzmdHoT75Qo0tkV0EIp/HM6bGJvQzmRL5/GEHwz2ysMQ== Received: from [98.139.170.179] by nm5.bullet.mail.bf1.yahoo.com with NNFMP; 13 Aug 2016 20:38:19 -0000 Received: from [68.142.230.76] by tm22.bullet.mail.bf1.yahoo.com with NNFMP; 13 Aug 2016 20:38:19 -0000 Received: from [127.0.0.1] by smtp233.mail.bf1.yahoo.com with NNFMP; 13 Aug 2016 20:38:19 -0000 X-Yahoo-Newman-Id: 34336.3682.bm@smtp233.mail.bf1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: tolR4lsVM1moN2Uk5bvpdRWaVcFfhYPhppFn_5aaUx7abbM KStxeT6s_vE_ksGs29xv7xUijnrrfT66_98AzrRQaIvcgQcfrI4MaosMdkM0 A3I7IXvhYqYbCbXZ9igDKlB_.AzbdAcnqA8PgSEHD0lfirk56a0.OLn10Ryx wcAHgEyyx2DsMvdnI5cKZ5BM9fWrrrihhDU7X8aS6k.b.TNA9XLyS1DdX1SQ OLXYZ9Zxbpf7CbTY1jYq_eG3YuQQgvdEZm.CAdX2UCEP7EiauduVkau1miAB lqG.JOo16RhS.pzWt941aqhLssyDqDr_XanHT8H.dYnTiupDBinRVOhRouV7 0.cxdyDdj7hLHSumcKV1WkOpnhcSuBeFo20DHBOFQMcdBlNNjKE7yRBHzmii PeOQG31VYPNVksX_NfJWR1aW.29ocoy0i2bodybKHlW1HtPcFkhlz5cFU5iu phDIaAVlNqkAePfI.0FfLBoJ7qsnJQ1Ny.r9gI27Ma77XuNXRbn3wOQx7gV6 mU0veOZKip6NrBqa00j0PLjXSRjrGWboXAY01vqQCQEvI4W4ON2SroUHhytJ iQbyI2lfayHCp X-Yahoo-SMTP: OIJXglSswBDfgLtXluJ6wiAYv6_cnw-- Subject: [PATCH 23/25] LSM: Correct allocation mode for sock blobs To: LSM , James Morris References: <801ef9a9-e594-387c-f285-8d90879ee2bf@schaufler-ca.com> Cc: John Johansen , Tetsuo Handa , Paul Moore , Stephen Smalley From: Casey Schaufler Message-ID: Date: Sat, 13 Aug 2016 13:38:16 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <801ef9a9-e594-387c-f285-8d90879ee2bf@schaufler-ca.com> Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Subject: [PATCH 23/25] LSM: Correct allocation mode for sock blobs Use the passed gfp mode for allocating socket blobs. Signed-off-by: Casey Schaufler --- security/security.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/security/security.c b/security/security.c index 9eade94..e194679 100644 --- a/security/security.c +++ b/security/security.c @@ -373,12 +373,13 @@ int lsm_msg_msg_alloc(struct msg_msg *mp) /** * lsm_sock_alloc - allocate a composite sock blob * @sock: the sock that needs a blob + * @priority: allocation mode * * Allocate the sock blob for all the modules * * Returns 0, or -ENOMEM if memory can't be allocated. */ -int lsm_sock_alloc(struct sock *sock) +int lsm_sock_alloc(struct sock *sock, gfp_t priority) { #ifdef CONFIG_SECURITY_STACKING_DEBUG if (sock->sk_security) { @@ -389,7 +390,7 @@ int lsm_sock_alloc(struct sock *sock) if (blob_sizes.lbs_sock == 0) return 0; - sock->sk_security = kzalloc(blob_sizes.lbs_sock, GFP_KERNEL); + sock->sk_security = kzalloc(blob_sizes.lbs_sock, priority); if (sock->sk_security == NULL) return -ENOMEM; return 0; @@ -1822,7 +1823,7 @@ EXPORT_SYMBOL(security_socket_getpeersec_dgram); int security_sk_alloc(struct sock *sk, int family, gfp_t priority) { - int rc = lsm_sock_alloc(sk); + int rc = lsm_sock_alloc(sk, priority); if (rc) return rc;