Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp915749rwd; Tue, 16 May 2023 09:12:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4u9l9cK1m3eotSD2pUWuHW88D43NqZ5nT8Wii8+X6zg5rw7Efnrytxcvul4aFxbv3tRmfM X-Received: by 2002:a17:90a:c8:b0:247:90d8:41fd with SMTP id v8-20020a17090a00c800b0024790d841fdmr37150096pjd.26.1684253547747; Tue, 16 May 2023 09:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684253547; cv=none; d=google.com; s=arc-20160816; b=xqyFGHWxZYYjrBTQyVXTVnN7SRCtbZkAqe1HfkzIW1Q+S6gf/y2L+86pYKO2hqOxdX KA2hbByCuqoR+SjA9wx/SgO5hiwVEGq4nlLeD7K5+WdpVWxoGyUr9uF6iPL+qj04kpWk xOn8L4xR5pVoz+47trjUTrum6cChfvZnYoSWOOcRvX4HH8K0WEBnoPwDT76og3HaJPe8 Of5o6uSlANy9q9neG1UD/TuaFg1NX1wyO+MN53IBReKl7G1oKdPiMayzvXQk1nICYipv SX8OJSkqJ/mciXw1j8DoUz8NWWXpDHHdSWg4kKGNwO2TzR3b0ItfkOHHKsE9ToX/B9gR gy6A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=T2DH6/H5m8Qazyq8fWgGGTIxlN/LEAb7+hM6ytoAYMY=; b=d78rzrVA3y6O3k9ZW10OToLBTMaeDJULXRSeUoKTNh3TEP9BB4LEmhgmp9BlpEUB66 7Ya4xIt/9JaqqPCj+y78NWI28BFnBiAo7ACe1I6oDFynIO7whXP9lD4ffHSRHdY2o2g1 S9BhzNi+211Yob8PTA/noj0Hncb0HLxTD9xa7ywnlS31V7SQU/38jcxU+C92xJxPuUGM eVPj4DfWArUIXIPVrZ941/vQlmqQ7pPzzeQpjaucuhPAMFCqpLwNlz5ZiFZIAicTxFxG qCV9hTCvtX2zmzczsMVD7eEG3K7UGXlMKxO/0bDLd8nYGTc3xDzPwvlrFyu/4/ZVhIjU ZW0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=jaYJo2OZ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j65-20020a638b44000000b0051b10b20ceasi20090098pge.893.2023.05.16.09.12.12; Tue, 16 May 2023 09:12:27 -0700 (PDT) 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; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=jaYJo2OZ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234525AbjEPQJf (ORCPT + 99 others); Tue, 16 May 2023 12:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231241AbjEPQJJ (ORCPT ); Tue, 16 May 2023 12:09:09 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 920BA9EEF for ; Tue, 16 May 2023 09:08:34 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34GFMLXM013969; Tue, 16 May 2023 11:07:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=T2DH6/H5m8Qazyq8fWgGGTIxlN/LEAb7+hM6ytoAYMY=; b=jaYJo2OZNJaOaQrzjITNXQW+77MenPnRLDgfl4yJSF1ZEy4lESaGCIij26mkBdeoOcL3 jw8dqXTMd/lPIbf+go/3Tw4kfuwPUpiEi3CUuWdr7qE48C6GbsPVj7I/LpzW/H/mQfiV JRLbofGTer24W/7Kmh6ZfEaJn/3fQQsREwv5Yj+/1qGlLebFTH6Va+4FT/GEwLNWJb6J EuwwV65XH+BYiYBsGU2ANWfdS0WlbmdCp28sszGEpVvdbDfMOdYs5coM+wBmh8uJ3vN/ NT5cldcZCzXw+akmOEt3X8xBudYqH8jlySboURtFo9S2zwdxv8rfVBfqEcuAffOypIAd OQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3qj7y14epn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 May 2023 11:07:58 -0500 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Tue, 16 May 2023 11:07:56 -0500 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Tue, 16 May 2023 11:07:56 -0500 Received: from EDIN4L06LR3.ad.cirrus.com (EDIN4L06LR3.ad.cirrus.com [198.61.64.66]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 15B7211A8; Tue, 16 May 2023 16:07:56 +0000 (UTC) From: Richard Fitzgerald To: , CC: , , Richard Fitzgerald Subject: [PATCH 1/5] debugfs: Prevent NULL dereference reading from string property Date: Tue, 16 May 2023 17:07:49 +0100 Message-ID: <20230516160753.32317-2-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230516160753.32317-1-rf@opensource.cirrus.com> References: <20230516160753.32317-1-rf@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: F3BY0PdYc71JIRmuN6TytsC3HzMbVf3f X-Proofpoint-ORIG-GUID: F3BY0PdYc71JIRmuN6TytsC3HzMbVf3f X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Check in debugfs_read_file_str() if the string pointer is NULL. It is perfectly reasonable that a driver may wish to export a string to debugfs that can have the value NULL to indicate empty/unused/ignore. Signed-off-by: Richard Fitzgerald --- fs/debugfs/file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 1f971c880dde..2c085ab4e800 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -878,6 +878,9 @@ ssize_t debugfs_read_file_str(struct file *file, char __user *user_buf, return ret; str = *(char **)file->private_data; + if (!str) + return simple_read_from_buffer(user_buf, count, ppos, "\n", 1); + len = strlen(str) + 1; copy = kmalloc(len, GFP_KERNEL); if (!copy) { -- 2.30.2