Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4920717pxb; Sun, 7 Nov 2021 01:13:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVHtW5VTkm0zcodbh9N+qe+Z9XuL85BUcwEAevbuKnBMVBjqO85bRcKIrFod/m0piGkLKs X-Received: by 2002:a05:6602:15cc:: with SMTP id f12mr7953621iow.2.1636276386257; Sun, 07 Nov 2021 01:13:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636276386; cv=none; d=google.com; s=arc-20160816; b=Q7+uAO/ZTGnMeGP9UNiFTKDg+DVfzrQA+7DqaTE3tajvhp/JAYI7C6zpDYIX2rH8/H 9TMHbngDveIJHm0yFF8uSIq0dVbzdrRAz34ll+B8JoMn1ftewstp1G54VQL4Zdj1ofDr O5DgUIEvq6eh8JLOMMbovZrdy5IWOm7CWvnIM6jwr7+4JWHV3oqNOF4a56KLzwcLEqhV lfYsrGLXQVk+4XZtOz3YVBFOO5F0aw9GXHiXb6e3YM2VVpC7F78sfrzPCnQb0tbEj/x1 aFaYLyFe8ly9O9JfDcakjScTlEZC/PIYVOgs/B+ezz7q3XOD66g5pP2rrN9WiJTNP8gD Dd1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YTwExqzbaLzxuqvV/oJ9V6E17L9+TERCkYUMoZe/UPM=; b=MC/+E2Cobwyjb9tE01vdgpZErmhwb9g/cVYyEBy6mhbW6wJbGhbE8JBh71ORYLpkXp N/GSvhL0FE3XoRCm5syN1XhLTVWuoI2aInPW14AiauU7hQryY49eM1vKBOM4oiibJlMK qHVjggjQboMKiQUJn7dFoNTVwmTaW4CwvyWsPcNV4pwPdXpdgNXV+foQAsIeKdm8oiEh TFGnE0sCqbqtJOlyfMCQ/iaWLzmv+gb9/nuOd5kDNgJCuYrUD3OIeeuf7Xxd7XCe2Sns +NPYz5FYAzk6VK1Wf0/QxcuQ2yL3egSIi5Og5Dcbqk0qVV/q2d39Ztbxpo6JgloWOnTt eJug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ubique-spb-ru.20210112.gappssmtp.com header.s=20210112 header.b="2/tfJl2l"; 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 14si12753264iof.53.2021.11.07.01.12.53; Sun, 07 Nov 2021 01:13:06 -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=@ubique-spb-ru.20210112.gappssmtp.com header.s=20210112 header.b="2/tfJl2l"; 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 S235011AbhKFUK3 (ORCPT + 99 others); Sat, 6 Nov 2021 16:10:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234998AbhKFUK0 (ORCPT ); Sat, 6 Nov 2021 16:10:26 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB309C061714 for ; Sat, 6 Nov 2021 13:07:43 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id j128-20020a1c2386000000b003301a98dd62so12070372wmj.5 for ; Sat, 06 Nov 2021 13:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ubique-spb-ru.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=YTwExqzbaLzxuqvV/oJ9V6E17L9+TERCkYUMoZe/UPM=; b=2/tfJl2l+6tcayj/K3ATETjvDd2NNQorHEsPZjv/kiLQQ/PtrwOB1jckPRS8AtfFsj 6i71NrLYm72TuGZe+K0ANABFbD5uxpN4P2j2iF+6ERtYQCaZdENvOY7DNKmD5AupQAeP TVxA88yV0S8EDqls5mlwbc6PkueL4iTcZvbHe1tf7lvgkhtVf3ckdIE57ec5UFPhH9s8 ckypZQl2B9hkRPAUuyBXtpZvnZQ1k4TuFePlhSoVYr0FU1hkxG7g5DPGmCBPmuHVU7C6 2XYHK0KRk/pZ0Kgn3yDMeOI9oQp96gWf61+sKP2AjhuaxRnGjsccSQQlEDyr/SRtOW2N U/Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=YTwExqzbaLzxuqvV/oJ9V6E17L9+TERCkYUMoZe/UPM=; b=LWvBmxxd7GqdqXI4UOhHegIbGN3l8U2JVb+4kfNjlmN5XKOVoUX6Rwjx3XKxZdD4u9 3frV9rVGz0jHzkuaiKqCfiVDUhDBfg9E75b3prp/8fA+GQH2r4bV8bog3Plm1CQeEAIz lnxi4vGg/npJMOCbf8CXESipS1a5AObEdMy2t+C2BX8/ecW9saWQlxbFTqORmS8uSBgT /gyl6o9ju0TramE7/Yywv8JE9KpoA2O7vbbHSEd3XoxfrIuX2wfnYuo+VeUnXYAm86uc XWsqbtjhYAf36j575IZoAZgh8cD3XOllW7kg4yy/moixjwfv5r5bdp+X+qnyiI3Yw2mM Td+w== X-Gm-Message-State: AOAM533tss6pvYD8KdWbDERhJM8EqzW+lYyUNtXFQ8/WU+Cy1s6TVgln gPqT/KVyLaaz1fEMI/I82lENeyMF8KBMKQX4 X-Received: by 2002:a05:600c:5101:: with SMTP id o1mr40540284wms.81.1636229262302; Sat, 06 Nov 2021 13:07:42 -0700 (PDT) Received: from localhost ([91.75.210.37]) by smtp.gmail.com with ESMTPSA id o9sm11571286wrs.4.2021.11.06.13.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Nov 2021 13:07:41 -0700 (PDT) Date: Sun, 7 Nov 2021 00:07:33 +0400 From: Dmitrii Banshchikov To: Thomas Gleixner Cc: Alexei Starovoitov , syzbot , John Stultz , LKML , sboyd@kernel.org, syzkaller-bugs , Peter Zijlstra , Mark Rutland , Steven Rostedt , Alexei Starovoitov , Daniel Borkmann , bpf Subject: Re: [syzbot] possible deadlock in ktime_get_coarse_ts64 Message-ID: <20211106200733.meank7oonwvsdjy4@amnesia> References: <00000000000013aebd05cff8e064@google.com> <87lf224uki.ffs@tglx> <20211105170328.fjnzr6bnbca7mdfq@amnesia> <875yt64isx.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <875yt64isx.ffs@tglx> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 05, 2021 at 06:24:30PM +0100, Thomas Gleixner wrote: > On Fri, Nov 05 2021 at 21:03, Dmitrii Banshchikov wrote: > > On Fri, Nov 05, 2021 at 08:53:06AM -0700, Alexei Starovoitov wrote: > >> > Timestamps from within a tracepoint can only be taken with: > >> > > >> > 1) jiffies > >> > 2) sched_clock() > >> > 3) ktime_get_*_fast_ns() > >> > > >> > Those are NMI safe and can be invoked from anywhere. > >> > > >> > All other time getters which have to use the timekeeping seqcount > >> > protection are prone to live locks and _cannot_ be used from > >> > tracepoints ever. > >> > >> Obviously. > >> That helper was added for networking use cases and accidentally > >> enabled for tracing. > > > > Sorry for that. > > I'm preparing a patch that will forbid using bpf_ktime_get_coarse_ns() > > helper in BPF_LINK_TYPE_RAW_TRACEPOINT. > > It cannot be used in TRACING and PERF_EVENT either. But those contexts > have to exclude other functions as well: > > bpf_ktime_get_ns > bpf_ktime_get_boot_ns > > along with > > bpf_spin_lock/unlock > bpf_timer_* 1) bpf_ktime_get_ns and bpf_ktime_get_boot_ns use ktime_get_{mono,boot}_fast_ns. 2) bpf_spin_lock/unlock have notrace attribute set. 3) bpf_timer_* helpers fail early if they are in NMI. Why they have to be excluded? -- Dmitrii Banshchikov