From mboxrd@z Thu Jan 1 00:00:00 1970 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 691B5C433EF for ; Mon, 9 May 2022 22:37:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231910AbiEIWlm (ORCPT ); Mon, 9 May 2022 18:41:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231851AbiEIWlh (ORCPT ); Mon, 9 May 2022 18:41:37 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56DD11FE1F2; Mon, 9 May 2022 15:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=5httqNTKNMbgjU3BIxtC2FF0M4AjcTdqhFqK/ZumpdE=; b=Cot2sF2iU+2/Xzl0/HW17+QR2z 8NjKGCVRideD24WANl7NLhcfOJUE1q9B4j5hntw+Q69/CNsDefhqhU0+3kKwvQh3fXez99cBGFIQq hJ3bs+piT079Au9ZVsAIkQJMw0ei8L+mkcuKFo12FHwXjyPyf53FcDCwfcuUEwG80iY3YCrBdQ0fS zTHVPMp5HtWd4++jLVsv6oqcRPyKvzVLvVZMKMSW/N1L1Cv2TjA3h8m1IxB6vq3BLNGfuWWPigS1w suIn4t2sz/cNxoKEYzsal9KLhJMS+wr03abmEyYcAVH2ofXUXapwgu0Vkfnia7VQ087XEd48ArzwJ xmJy1Z7w==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1noC0Z-00Gb6D-5v; Mon, 09 May 2022 22:37:39 +0000 Date: Mon, 9 May 2022 15:37:39 -0700 From: Luis Chamberlain To: Dan Carpenter Cc: Greg Kroah-Hartman , Russ Weight , Tianfei zhang , Lee Jones , Shawn Guo , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH v3] test_firmware: fix end of loop test in upload_read_show() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 06, 2022 at 09:55:15AM +0300, Dan Carpenter wrote: > If a list_for_each_entry() loop exits without hitting a break statement > then the iterator points to invalid memory. So in this code the > "tst->name" dereference is an out bounds read. It's an offset from the > &test_upload_list pointer and it will likely work fine most of the time > but it's not correct. > > One alternative is to fix this this by changing the test to: > > if (list_entry_is_head(tst, &test_upload_list, node)) { > > But the simpler, trendy new way is just create a new variable and test > for NULL. > > Fixes: a31ad463b72d ("test_firmware: Add test support for firmware upload") > Signed-off-by: Dan Carpenter > Reviewed-by: Russ Weight Acked-by: Luis Chamberlain Luis