Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp9324871rwl; Wed, 11 Jan 2023 04:28:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXvmsOm8S/oLRSOvFoMb2n3Yn9L9KqDy/+YC7WmItHMeGkUFTWHQEGjHHQLfK0kb6YIjQHTu X-Received: by 2002:a05:6402:6c7:b0:492:609a:f144 with SMTP id n7-20020a05640206c700b00492609af144mr19717088edy.6.1673440135607; Wed, 11 Jan 2023 04:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673440135; cv=none; d=google.com; s=arc-20160816; b=UBIt2Bpzlb34yLAxdEyCrx19uqOiAJ+4q97T3kyOaBwcLLY0jr2aLmRjrIdVks4IzM TEVx8naRHRRMgH/mwxjJoabXdyWuMT06hXNr2UfVi1jVW6Ca0Ha3DotzguKylri/DybW 7896jDo9TxUvjj0swIvSPScpT+49rrKqVtS6SmUFS7jtp3hkNIJ7WGCnMuH4Y/vlKk1M +uw44ieYIgKzf61jmvldJ4/Vv0aT7lYeSPkQRt3jnyKFs921yKF8DRCEuvPONMP/FKK+ kmbfEMG5XHX5/URZP38BGE38HC+KucABO/bxs7DtsmuDsH2DwYF9SqXU1DyXpAt1AJUe w1Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=qWEp68BaQ4tiwEzntQ/EKk1PFF5xs3d/gJEBTNIwaE4=; b=U/Ybrl0/D0xDvQ3qEzKgO+aqGiS1rotazg7JR4ydYo7QJ+fb8VSg8euuZiN52eYJTw rRdRMXqfTVk0hE1/xnsa4w5rT49V9W0fLnikdXtOOqM81Qt3I6wsj+aK4F5SwJey0x8Z tSB9Z6kupT/sNuQ/xVedrLuxuTy1pG8D7wjXD/G72IEY6W6pHR5uY2QeEA2v1Xv23/Ws cSw/YW9ntZ0s9zaj0f81wDl9+4a4PgRoppGdYZeQOtZ2DXYsyyqSJqJGtogDPWYgLMho FdNKcPFu2q7ULe+QbKamWOSg5lSMzsSxu6evB0F90+fM7fyIZ3PSOFguIf9oHhWP+i3P E62Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf16-20020a0564021a5000b0047b79b99e58si13701416edb.446.2023.01.11.04.28.42; Wed, 11 Jan 2023 04:28:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232271AbjAKLoF (ORCPT + 53 others); Wed, 11 Jan 2023 06:44:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238586AbjAKLni (ORCPT ); Wed, 11 Jan 2023 06:43:38 -0500 X-Greylist: delayed 66 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 11 Jan 2023 03:42:36 PST Received: from exchange.fintech.ru (e10edge.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED271110D for ; Wed, 11 Jan 2023 03:42:36 -0800 (PST) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Wed, 11 Jan 2023 14:41:21 +0300 Received: from KANASHIN1.fintech.ru (10.0.253.125) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 11 Jan 2023 14:41:21 +0300 From: Natalia Petrova To: Steven Rostedt CC: Natalia Petrova , Ingo Molnar , , Subject: Date: Wed, 11 Jan 2023 14:41:18 +0300 Message-ID: <20230111114118.3796-1-n.petrova@fintech.ru> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.253.125] X-ClientProxiedBy: Ex16-01.fintech.ru (10.0.10.18) To Ex16-01.fintech.ru (10.0.10.18) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Date: Thu, 15 Dec 2022 18:08:36 +0300 Subject: [PATCH] trace_events_hist: add check for return value of 'create_hist_field' Function 'create_hist_field' is called recursively at trace_events_hist.c:1954 and can return NULL-value that's why we have to check it to avoid null pointer dereference. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 30350d65ac56 ("tracing: Add variable support to hist triggers") Signed-off-by: Natalia Petrova --- kernel/trace/trace_events_hist.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index fdf784620c28..9c8c1614a78e 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -1952,6 +1952,8 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data, hist_field->fn = flags & HIST_FIELD_FL_LOG2 ? hist_field_log2 : hist_field_bucket; hist_field->operands[0] = create_hist_field(hist_data, field, fl, NULL); + if (!hist_field->operands[0]) + goto free; hist_field->size = hist_field->operands[0]->size; hist_field->type = kstrdup_const(hist_field->operands[0]->type, GFP_KERNEL); if (!hist_field->type) -- 2.34.1