Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp4265252rba; Tue, 2 Apr 2024 11:45:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/B114MHY1thyRgKAYCuJjMItGRppTUJjkV2AumJ3K1WpgFCGon3uQ1qaAmgQzy0E/QKcOgtVmGv+7jwbh3N4r3V7p4xOVBai+uQdfvA== X-Google-Smtp-Source: AGHT+IFf9qg6NgV1RqOUSgNBEChfs3aOkoerIH3D8e4bX+WYOniJBVfDpQ2ERFO1DhnMdoDTPlWZ X-Received: by 2002:a1f:f287:0:b0:4d8:6ae0:36a6 with SMTP id q129-20020a1ff287000000b004d86ae036a6mr9707442vkh.3.1712083556304; Tue, 02 Apr 2024 11:45:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712083556; cv=pass; d=google.com; s=arc-20160816; b=aZDCSDd9XZXV7qhqIio1nhCyzVMlg7ybZEzLb0KN0vfjw8pwVXB/LF90RGKQV6A9Q4 Hiin7hEcVsaSaknMUgdpVm2J58hTbElsuj4FNZBoQthza+iAXi9hdKqFGSGIfFyisX4N W3UuoOjegY0JEgNxMxb3NchsSfLUsXKPefLH0wPlJABz8/NoVYhqDwCtiyy2IXNPTM4I n8B12+6khzSVScy1tsgGOGFU9sQD9rEVfQrqhwwrK8L+Kn0t4Jblf/+dhHa42ZPP8w8c Dw254bE/mR4E8K3C9O182dFcm0I76ZjiYhGVeZTh0THztOLYbMAjIOzUZz+IAxAx6ejg W9OA== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=sL594dRjKrRvgDwAu6nK3cXb0rXdqzK1JyQE0PlCmmI=; fh=a9zkyDTTP4hIGFBeAJCcWdWF2IfV5BYM5Tn5dB8faEc=; b=l+XfmHYJUKouoiqVKu42kTiGDcSH97WjOTxWbR2vpczFmCFeFahSXswCbLL0GlcfSG rXF0POuNGXsRgCHHeoH0AzesLduHO6di3CA6gHxZJBW170EZh+L7pALIVghFA3Qanqa+ KUA1ymqsmGvyfnSpohsr5MedsxqssWQtoW2Daonev6IDCK6T/96zpmzK7v8C0yl/CNo0 1n4OgtMl6XaiRnfs7II48rRryR/6mnBTo3FFMUOjb4ec3v8r5ndXuupqHlXw8IavdPUC AlkjEMisr++A6n17mzV4A7ghwWHCPAAweAyja/KR4Rl4WQUVu4sR2VJsqYgKdn3RP75Y cXBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U5Rw7oYe; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-128517-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128517-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c1-20020a056214004100b0069676318c3asi12236334qvr.62.2024.04.02.11.45.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 11:45:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128517-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U5Rw7oYe; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-128517-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128517-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id EFA2E1C22EBF for ; Tue, 2 Apr 2024 18:45:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0889D15B134; Tue, 2 Apr 2024 18:45:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U5Rw7oYe" 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 2132F17582; Tue, 2 Apr 2024 18:45:44 +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=1712083545; cv=none; b=dHMEpn/NKomV//1EofR+uPPbCVZNKv9w8NMJZtNbAfJYhjlyT2XxzsemF4qT3fvEHjsGVNpDGNjH1oKFrW/47tf8Gw/lgxg500G7OEp1cH05I6OKPmtBcS+wpbBFBgMkFCRcttD1SIXXOhwBpyBb3pZvkso702/jcYaF2lb9P4E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712083545; c=relaxed/simple; bh=HOVqg2Er+74+MeO5rrzusHbqWwKSikD0noVEquqbUw0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Jf5FsJbxkTSOCVMZLN86veYrc81mdKoqLMlCkV/46ytJM771QKHlP5+YOCKtiSfWKU0yveIyHz+BE4jqqO3Ee6bMUXNlTqRCneLeU5bjR+UrA2JxVw8NOqE+HsUt8BSUuj/Ght10xadtmoRSqaZWfFnhOi/GiAEEc5ERVugHNPg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U5Rw7oYe; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43C24C433C7; Tue, 2 Apr 2024 18:45:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712083544; bh=HOVqg2Er+74+MeO5rrzusHbqWwKSikD0noVEquqbUw0=; h=From:To:Cc:Subject:Date:From; b=U5Rw7oYeehrvzdYKOy9I4OhtE0J+OS7A91mVCv8R5+y6LyKuJBR53Mr+xm4UFuaTu Wq6l+yU83oepmkeOsyjlgZzWVXqScOin+hYP/rZi6UBevq3pSzeg4ICgPpGs5rKk1z o47A7ls168CBvGfUzOTai+KFeAs7/tx1P86j1/ebglkYz+irSk3UZo0KD1QI3PKIrn kuZOtXRBWMSU5GujaO/8qNgg7uO8hf2lE7O37NyzYkPIAUM0cP5Z3kUlIyZ7NKYWBx z6qyml6XXVy7lkPOGN/+pFLV34X0cLbwzhjuCLHQixFQmzcDY1ELv1FyCsqdDypsg7 vYUW+d7YnXDAg== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Song Liu , bpf@vger.kernel.org Subject: [PATCH] perf lock contention: Add a missing NULL check Date: Tue, 2 Apr 2024 11:45:43 -0700 Message-ID: <20240402184543.898923-1-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit I got a report for a failure in BPF verifier on a recent kernel with perf lock contention command. It checks task->sighand->siglock without checking if sighand is NULL or not. Let's add one. ; if (&curr->sighand->siglock == (void *)lock) 265: (79) r1 = *(u64 *)(r0 +2624) ; frame1: R0_w=trusted_ptr_task_struct(off=0,imm=0) R1_w=rcu_ptr_or_null_sighand_struct(off=0,imm=0) 266: (b7) r2 = 0 ; frame1: R2_w=0 267: (0f) r1 += r2 R1 pointer arithmetic on rcu_ptr_or_null_ prohibited, null-check it first processed 164 insns (limit 1000000) max_states_per_insn 1 total_states 15 peak_states 15 mark_read 5 -- END PROG LOAD LOG -- libbpf: prog 'contention_end': failed to load: -13 libbpf: failed to load object 'lock_contention_bpf' libbpf: failed to load BPF skeleton 'lock_contention_bpf': -13 Failed to load lock-contention BPF skeleton lock contention BPF setup failed lock contention did not detect any lock contention Signed-off-by: Namhyung Kim --- tools/perf/util/bpf_skel/lock_contention.bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/bpf_skel/lock_contention.bpf.c b/tools/perf/util/bpf_skel/lock_contention.bpf.c index fb54bd38e7d0..4e5914d7eeaa 100644 --- a/tools/perf/util/bpf_skel/lock_contention.bpf.c +++ b/tools/perf/util/bpf_skel/lock_contention.bpf.c @@ -305,7 +305,7 @@ static inline __u32 check_lock_type(__u64 lock, __u32 flags) break; case LCB_F_SPIN: /* spinlock */ curr = bpf_get_current_task_btf(); - if (&curr->sighand->siglock == (void *)lock) + if (curr->sighand && &curr->sighand->siglock == (void *)lock) return LCD_F_SIGHAND_LOCK; break; default: -- 2.44.0.478.gd926399ef9-goog