From patchwork Mon Apr 24 13:18:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 13222179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AB3AC77B7F for ; Mon, 24 Apr 2023 13:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232782AbjDXNjX (ORCPT ); Mon, 24 Apr 2023 09:39:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232790AbjDXNjB (ORCPT ); Mon, 24 Apr 2023 09:39:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C886F93F6; Mon, 24 Apr 2023 06:38:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 74B2661D16; Mon, 24 Apr 2023 13:38:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 815A6C433D2; Mon, 24 Apr 2023 13:38:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1682343526; bh=VcLv8JN1TgLe7NYl2Ie7loJzukPT4oWuE1B8SrIq7+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YUOzJ3WsJm/m1RvOjwLpjWYbx0Lx9Rqq0iz/PSHsldg5uhX5GBXHemoEUwHOM15GQ FdzGMAYyhwXr8lEWxi71hbaxtWouO4rtEx+I4AwRrlfT2AH8rHHC3tUF6yNMwczX9k kGr8byPNdvn2MZbv0T04BUHTnwTLuXRe+XmIJNmU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ekaterina Orlova , David Woodhouse , James Bottomley , Jarkko Sakkinen , keyrings@vger.kernel.org, linux-kbuild@vger.kernel.org, David Howells , Linus Torvalds Subject: [PATCH 4.19 29/29] ASN.1: Fix check for strdup() success Date: Mon, 24 Apr 2023 15:18:56 +0200 Message-Id: <20230424131122.114376465@linuxfoundation.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230424131121.155649464@linuxfoundation.org> References: <20230424131121.155649464@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: keyrings@vger.kernel.org From: Ekaterina Orlova commit 5a43001c01691dcbd396541e6faa2c0077378f48 upstream. It seems there is a misprint in the check of strdup() return code that can lead to NULL pointer dereference. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 4520c6a49af8 ("X.509: Add simple ASN.1 grammar compiler") Signed-off-by: Ekaterina Orlova Cc: David Woodhouse Cc: James Bottomley Cc: Jarkko Sakkinen Cc: keyrings@vger.kernel.org Cc: linux-kbuild@vger.kernel.org Link: https://lore.kernel.org/r/20230315172130.140-1-vorobushek.ok@gmail.com/ Signed-off-by: David Howells Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- scripts/asn1_compiler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/scripts/asn1_compiler.c +++ b/scripts/asn1_compiler.c @@ -629,7 +629,7 @@ int main(int argc, char **argv) p = strrchr(argv[1], '/'); p = p ? p + 1 : argv[1]; grammar_name = strdup(p); - if (!p) { + if (!grammar_name) { perror(NULL); exit(1); }