Project

General

Profile

Actions

Feature #2962

open

Aspectator should provide "memset" functionality

Added by Evgeny Novikov about 12 years ago. Updated over 8 years ago.

Status:
Open
Priority:
Low
Category:
-
Start date:
06/06/2012
Due date:
% Done:

0%

Estimated time:
Published in build:

Description

memset function has rather simple implementation:

void *memset(void *s, int c, size_t count)
{
        char *xs = s;

        while (count--)
                *xs++ = c;
        return s;
}

For us it's interesting cases, when c is 0, count is a size of allocated memory (pointed by s) in bytes. But this is too complex for high-weight static verifiers nevertheless. For them we should provide more simple code. Let's consider the following example:
struct net2280_ep {
        struct usb_ep                           ep;
        struct net2280_ep_regs                  __iomem *regs;
        struct net2280_dma_regs                 __iomem *dma;
        struct net2280_dma                      *dummy;
        dma_addr_t                              td_dma; /* of dummy */
        struct net2280                          *dev;
        ...
};

struct net2280 {
        /* each pci device provides one gadget, several endpoints */
        struct usb_gadget               gadget;
        spinlock_t                      lock;
        struct net2280_ep               ep [7];
        struct usb_gadget_driver        *driver;
        ...
};

struct net2280        *dev;
dev = kzalloc (sizeof *dev, GFP_KERNEL);

For such the example, "memset" should look like:
// memset(dev, 0, sizeof(struct net2280))
dev.gadget.... = 0;
dev.lock.... = 0;
dev.ep[0].... = 0;
dev.ep[0].dma = 0;
dev.ep[0].... = 0;
dev.ep[1] = 0;
...
dev.ep[6].dma = 0;
dev.ep[6].... = 0;
dev.driver = 0;
...

Without this knowledge static verifiers have many false positives.

Actions

Also available in: Atom PDF