Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3081549rwl; Tue, 27 Dec 2022 04:11:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXsip3+ew4YTbq2FEpgoxmIfBf1CUTaxlEA3DEeTR4S5ebB7uzFBvNqetZj8xXNX0sQtDmha X-Received: by 2002:a05:6a00:1d28:b0:577:6525:fc98 with SMTP id a40-20020a056a001d2800b005776525fc98mr25187634pfx.3.1672143065705; Tue, 27 Dec 2022 04:11:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672143065; cv=none; d=google.com; s=arc-20160816; b=syQlCYg0ABLaBNLW8a0EnZ8Aqih52v8GP/SPGKW9Y4VWX7WkKRb/c/81vYs//fo0QG 3L6jTiTktQwqh+h23oIAqeIjz4M7MPEdhfI/i6fCEWi1xGoxPvGJMGpAAbvmu89hWR1Y AyNBQ4/+fYyI6zhVtrN55AHWxuGH/KGneoeMRZWpDt5Xaf2fwkNTADyUtJ6nyXvzYhzS n/Y82Fn1XqfEyYFxkOYd7CHEmnP++TtW8wSTf7Hk5ricfyrj1qHO94qn4oY480mZjQeO K9dfTFYIehmgF866HIEvvcHQh0xAGwmDN8eCC9tHxwq1WwRtWD9tt8oDSqEiN78dQY7F iAow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=G9KGHKGvEmHY8m6mMHbHyYBd5mnPoViFa4gD7Us+W8E=; b=E446kxT/pCp/jkgqGC6S24tO2yvfJObNQ4JOkSumzfEd37HU9dl92xYTg+99djH2xf J//ydA3nCc8Dk7UWJ49oQX3RQeVVKarZTcizyUwBzBcwbCx8MgK5ZVNRpcWpvY2ulAOb AEg09G1eDffJdXO5MvKdUn6hHpcC446IJnL7ll2sdhcC2leu8GJusRkFSNyWk/WUwG5w /iO72BDFuJz6Fva4kqK+PksdtHSKAhr6ht5gktohTffyc1PktXf/ZPHN4a3gro23SGD8 9H0OttBKgZ0e0enPDjonnJw/sl6hucBWyULbjtWAPDhn7ZI6b+hejtZn0RJTFwzdS/Gl /upw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZjzsFz30; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d16-20020aa78e50000000b0053e0d9dfee5si13183746pfr.217.2022.12.27.04.10.57; Tue, 27 Dec 2022 04:11:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZjzsFz30; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232103AbiL0L7a (ORCPT + 66 others); Tue, 27 Dec 2022 06:59:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231967AbiL0L64 (ORCPT ); Tue, 27 Dec 2022 06:58:56 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB22DAE5A; Tue, 27 Dec 2022 03:58:55 -0800 (PST) Date: Tue, 27 Dec 2022 11:58:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1672142334; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G9KGHKGvEmHY8m6mMHbHyYBd5mnPoViFa4gD7Us+W8E=; b=ZjzsFz30JcHNNKitODN5AzpHyFp1DhFvc08uWV/qUacYyMhxX0fknUB3nKSdZbUMQ9tHnX iPI0f7nhlXbXmDQ82laEvgvPX/v8wqvCza6nP4gdJ5HjA066oVzJ9Zl055rvz08CLN9WvV QkgzDlduiT//fmEcC/mpQKwAX+HIQiJxt2Gdf6CrvcF08kHt07EMSwWHe/C71xZEK1VOPn qOCKGc9j3YA4jRyqfo+H829XHJq8mTFxhofdJR1bcUgcHYJ2fInIbS7c+fIi5A5jXoUkKC rhrq7NbwvBS2qIztydIHMf6QSMVkX2nnSOAx5WGZMo08Iw5/wQV99yLDLV4b2A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1672142334; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G9KGHKGvEmHY8m6mMHbHyYBd5mnPoViFa4gD7Us+W8E=; b=bmtwC+3Li5Q08No3N7rc54fF5SO6AJli3YYN8Aeuym7b+dHnrVq5FL71xaqjUKzT1ejJKP +mdaDqZiH1KiW6Dw== From: "tip-bot2 for Mathieu Desnoyers" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/urgent] futex: Fix futex_waitv() hrtimer debug object leak on kcalloc error Cc: Mathieu Desnoyers , "Peter Zijlstra (Intel)" , Davidlohr Bueso , stable@vger.kernel.org, stable@vger.kernel.org, #@tip-bot2.tec.linutronix.de, v5.16+@tip-bot2.tec.linutronix.de, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221214222008.200393-1-mathieu.desnoyers@efficios.com> References: <20221214222008.200393-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Message-ID: <167214233380.4906.7703534432069912531.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the locking/urgent branch of tip: Commit-ID: 94cd8fa09f5f1ebdd4e90964b08b7f2cc4b36c43 Gitweb: https://git.kernel.org/tip/94cd8fa09f5f1ebdd4e90964b08b7f2cc4b36c43 Author: Mathieu Desnoyers AuthorDate: Wed, 14 Dec 2022 17:20:08 -05:00 Committer: Peter Zijlstra CommitterDate: Tue, 27 Dec 2022 12:52:02 +01:00 futex: Fix futex_waitv() hrtimer debug object leak on kcalloc error In a scenario where kcalloc() fails to allocate memory, the futex_waitv system call immediately returns -ENOMEM without invoking destroy_hrtimer_on_stack(). When CONFIG_DEBUG_OBJECTS_TIMERS=y, this results in leaking a timer debug object. Fixes: bf69bad38cf6 ("futex: Implement sys_futex_waitv()") Signed-off-by: Mathieu Desnoyers Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Davidlohr Bueso Cc: stable@vger.kernel.org Cc: stable@vger.kernel.org # v5.16+ Link: https://lore.kernel.org/r/20221214222008.200393-1-mathieu.desnoyers@efficios.com --- kernel/futex/syscalls.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c index 086a22d..a807407 100644 --- a/kernel/futex/syscalls.c +++ b/kernel/futex/syscalls.c @@ -286,19 +286,22 @@ SYSCALL_DEFINE5(futex_waitv, struct futex_waitv __user *, waiters, } futexv = kcalloc(nr_futexes, sizeof(*futexv), GFP_KERNEL); - if (!futexv) - return -ENOMEM; + if (!futexv) { + ret = -ENOMEM; + goto destroy_timer; + } ret = futex_parse_waitv(futexv, waiters, nr_futexes); if (!ret) ret = futex_wait_multiple(futexv, nr_futexes, timeout ? &to : NULL); + kfree(futexv); + +destroy_timer: if (timeout) { hrtimer_cancel(&to.timer); destroy_hrtimer_on_stack(&to.timer); } - - kfree(futexv); return ret; }