Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp301915imn; Wed, 27 Jul 2022 06:44:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vjGpwk/cM/OBhj+s3E24C5j0NAh3TQAIcEOargsq2dYTJMYIF4EAm+kPk1KEOpH6nWuna4 X-Received: by 2002:a65:4c0b:0:b0:415:d3a4:44d1 with SMTP id u11-20020a654c0b000000b00415d3a444d1mr19174213pgq.191.1658929451761; Wed, 27 Jul 2022 06:44:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658929451; cv=none; d=google.com; s=arc-20160816; b=hX6olng3fnZETyL6PS5O3TWxJpwSP/OX1Iv1mmO4IBnOPOupaq1LxppeIpmTFdxxtv xIdeToiffYCnQLyVMKt9k/Ur0aTUD6qRwRUOjeox8k3ePzX2AQJeY75bnnuz4KOzh9WJ VJNYZkmbgJVNKEshKRAVrzaHOUn4UL/WZWRaDUOJXm8GI7rwT0rAPb4yhOXhwZIgjiMm jjdhULtDjXFk9FGBRR4yhcZ8O0vSKnr5GDwL9jg6qywKNhh730kkxSvU5uxOhtL+iQTD Hs88ZvtxiqcR6Pgqxh3Xt6Y+t4+1bx+f+ecxg8M7jGPZt/+W3Jp6Px4I27PKKVD1Gihe KwEQ== 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=j1/TE5/KIyIZodw+RphuRVFXIW8wbB6RbMtWK4h3y6Q=; b=T3j0D+HBXg0n3CpMqtCw9bmlgJLpzD4T6Jvd/BlMexvl+1tZEItY1yQtIRD2R1pv5H neFHAvYGjk1bvZ8gfFao0rKNpSYQi2MXA4PnsfSG4JDd6RYJrlZVEMS2KsrKmMu9kVhP GR7FhsB4ajX9zPJYO5MvDszGGJJfalEme8c9NqQd6Ta53jrS1SFzLW7VHtfezGWsizvl Aj3DPzFj2aBeehY9klwCYuZslZoqZZw9pgqY0iS8h5Fz3Sym1NV3C8WY5ra9MrARcdCT +zgyl3dY+t7Yr7W7OpthZZXmfxSuHl+9X4F9hVbi0dRUZZgaDniBXA8I+A74R5sfPIx3 UnBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d0DYo5D7; 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 b19-20020a056a000a9300b0052b0e52e1e4si22616008pfl.2.2022.07.27.06.43.56; Wed, 27 Jul 2022 06:44:11 -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=d0DYo5D7; 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 S233412AbiG0NOQ (ORCPT + 99 others); Wed, 27 Jul 2022 09:14:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbiG0NOO (ORCPT ); Wed, 27 Jul 2022 09:14:14 -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 1506E2715B for ; Wed, 27 Jul 2022 06:14:14 -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 A4D07616E9 for ; Wed, 27 Jul 2022 13:14:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABF86C433C1; Wed, 27 Jul 2022 13:14:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658927653; bh=UlOJehB2C1dNDPXUGdD1B54/kBcVsgQvnRt2OM153Xw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d0DYo5D7jLWdFMIOGTd0DjsNocVglW009ELjLZ4/GHv44QeELumQ+XWY+yuDwCw8y ERQ3yuNqnvbhzCfLAGyKFtr7sKH0rGeF6wnpN15kNuZgDAqfTVzJ/NySET9/p6+6Wc b1SpkEw7h2BYJwIhSgfjBznpXAf4hPzMgtocQs/U= Date: Wed, 27 Jul 2022 15:14:10 +0200 From: Greg KH To: Jiho Chu Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, yelini.jeong@samsung.com, myungjoo.ham@samsung.com Subject: Re: [PATCH 3/9] trinity: Add load/unload IDU files Message-ID: References: <20220725065308.2457024-1-jiho.chu@samsung.com> <20220725065308.2457024-4-jiho.chu@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220725065308.2457024-4-jiho.chu@samsung.com> X-Spam-Status: No, score=-7.7 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 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 Mon, Jul 25, 2022 at 03:53:02PM +0900, Jiho Chu wrote: > +static int triv2_idu_load_file(struct trinity_driver *drv, const char *dirpath, > + const char *file_name, > + struct trinity_resv_mem *sector) > +{ > + struct device *dev = drv_to_dev_ptr(drv); > + struct trinity_resv_mem mem; > + char filepath[NAME_MAX]; > + struct kstat *stat; > + struct file *filp; > + loff_t pos = 0; > + size_t size; > + int ret; > + > + dev = drv_to_dev_ptr(drv); > + stat = vmalloc(sizeof(*stat)); > + if (stat == NULL) > + return -ENOMEM; > + > + /* if dirpath is null, use the default path */ > + if (dirpath) > + snprintf(filepath, NAME_MAX, "%s/%s", dirpath, file_name); > + else > + snprintf(filepath, NAME_MAX, TRIV2_IDU_DIRPATH_FMT "/%s", > + utsname()->release, file_name); > + > + filp = filp_open(filepath, O_RDONLY, 0400); That is cute. And totally not ok. Please never do this, that is not how to properly load a firmware blob in the kernel. This is racy and broken and probably a huge security hole. Heck, I wrote an article about this very topic, way back in 2005, with the title of, "Things you should never do in the kernel" and can be seen here: https://www.linuxjournal.com/article/8110 This should not be news to anyone, again, never do this. thanks, greg k-h