Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp553067lqp; Tue, 11 Jun 2024 12:03:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVhR5fbeOZ5FVP/232xsvwNeMS4G1i9yoSwG19TkvjqYM8oJ0NqVYGK/M9t5pJW/srU8tcz3Ye1IlJ82ucfHleYJh9Gc9/a/RxH+dAhvg== X-Google-Smtp-Source: AGHT+IHa2zXoo8+cKF9QH1A6BGk5qhAfVItWW9fuMIbxTFlvvR7SeV3YeoQ9wvJMAezNKxft/Q0X X-Received: by 2002:a05:6a00:848:b0:705:b9da:8152 with SMTP id d2e1a72fcca58-705b9da86admr900013b3a.29.1718132580845; Tue, 11 Jun 2024 12:03:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718132580; cv=pass; d=google.com; s=arc-20160816; b=tcmp/ggjhUgSmHRc/yo7ShPmjw97lreWjzpHgW+U0yFLdxktLMmNEMNQNPlWIXvmVH fY/gK8ejL62aNg7F0PUH5oeTe2UN5bhIudJuirdTO3EjtxVq1Lx3RK4WJ5M7yOty7uQO 9tkiegt813xQsWe8fANUMKB/n36QBll3W2H3buoO/ttOYoBKBeptfg3DTy30/jwFxGnJ f89DTBjcjwZJ3eDL7tQDJaK7QEdrcK5N87jD283LBtuLO7Po7X+G+bvmEpxLpKKmirVn uJb64Z9QSgly9J2G2iNprqSay7v3p3pqI2pKi0eWqWOvcJd1hMzkkJhYkHMHxZtbkEvF u4mA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=Ch6Ef/9+oouFYtrlPPGYQzl5zrYIyJBzWuJGDffk8Aw=; fh=fRHmbX4kiZkr1X+/3i7RbgVD14JT5XkZDhblGZlruTk=; b=fwoqeAlbisUPpoeS4iJ4zrwWhS9OJWyKYL8a8v8bDK9iA4J4/WcDwY6OVNwsn4puzT e8qxq2X63nJmNZ72G2wPFTyK6ZBQ0F6WcXGd6y5eTLipaBGJDOaBnFpZ7mMLuxx4KmPO GYq7ctGsQV11LT0h3g8GEsmpxoEjkykKztkx/QQw6Jkm1F7nhzVg0CPR8ugoK3lBzdms idNLOWfAZxfwnjNxHbtR9z3jouTLbkG1KRgYTsQDstI0d1DC0VBpaqwb2jgIClDvSHgK aFa4mIo5hKyWn+1qdjznoGpJtQHJ7DKEpap62eb6BAY0lAVTlNNklM2M/1L6RQlJVXwx OVKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=No3kRxxr; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-210471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210471-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-7042c42e3a4si5782867b3a.303.2024.06.11.12.03.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 12:03:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=No3kRxxr; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-210471-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210471-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id CDF14B244C9 for ; Tue, 11 Jun 2024 18:51:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A861770FF; Tue, 11 Jun 2024 18:51:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="No3kRxxr" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3C5774413 for ; Tue, 11 Jun 2024 18:51:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718131894; cv=none; b=E2rj34TzvoC8i8vqa/qJbN1T69cMkXk+1jnTgAeqPrHDQY50jT1evSroi0ypkALJCsbmASPDaf7NX3LDYRWc4VTKHbRzeTnUbCTHF3V6E7AKPSrIo6ndp+/XzIOMpcHJwfAypyiump0DspMeEWWhUJ1Kqry6UW/9ie35JegRiKU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718131894; c=relaxed/simple; bh=CRVb1cscuZGU+C1mehva/5GiW5SQN/xPGb0k2ueosro=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=qmDUY2nrUJbvpzN+NmnZqQXmJXWqWbhexsirb2Wa0rfMS3MVOzdoK2YBowD1WbkE6A5YuhV1c1UjtJOjo+ZR7UozQcKsoWMGSjJzFRG/ONqcRdA2h0VJOU/lQwW5ykyTYUVuv2g45DBuiWFTC9QgIcJ+pDcLhqcCnr+Av21I/F4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=No3kRxxr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0B23C2BD10; Tue, 11 Jun 2024 18:51:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1718131894; bh=CRVb1cscuZGU+C1mehva/5GiW5SQN/xPGb0k2ueosro=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=No3kRxxrNI0tTN0hPHgb/qxTHnxbq6INdnv4nz+JcBDk8PonK+GgqFx0YJ9UCff+3 FQD4vr6bFA6VYKMCNo5JXutRLplrBc31hjbITTAB6nXhlbhvdObeQP13xEIkU55cdj Nn6A5gISENMjTCb5fRXyIbii7stdAOiOpJhupUqY= Date: Tue, 11 Jun 2024 11:51:33 -0700 From: Andrew Morton To: Aleksandr Nogikh Cc: dvyukov@google.com, andreyknvl@gmail.com, arnd@arndb.de, elver@google.com, glider@google.com, syzkaller@googlegroups.com, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kcov: don't lose track of remote references during softirqs Message-Id: <20240611115133.fa80466e924ad34ed4ad73cb@linux-foundation.org> In-Reply-To: <20240611133229.527822-1-nogikh@google.com> References: <20240611133229.527822-1-nogikh@google.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 11 Jun 2024 15:32:29 +0200 Aleksandr Nogikh wrote: > In kcov_remote_start()/kcov_remote_stop(), we swap the previous KCOV > metadata of the current task into a per-CPU variable. However, the > kcov_mode_enabled(mode) check is not sufficient in the case of remote > KCOV coverage: current->kcov_mode always remains KCOV_MODE_DISABLED > for remote KCOV objects. > > If the original task that has invoked the KCOV_REMOTE_ENABLE ioctl > happens to get interrupted and kcov_remote_start() is called, it > ultimately leads to kcov_remote_stop() NOT restoring the original > KCOV reference. So when the task exits, all registered remote KCOV > handles remain active forever. > > Fix it by introducing a special kcov_mode that is assigned to the > task that owns a KCOV remote object. It makes kcov_mode_enabled() > return true and yet does not trigger coverage collection in > __sanitizer_cov_trace_pc() and write_comp_data(). What are the userspace visible effects of this bug? I *think* it's just an efficiency thing, but how significant? In other words, should we backport this fix?