From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754517AbbCaDPp (ORCPT ); Mon, 30 Mar 2015 23:15:45 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:52280 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754035AbbCaDPl (ORCPT ); Mon, 30 Mar 2015 23:15:41 -0400 X-Sasl-enc: POyCjrYn66tKxO6G4ztSuLSzABa0wCfWr2UfF+n6KWfJ 1427771740 Subject: [RFC PATCH 5 6/7] KEYS - use correct memory allocation flag in call_usermodehelper_keys() From: Ian Kent To: Kernel Mailing List Cc: David Howells , Oleg Nesterov , Trond Myklebust , "J. Bruce Fields" , Benjamin Coddington , Al Viro , Jeff Layton , "Eric W. Biederman" Date: Tue, 31 Mar 2015 11:15:27 +0800 Message-ID: <20150331031525.10464.67887.stgit@pluto.fritz.box> In-Reply-To: <20150331030340.10464.30272.stgit@pluto.fritz.box> References: <20150331030340.10464.30272.stgit@pluto.fritz.box> User-Agent: StGit/0.17-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ian Kent When call_usermodehelper_keys() is called it assumes it won't be called with the flag UMH_NO_WAIT. Currently that's always the case. Change this to check the flag and use the correct kernel memory allocation flag to guard against future changes. Signed-off-by: Ian Kent Cc: Benjamin Coddington Cc: Al Viro Cc: J. Bruce Fields Cc: David Howells Cc: Trond Myklebust Cc: Oleg Nesterov Cc: Eric W. Biederman Cc: Jeff Layton --- security/keys/request_key.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/security/keys/request_key.c b/security/keys/request_key.c index 486ef6f..e865f9f 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c @@ -76,8 +76,10 @@ static int call_usermodehelper_keys(char *path, char **argv, char **envp, struct key *session_keyring, int wait) { struct subprocess_info *info; + unsigned int gfp_mask = (wait & UMH_NO_WAIT) ? + GFP_ATOMIC : GFP_KERNEL; - info = call_usermodehelper_setup(path, argv, envp, GFP_KERNEL, + info = call_usermodehelper_setup(path, argv, envp, gfp_mask, umh_keys_init, umh_keys_cleanup, session_keyring); if (!info)