From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Morris Date: Fri, 27 Oct 2017 08:06:01 +0000 Subject: Re: [PATCH] keyctl: use keyctl_read_alloc() in dump_key_tree_aux() Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit List-Id: References: <20171026210008.106248-1-ebiggers3@gmail.com> In-Reply-To: <20171026210008.106248-1-ebiggers3@gmail.com> To: keyrings@vger.kernel.org On Thu, 26 Oct 2017, Eric Biggers wrote: > From: Eric Biggers > > dump_key_tree_aux() (part of 'keyctl show') was racy: it allocated a > buffer for the keyring contents, then read the keyring. But it's > possible that keys are added to the keyring concurrently. This is > problematic for two reasons. First, when keyctl_read() is passed a > buffer that is too small, it is unspecified whether it is filled or not. > Second, even if the buffer is filled, some keys (not necessarily even > the newest ones) would be omitted from the listing. > > Switch to keyctl_read_alloc() which handles the "buffer too small" case > correctly by retrying the read. > > Signed-off-by: Eric Biggers Reviewed-by: James Morris -- James Morris