mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oliver Henning <oliver.henning@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: [RESEND] Unsafe kmalloc() calls found
Date: Thu, 4 Apr 2019 16:09:55 +0200	[thread overview]
Message-ID: <0fc84c29-867d-89f2-a05e-c48e754b7c6f@gmail.com> (raw)
In-Reply-To: <9f3ba19b-70cb-7631-9426-7aabacc1fdb6@gmail.com>

Hello

I have written a Python script to scan the kernel for unchecked kmalloc() calls. It found the following instances. I checked them manually, too. I would like to fix them myself but I do not how to do a proper failure handling. So maybe someone else can have a look.

Oliver


drivers/net/wireless/rsi/rsi_91x_mac80211.c:199
             channels = kmalloc(sizeof(rsi_2ghz_channels), GFP_KERNEL);
             memcpy(channels,
                    rsi_2ghz_channels,
                    sizeof(rsi_2ghz_channels));
---

drivers/net/wireless/rsi/rsi_91x_mac80211.c:208
             channels = kmalloc(sizeof(rsi_5ghz_channels), GFP_KERNEL);
             memcpy(channels,
                    rsi_5ghz_channels,
                    sizeof(rsi_5ghz_channels));
---

arch/mips/pmcs-msp71xx/msp_prom.c:378
          argv = kmalloc(len, GFP_KERNEL);
          ptr = (char *) &argv[prom_argc + 1];    /* strings follow array */
    
          for (argc = 0; argc < prom_argc; argc++) {
               argv[argc] = ptr;
               strcpy(ptr, prom_argv[argc]);
               ptr += strlen(prom_argv[argc]) + 1;
          }
---

arch/mips/pmcs-msp71xx/msp_prom.c:399
          envp = kmalloc(len, GFP_KERNEL);
          ptr = (char *) &envp[i+1];
    
          for (argc = 0; argc < i; argc++) {
               envp[argc] = ptr;
               strcpy(ptr, prom_envp[argc]);
               ptr += strlen(prom_envp[argc]) + 1;
          }
---

arch/powerpc/platforms/pseries/dlpar.c:389
          hp_errlog_copy = kmalloc(sizeof(struct pseries_hp_errorlog),
                          GFP_KERNEL);
          memcpy(hp_errlog_copy, hp_errlog, sizeof(struct pseries_hp_errorlog));
---

drivers/media/pci/cx23885/cx23885-dvb.c:1477
                    fe0->dvb.frontend->sec_priv = kmalloc(sizeof(dib7000p_ops), GFP_KERNEL);
                    memcpy(fe0->dvb.frontend->sec_priv, &dib7000p_ops, sizeof(dib7000p_ops));
---

drivers/misc/lkdtm/perms.c:135
          u32 *kmalloc_area = kmalloc(EXEC_SIZE, GFP_KERNEL);
          execute_location(kmalloc_area, CODE_WRITE);
          kfree(kmalloc_area);
     }
---

drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c:113
          new_compat = kmalloc(new_len, GFP_KERNEL);
    
          omapdss_prefix_strcpy(new_compat, new_len, prop->value, prop->length);
    
          omapdss_update_prop(node, new_compat, new_len);
     }
---

drivers/staging/media/davinci_vpfe/dm365_ipipe.c:1267
               params = kmalloc(sizeof(struct ipipe_module_params),
                          GFP_KERNEL);
               to = (void *)params + module_if->param_offset;
               size = module_if->param_size;
    
               if (to && from && size) {
                    if (copy_from_user(to, (void __user *)from, size)) {
                         rval = -EFAULT;
                         break;
                    }
---

drivers/staging/media/davinci_vpfe/dm365_ipipe.c:1309
               params = kmalloc(sizeof(struct ipipe_module_params),
                          GFP_KERNEL);
               from = (void *)params + module_if->param_offset;
               size = module_if->param_size;
    
               if (to && from && size) {
                    rval = module_if->get(ipipe, from);
                    if (rval)
                         goto error;
                    if (copy_to_user((void __user *)to, from, size)) {
---


      reply	other threads:[~2019-04-04 14:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-03 12:08 Unchecked kmalloc() calls Oliver Henning
2019-04-04 14:09 ` Oliver Henning [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0fc84c29-867d-89f2-a05e-c48e754b7c6f@gmail.com \
    --to=oliver.henning@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®