From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932662AbbJHLgb (ORCPT ); Thu, 8 Oct 2015 07:36:31 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:38266 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932551AbbJHLeo (ORCPT ); Thu, 8 Oct 2015 07:34:44 -0400 X-Sasl-enc: F9174MdgWlOn0uPi3QEW/eo+bpNGWOwqSMWbe0pphnm7 1444304083 From: Sergei Zviagintsev To: Greg Kroah-Hartman , Daniel Mack , David Herrmann , Djalal Harouni Cc: linux-kernel@vger.kernel.org, Sergei Zviagintsev Subject: [PATCH 41/44] kdbus: Fix memfd install algorithm Date: Thu, 8 Oct 2015 14:32:10 +0300 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If file descriptor allocation for memfd fails, we do not fill the corresponding position in `fds' array with -1. Later when we install memfds, fds[gaps->n_fds + i] will contain garbage which we pass then to fd_install(). Fix it by adding -1 to `fds' in case when we can't get free file descriptor for memfd. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/message.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c index f2176796390d..0653a085c104 100644 --- a/ipc/kdbus/message.c +++ b/ipc/kdbus/message.c @@ -181,6 +181,7 @@ int kdbus_gaps_install(struct kdbus_gaps *gaps, struct kdbus_pool_slice *slice, memfd = get_unused_fd_flags(O_CLOEXEC); if (memfd < 0) { incomplete_fds = true; + fds[n_fds++] = -1; /* memfds are initialized to -1, skip copying it */ continue; } -- 1.8.3.1