Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp950990rwd; Tue, 16 May 2023 09:40:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ59SzfdHnSu2kZ99aODMBFzLH6JpET/ndHgRK/hVT+A4ZhKFyYtyDWT/BL8UMNeGz3jSfWG X-Received: by 2002:a05:6a20:3d87:b0:101:e680:d423 with SMTP id s7-20020a056a203d8700b00101e680d423mr29929229pzi.28.1684255220040; Tue, 16 May 2023 09:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684255220; cv=none; d=google.com; s=arc-20160816; b=MVqsuQX4ukrXpPwsdn+2b3w2tE7MVlaU+ZcAUEQU/xr3jvprPCHT2j+5QldzUkkJS4 ObcmbqiwQHpQUW58HGdKZkOPw7XoKAGb1yXsi6o+4w04soMYQJSifa/eoiHDhzyCCow4 mOtoR3kugNB8GzGy0jZoyjcTzDIuTJKzWUxpDASE1LUBAGYHIR4ti/az1GNybUOmUhG8 wqnA+oX/UFQtbPtKv/vTNAjMmgUokh8oIqU7B0RueUuhsw26DN8kCmOfmcS4vErnpUgl wte9BIfHQ5qbEEdaRr0Cd3sQBC5Bdfm6wmy2PtMh+X/3Fwu//fIdnfdnwkTq5MA9olda +Siw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=yIwcAi+cCOWpX4kxfrYFMTA8XVUpitO0G88InM1Q3XQ=; b=L1WiRykrvEf5qXJVKTgX0o5oWYOEHAX0+uNmxfo9ARvnjuq+yF65+TkNL0lVDNjDSJ FUjvxN4sb+Xb/1fdv1zru0tfWNzurtqmTk5LZ4UhTh8vPrMboOQ/7WFB47QEA+KgzkaS QFZVJtVCdfVBoBj6Qx18VixVsMOGMASDeI8Llx9m1tM+PWkOxYu1wvCH2/0CUs8ZCQJc UK6cPquOGR5Gd1m5V8xkUrY83skrx9lXz9MsIt16MYcnmxT+DLWjyKJ3IUMw5A+Aou+V vnS7gWEayiK4sLxAFMPRLYuyzfzxgfv3Dj1wy/+DbkcZl0Zd5TQfddXSJ7SXVx4TEJCS PBAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=o+7H1wis; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020aa79d87000000b0064aef84eb16si9909558pfq.135.2023.05.16.09.40.06; Tue, 16 May 2023 09:40:20 -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=@linuxfoundation.org header.s=korg header.b=o+7H1wis; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231255AbjEPQek (ORCPT + 99 others); Tue, 16 May 2023 12:34:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231164AbjEPQeT (ORCPT ); Tue, 16 May 2023 12:34:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72E868A6F for ; Tue, 16 May 2023 09:33:51 -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 6A37363C4E for ; Tue, 16 May 2023 16:33:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F801C433EF; Tue, 16 May 2023 16:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1684254790; bh=S662qo2UVoOXOFDuwEkwSVoUMgoQBmhOOr5kswpopv8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=o+7H1wisXbIBcAvQyoHAL3B+q7ARKGA6goA+cwdMrOi0XLMLycw0HhgiPwK9cHAU6 XeG4VcilF6WaI930vA5K5fqXnAFxe5OHXZ8/ZOQFsPHJdRVR8awdx+4MPMXr2Smn9H KSx6Fx5HThvUcK7lMfWuw0DthbvmIZZwBHqD9XAM= Date: Tue, 16 May 2023 18:33:08 +0200 From: Greg KH To: Richard Fitzgerald Cc: rafael@kernel.org, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com Subject: Re: [PATCH 1/5] debugfs: Prevent NULL dereference reading from string property Message-ID: <2023051659-sinless-lemon-e3b1@gregkh> References: <20230516160753.32317-1-rf@opensource.cirrus.com> <20230516160753.32317-2-rf@opensource.cirrus.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230516160753.32317-2-rf@opensource.cirrus.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Tue, May 16, 2023 at 05:07:49PM +0100, Richard Fitzgerald wrote: > 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. Does any in-kernel driver do this today? If not, why not fix up the driver instead? > > 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); Why not print "(NULL)"? thanks, greg k-h