Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9094848pxu; Mon, 28 Dec 2020 06:30:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFA3B/PzDSmJKO+ZRMTRE18Vi2cPCTQDKIogtd29e8DtTF94qWyt6xBipQRqBQ9bvWeQvd X-Received: by 2002:aa7:db56:: with SMTP id n22mr43119217edt.4.1609165858783; Mon, 28 Dec 2020 06:30:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165858; cv=none; d=google.com; s=arc-20160816; b=unn+YplLusIFeetfhRORLptvOv2M512BEoAv47mlxKk1bTTQAeKff4PVvcwsEJnrwY G6DwXn4wOAEeBLlKDfQ2n7nl0UBtE6kKWiD/nz54OmW9FnsVfE/SGUw9jIA/1f9V/3pL dmJhitiGy4YrA2IbYR5JY0PKQmDbrsmpnoyYFJXxU6qk2IR2cHtXe2BxRKmhUFzTAmSS i9ouR6OkpWOV8Df2A2b5SXR7UEBN2s5oHsry7AiMCCxJgXouPKiG87lhR2xeyiAvYoQy OZWXRnKIuH/jFwHgS8Pm79GyPMeId7VUCKNQ3CTgczu+nqJijzYRBGZCoWxFEFH+ZHaO kr3Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JTsbAKQLn6B0Wj04R5zJQRb7ecV9Xb8mba93muW1jvc=; b=qEPPykv0OIiSa4pLnQRVs+FPoYD9TE9nOx2SZowTzggyxnrsAmtRmEk28LFYcmyp+p qA+xIJz0k4OhomadENStVQVYaisFt1Axf5OudETXgWS4flKjh/dh1+V6YynDdTdZFjzo boi+iwfzUJ9RBFdR//xTBLOsY9tGDU+kzs3KWRFAWHZv4Ej5NOZzmujsND1nIlaYuDNn KQ+sb8CYbw8iEJ9NEAce6qED/ij2rsFHlKP86AQ3VgwkuINpYicrc+sRqTDJ+IbVUzYQ IYgDQKdBEFsHThb3Scl71uEVQt0RYSTDEiSQ8tTzBquT9VHJ0OgCAmeJ9TmG8O8qg2F6 aG7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=m8azPOAh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb10si2773040edb.192.2020.12.28.06.30.35; Mon, 28 Dec 2020 06:30:58 -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=@linuxfoundation.org header.s=korg header.b=m8azPOAh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502393AbgL1O2U (ORCPT + 99 others); Mon, 28 Dec 2020 09:28:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:36226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502358AbgL1O2T (ORCPT ); Mon, 28 Dec 2020 09:28:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 64270206D4; Mon, 28 Dec 2020 14:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165659; bh=aZwdFjxzpDrDs30YAcOvGiCDupbp5UYPJBHDopEQny0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m8azPOAhJNWVqmTCDQ4xiaMcptf8CUAiS1BvISxnmpuG3M9YYOeCEYq7t0Jk05oB/ LIKIcJ5MzrRZDyihz+bRYO7DGNTbEI8CnV+syZrppHohgYLMQsDVVOOFZlCoSAt8lW +RyCJ6/Y6TSAU73HrQW/qDz9KbhTLdxYvdXRuVJc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jim Cromie Subject: [PATCH 5.10 578/717] dyndbg: fix use before null check Date: Mon, 28 Dec 2020 13:49:36 +0100 Message-Id: <20201228125048.602826394@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jim Cromie commit 3577afb0052fca65e67efdfc8e0859bb7bac87a6 upstream. In commit a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec_queries()"), a string is copied before checking it isn't NULL. Fix this, report a usage/interface error, and return the proper error code. Fixes: a2d375eda771 ("dyndbg: refine export, rename to dynamic_debug_exec_queries()") Cc: stable@vger.kernel.org Signed-off-by: Jim Cromie Link: https://lore.kernel.org/r/20201209183625.2432329-1-jim.cromie@gmail.com Signed-off-by: Greg Kroah-Hartman --- lib/dynamic_debug.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -561,9 +561,14 @@ static int ddebug_exec_queries(char *que int dynamic_debug_exec_queries(const char *query, const char *modname) { int rc; - char *qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL); + char *qry; /* writable copy of query */ - if (!query) + if (!query) { + pr_err("non-null query/command string expected\n"); + return -EINVAL; + } + qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL); + if (!qry) return -ENOMEM; rc = ddebug_exec_queries(qry, modname);