Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp35329pxu; Thu, 3 Dec 2020 18:35:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXIZvRM/vVxp6o07EZMUfxdDUEukeTmgAcJUC8MrL9iAs8n3fzpvVjRoV4SPex6Ch4c3h0 X-Received: by 2002:a17:906:d146:: with SMTP id br6mr5105739ejb.331.1607049314543; Thu, 03 Dec 2020 18:35:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607049314; cv=none; d=google.com; s=arc-20160816; b=TK3okLRDoHjkidVtwpzouwiWzd8JFBe3NQc8EanksknV+56tpP1mHHsvTEl/IZLQlr eunJPM4/oWgfMzbBzJP6UxVZfiGC1DxBhhy7VnBpl1+xbt0rVWB91WDvI1DaEDAtwhmO jzjWRTJba5rG6hw2S72j43DNuIGvvEI4/g7YkhSb613Y5AcgJPB84wNtMDWYhUOOsW73 ooD2kdVoixjN73QoARl6JuEI+FA06R1d3V7w7V0E0t4TmZ6P+xkbtJ/TiMWMw2jDaoKA Ru/3yhgCHkUhROBlOFmBiYIpG7bh2cfF0o7KQq3ELU5mbmCXMWSYY4YmX7NpSaOtT3kj noZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=799HwfENk8y05soNUsgKUZdfsq1t4k4wBTh65JJiSEA=; b=kBcmUsg5TxM7XPYwXyDxHVR4LkMf50FAQJ9dgdGp5ieogkghul/c4v1Mn1zeZSIDlR B5D3zxRPklbOCf4S8zKdjb5VIuPbujw0uihh3wGNcqxiKINcC0sB6zYtYlYOwuaJDOxb t2tiD+ZUHbm2c0I4L7o/IBtngqiP2D5fFoxTzwkJBN829SZs3V8qU9WiZQ/742bi+qce /8KH/QEha0L1fWw2aZdYK1L1L5p2NeuRa1HuVmb+vCEhQtpM6CHLy81UMDpW1iAcVrFK Hhu1gdr0l9jAiihZCBjfRzA+2vJRtCF1dD5JXmmVL9xeanyQlvYqGbSFyu+gDToJh/55 Ivkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ozlabs-ru.20150623.gappssmtp.com header.s=20150623 header.b="ftzJWQm/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si500430ejd.505.2020.12.03.18.34.51; Thu, 03 Dec 2020 18:35:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ozlabs-ru.20150623.gappssmtp.com header.s=20150623 header.b="ftzJWQm/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726080AbgLDCaw (ORCPT + 99 others); Thu, 3 Dec 2020 21:30:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725847AbgLDCaw (ORCPT ); Thu, 3 Dec 2020 21:30:52 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9F39C061A4F for ; Thu, 3 Dec 2020 18:30:11 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id o5so2602552pgm.10 for ; Thu, 03 Dec 2020 18:30:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ozlabs-ru.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=799HwfENk8y05soNUsgKUZdfsq1t4k4wBTh65JJiSEA=; b=ftzJWQm/j8jHeKBDnmArPbBNNHejuHEDOu3YwEq4vTCJ9/LSe8sr1q28Wft90kK2gp rtho3xfRbr/PztkloRpS8Rp+V7yW7nY9C2UqQW1I0IBrxCl7gJ4phnGvDofBt8hvWt89 ER+Un8KmxXu9N/FPjcTbPXjMHRDQ0peQLSG6ye9Rnvy0pPpIMt3d5tcax5ShsqJUSd9q cUkchBqNYjvbOA4ni+aKCbf09D36Dl27osonFDILmSdOAKT11UAZpW+nEaxwa90aDY7c vv0rDq85+uWwl+bGvHdVvBEUbTA6URRcJwu61vNeJ8SYFFIYs9sJoAgvBGZuJ7+KEInH 9zjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=799HwfENk8y05soNUsgKUZdfsq1t4k4wBTh65JJiSEA=; b=iyemndQlOk+VeZbl3pMoar8w6URnolbDTxYKElVyHrv50xVZs/zzCK+RtrOJiGMtSc yi4dvlFZbakV/yNuofCQMi7nyQoAPX0fPNrv7pPqanYI7BqKGay1m2Vc6dm02lTlcxen uvP5oKLhaEGc0i2AWAoBVixvKFswTCTJeeFUS7+evNV0sRuMW8ZZPzRaS4Qy2tyyW4pC xhLLLDky2WNobrLvcLDdXOocotpoIRr+QHo+u+gGy/GRY2W+Hkzm4wEzPANC+wU442M/ q639ckHFGO4PvTAqfwLjktfz+4dIh4SD06iNiyIA1i0PqWGiMPVlpc5FaVUWtHRGdDpi 57Ig== X-Gm-Message-State: AOAM530jRisozSp1ZZTcbZtLMwWyKuweZwsHhqeVDA/pkQ6oxgRa9uh6 pXT8nci5Zbx/6CDj7x6EKGKQvlWah+bw9g== X-Received: by 2002:a62:61c2:0:b029:197:f5ee:6ffa with SMTP id v185-20020a6261c20000b0290197f5ee6ffamr1730101pfb.18.1607049011041; Thu, 03 Dec 2020 18:30:11 -0800 (PST) Received: from [192.168.10.153] (124-171-134-245.dyn.iinet.net.au. [124.171.134.245]) by smtp.gmail.com with UTF8SMTPSA id g14sm2971248pfo.198.2020.12.03.18.30.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Dec 2020 18:30:10 -0800 (PST) Subject: Re: WARN_ON_ONCE To: Michael Ellerman , Dmitry Vyukov Cc: syzkaller , LKML References: <87f443cf-26c0-6302-edee-556045bca18a@ozlabs.ru> <87k0tyuztw.fsf@mpe.ellerman.id.au> From: Alexey Kardashevskiy Message-ID: <414bc088-9441-70c7-88e2-2c928b97db36@ozlabs.ru> Date: Fri, 4 Dec 2020 13:30:06 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0 MIME-Version: 1.0 In-Reply-To: <87k0tyuztw.fsf@mpe.ellerman.id.au> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/12/2020 12:25, Michael Ellerman wrote: > Dmitry Vyukov writes: >> On Thu, Dec 3, 2020 at 10:19 AM Dmitry Vyukov wrote: >>> On Thu, Dec 3, 2020 at 10:10 AM Alexey Kardashevskiy wrote: >>>> >>>> Hi! >>>> >>>> Syzkaller triggered WARN_ON_ONCE at >>>> >>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/tracepoint.c?h=v5.10-rc6#n266 >>>> >>>> >>>> === >>>> static int tracepoint_add_func(struct tracepoint *tp, >>>> struct tracepoint_func *func, int prio) >>>> { >>>> struct tracepoint_func *old, *tp_funcs; >>>> int ret; >>>> >>>> if (tp->regfunc && !static_key_enabled(&tp->key)) { >>>> ret = tp->regfunc(); >>>> if (ret < 0) >>>> return ret; >>>> } >>>> >>>> tp_funcs = rcu_dereference_protected(tp->funcs, >>>> lockdep_is_held(&tracepoints_mutex)); >>>> old = func_add(&tp_funcs, func, prio); >>>> if (IS_ERR(old)) { >>>> WARN_ON_ONCE(PTR_ERR(old) != -ENOMEM); >>>> return PTR_ERR(old); >>>> } >>>> >>>> === >>>> >>>> What is the common approach here? Syzkaller reacts on this as if it was >>>> a bug but WARN_ON_ONCE here seems intentional. Do we still push for >>>> removing such warnings? > > AFAICS it is a bug if that fires. > > See the commit that added it: > d66a270be331 ("tracepoint: Do not warn on ENOMEM") > > Which says: > Tracepoint should only warn when a kernel API user does not respect the > required preconditions (e.g. same tracepoint enabled twice, This says that the userspace can trigger the warning if it does not use the API right. > or called > to remove a tracepoint that does not exist). > > Silence warning in out-of-memory conditions, given that the error is > returned to the caller. > > > So if you're seeing it then you've someone caused it to return something > other than ENOMEM, and that is a bug. This is an userspace bug which registers the same thing twice, the kernel returns a correct error. The question is should it warn by WARN_ON or pr_err(). The comment in bug.h suggests pr_err() is the right way, is not it? -- Alexey