Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4198035pxu; Wed, 9 Dec 2020 10:40:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcXmRLzVwM0R2oQwXpSvryaqKwaKvmc32z15hwwkm7JiXDV/iZ6yyRniZIJv7Pr2KNtlXX X-Received: by 2002:aa7:c892:: with SMTP id p18mr3312732eds.64.1607539212631; Wed, 09 Dec 2020 10:40:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607539212; cv=none; d=google.com; s=arc-20160816; b=B1uUuULEIY6XB2Oh/8J7W+Hfs036gsYAKtX2v8RQdUQHGpdSccQZW7PX/VNg+pLMZv VHOClO/igzkraItf1Ocz7e3YGSQsOOxqJBG+BG7yQbUrWaSeuxhjfJmaKtmkaAYnRd1N Bp6uBNF5gPVHjjblfugN5QuIvVZbZy+4Q3JHiwh2JDbli29LOLak1Bx3g6HRsyiAFfMm jQyJEx0aWe7afwx3eDoCOsuxnG63fMVxqnPZkHDmy+b1aVL8Jb8jQx6Ny0tnNpcoLh9+ fFnfutGPRcRXUjW9yKkYCkZmVSR7izUn/p4nH+4PwkaM/v6M/+5IfcWh33xUJvgTGSST Rjaw== 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:dkim-signature; bh=InI8kMxZ0SE9l75DuOndEZGfmarmC3cXjv+qNAPdxJc=; b=e/ZqHC4T2d/YzjHoiU4BRnL7uC9Uk/GAgPCiYTE1+saF0+EsaMrNz2iT/g/WpKP7Mn /RnmNOD/xOhRCRTTgr+MvPvphTE7WXV44NLL8QhvMdHPu1hPIGTpaulmDUyeIll4qDs6 cEZOGODIE3r0jqgD+dqKWNNmeQBmrApbV52K3KPnmvSWNZPcKIuv9wIcKHyxv4Ryeykq m5usnG5sGV8J5m8QC4HagUwE966tfYYYPoTv2OsCxhfBVYgxmSVX9bEFHqr7S1Kpz55u AcVfBzqSnRCesY24qcvi4NSYfHYOk+mPc1eGkxwcw2X3IxMoOBFiRMqu1RX+qHxCG78D GGUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LsJ2BETu; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq6si1179927ejc.40.2020.12.09.10.39.48; Wed, 09 Dec 2020 10:40:12 -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=@gmail.com header.s=20161025 header.b=LsJ2BETu; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733150AbgLIShL (ORCPT + 99 others); Wed, 9 Dec 2020 13:37:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728625AbgLIShL (ORCPT ); Wed, 9 Dec 2020 13:37:11 -0500 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F13FFC0613CF; Wed, 9 Dec 2020 10:36:30 -0800 (PST) Received: by mail-oi1-x243.google.com with SMTP id k2so2746740oic.13; Wed, 09 Dec 2020 10:36:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=InI8kMxZ0SE9l75DuOndEZGfmarmC3cXjv+qNAPdxJc=; b=LsJ2BETuCnGZplnCDnz9ZU/yhWlpFhGebvqCV1GITkN7ifDJZbUx21OQBZDu8otKZB Z+rOS2JXHh+o5IkyMq4Rc0lcJohqNOsjejAD9dEUKG8GhAYYNOHhwNUPfgz3AXsq0aU9 CL/YfPZi64bVyKE9IFBwOyqY25PxEaerntKM7SjeuNrv74hq1FkXppsCbWMY3CNpjHwR rhBIsXUCAFQAnnd6RNtR1eBwY8PQ2B1cx5W+f/M37LmJRc7iIP8v7FyhjGTctyy9J+FK K5dEzwZIjoijlFv9OKZTwHKfBdHItKvhwbVZoldEDyQ/AC6pDxi48+t4og7mu1yjzM6N +xQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=InI8kMxZ0SE9l75DuOndEZGfmarmC3cXjv+qNAPdxJc=; b=CJ5F5ZbgDs5berxM48iAuhQ3fr2u2KZ3BGXAGT8q4kQcUE4pxhWIyOefgTGwmAGe3W EI0ee06h77pPLcx8Mb5nARvF9pRvIAx7rjnRnnpJLtlNEKex4aU7Q3/Fwd20I/Mn0HUh P8Y/JC2/vJi9lMjbb0TRHzetOXP740ijpARMmn6WU/vSeZJPghpPtBy0XTVE3TYAtvj3 2v7xkZSdM37TVajQdG/hw4B7FCCMYriDvVpt2g1FvFmQu2iZMT9Li8dOsoteogtxD6SL 77zN4Nnyp6q2iKUPPjvnkXqBC9n+SmgWCoLsqMqVTuFgrN4xCqVYzf9KxxCX09BmFarL LRbg== X-Gm-Message-State: AOAM530BHIe4z/88fxJb/dXFHNnBJRlPG/tXFIH1YfW3QG6TiKCKIfl9 R+Bbvdf+cWPDxSeEMEIFsTQ= X-Received: by 2002:aca:aa83:: with SMTP id t125mr2702550oie.103.1607538990199; Wed, 09 Dec 2020 10:36:30 -0800 (PST) Received: from frodo.comcast.net ([2601:284:8203:5970::fb22]) by smtp.googlemail.com with ESMTPSA id e8sm540375oti.76.2020.12.09.10.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 10:36:29 -0800 (PST) From: Jim Cromie To: gregkh@linuxfoundation.org Cc: Jim Cromie , stable@vger.kernel.org, Jason Baron , linux-kernel@vger.kernel.org Subject: [PATCH v2] dyndbg: fix use before null check Date: Wed, 9 Dec 2020 11:36:25 -0700 Message-Id: <20201209183625.2432329-1-jim.cromie@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- -v2 drop comment tweak, improve commit message Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index bd7b3aaa93c3..c70d6347afa2 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -561,9 +561,14 @@ static int ddebug_exec_queries(char *query, const char *modname) 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); -- 2.29.2