From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Howells Date: Tue, 19 Sep 2017 15:46:08 +0000 Subject: Re: [PATCH] KEYS: fix cred refcount leak in request_key_auth_new() Message-Id: <28352.1505835968@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit List-Id: References: <20170918183331.113261-1-ebiggers3@gmail.com> In-Reply-To: <20170918183331.113261-1-ebiggers3@gmail.com> To: linux-security-module@vger.kernel.org Eric Biggers wrote: > In request_key_auth_new(), if alloc_key() or key_instantiate_and_link() > were to fail, we would leak a reference to the 'struct cred'. Currently > this can only happen if alloc_key() fails to to allocate memory. But it > still should be fixed, as it is a more severe bug waiting to happen. It might be better to combine request_key_auth_destroy() and the error path that you're altering in request_key_auth_new() by pulling it into a separate function. David From mboxrd@z Thu Jan 1 00:00:00 1970 From: dhowells@redhat.com (David Howells) Date: Tue, 19 Sep 2017 16:46:08 +0100 Subject: [PATCH] KEYS: fix cred refcount leak in request_key_auth_new() In-Reply-To: <20170918183331.113261-1-ebiggers3@gmail.com> References: <20170918183331.113261-1-ebiggers3@gmail.com> Message-ID: <28352.1505835968@warthog.procyon.org.uk> To: linux-security-module@vger.kernel.org List-Id: linux-security-module.vger.kernel.org Eric Biggers wrote: > In request_key_auth_new(), if alloc_key() or key_instantiate_and_link() > were to fail, we would leak a reference to the 'struct cred'. Currently > this can only happen if alloc_key() fails to to allocate memory. But it > still should be fixed, as it is a more severe bug waiting to happen. It might be better to combine request_key_auth_destroy() and the error path that you're altering in request_key_auth_new() by pulling it into a separate function. David -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751794AbdISPqM (ORCPT ); Tue, 19 Sep 2017 11:46:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60722 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751672AbdISPqK (ORCPT ); Tue, 19 Sep 2017 11:46:10 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6959F68D3 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dhowells@redhat.com Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20170918183331.113261-1-ebiggers3@gmail.com> References: <20170918183331.113261-1-ebiggers3@gmail.com> To: Eric Biggers Cc: dhowells@redhat.com, keyrings@vger.kernel.org, Michael Halcrow , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Biggers Subject: Re: [PATCH] KEYS: fix cred refcount leak in request_key_auth_new() MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28351.1505835968.1@warthog.procyon.org.uk> Date: Tue, 19 Sep 2017 16:46:08 +0100 Message-ID: <28352.1505835968@warthog.procyon.org.uk> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 19 Sep 2017 15:46:10 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Eric Biggers wrote: > In request_key_auth_new(), if alloc_key() or key_instantiate_and_link() > were to fail, we would leak a reference to the 'struct cred'. Currently > this can only happen if alloc_key() fails to to allocate memory. But it > still should be fixed, as it is a more severe bug waiting to happen. It might be better to combine request_key_auth_destroy() and the error path that you're altering in request_key_auth_new() by pulling it into a separate function. David