lkml.org 
[lkml]   [2022]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/9] trinity: Add load/unload IDU files
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

\
 
 \ /
  Last update: 2022-07-27 15:15    [W:0.201 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site