Received: by 10.223.185.116 with SMTP id b49csp1112094wrg; Fri, 23 Feb 2018 12:08:17 -0800 (PST) X-Google-Smtp-Source: AH8x225Im8vQaeOAVBQuxQxv+F9my9aX6Wy6aL5mng9sZ7X7s8ePmyuUWXfVAZT9g4QK0Y50nRVg X-Received: by 2002:a17:902:5481:: with SMTP id e1-v6mr2752550pli.300.1519416497222; Fri, 23 Feb 2018 12:08:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519416497; cv=none; d=google.com; s=arc-20160816; b=eJnWAOmyF6r3MDoGRn5fbDlkrTW6GB8GtAy3epTMhT9nK7ft1nQMSYnxcs3DH7GBjM EcFby02tWZrojGBOTF0V2LNByT0RyyAC1Fqd23r+hZND2Z+/un0cNAonOdCLxLVIfeWX +YEQ9q8WXJQkFQ3iQaapE3CAwFDYU2QhoBco/a+icn/mWeY7W1/Ed+3hVVq1JRwuzJzP rmEut2V9MNBaqppXJSLh5vvo6BK5Z0gNzJ2Ki8+8ndhU360G2v1dBFk6vdEV8+9ng+lF oj0P8AD2Hfw3apM3czoha7Y9xBapJ7Vz+79cSFSX2uGgN0ci1CnT4DU7cnyFRyGDKqX5 /Wrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=rZIpmzHS9UFaBUdh/d9FjytWBoFlWAPK2PSiZR20kTU=; b=P4CXuuGCzv/6RyG88smeqS/DGPvf0Rh940nviSsD/w8xFxA5WmOtWuk/TXo/bamhT9 hzXTpmSYHCTvMDFrogywBtcHW0BzHLd5dbulK2/Rdp5lOYI7wZ4zdAqrQ3xJdZsswCwU /FOENZfx0jFN32WpQJW5FTYJ4BH3AnMb0DwpKFDwLrvmvuKrAH4CH8JyP+hru43qQ6X/ wEwxBaHpfAXY3QDyOjk8fO0Hn+/wBQ8Y4honVM1BbUCuIZqpAlAYzpkVv6vOkvjmCGWp JLCRMTMq8FxNMo5ffkRdtoZ0lxL7N9p3oL9WPQmBuo45u/9SmEbzZS4oSeHSgmNOcMdA w6/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h125si2307244pfc.133.2018.02.23.12.08.02; Fri, 23 Feb 2018 12:08:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933166AbeBWSm4 (ORCPT + 99 others); Fri, 23 Feb 2018 13:42:56 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:41944 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932515AbeBWSmv (ORCPT ); Fri, 23 Feb 2018 13:42:51 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 29AF41046; Fri, 23 Feb 2018 18:42:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Vyukov , Shankara Pailoor , syzbot , Andrew Morton , Linus Torvalds Subject: [PATCH 4.9 021/145] kcov: detect double association with a single task Date: Fri, 23 Feb 2018 19:25:27 +0100 Message-Id: <20180223170727.394863455@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dmitry Vyukov commit a77660d231f8b3d84fd23ed482e0964f7aa546d6 upstream. Currently KCOV_ENABLE does not check if the current task is already associated with another kcov descriptor. As the result it is possible to associate a single task with more than one kcov descriptor, which later leads to a memory leak of the old descriptor. This relation is really meant to be one-to-one (task has only one back link). Extend validation to detect such misuse. Link: http://lkml.kernel.org/r/20180122082520.15716-1-dvyukov@google.com Fixes: 5c9a8750a640 ("kernel: add kcov code coverage") Signed-off-by: Dmitry Vyukov Reported-by: Shankara Pailoor Cc: Dmitry Vyukov Cc: syzbot Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- kernel/kcov.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -220,9 +220,9 @@ static int kcov_ioctl_locked(struct kcov if (unused != 0 || kcov->mode == KCOV_MODE_DISABLED || kcov->area == NULL) return -EINVAL; - if (kcov->t != NULL) - return -EBUSY; t = current; + if (kcov->t != NULL || t->kcov != NULL) + return -EBUSY; /* Cache in task struct for performance. */ t->kcov_size = kcov->size; t->kcov_area = kcov->area;