* [static analysis] memory corruption in tty/synclink.c on 64bit
@ 2012-09-17 11:18 Dan Carpenter
2012-09-17 13:16 ` Alan Cox
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-09-17 11:18 UTC (permalink / raw)
To: linux-kernel; +Cc: Jiri Slaby
I don't think anyone really cares about this but just for laughs here
is the warning:
drivers/tty/synclink.c:5418 usc_process_rxoverrun_sync() warn: potential memory corrupting cast 8 vs 2 bytes
drivers/tty/synclink.c:6414 mgsl_reset_tx_dma_buffers() warn: potential memory corrupting cast 8 vs 2 bytes
drivers/tty/synclink.c:6455 mgsl_reset_rx_dma_buffers() warn: potential memory corrupting cast 8 vs 2 bytes
drivers/tty/synclink.c:6500 mgsl_free_rx_frame_buffers() warn: potential memory corrupting cast 8 vs 2 bytes
6489 /* reset current buffer for reuse */
6490 // pBufEntry->status = 0;
6491 // pBufEntry->count = DMABUFFERSIZE;
6492 *((unsigned long *)&(pBufEntry->count)) = DMABUFFERSIZE;
It looks like the commented out code is the correct code and the code
on line 6492 is the "faster" version? My static checker complains that
it would corrupt the next struct elements on 64 bit. Also it only works
on little endian systems.
typedef struct _DMABUFFERENTRY
{
u32 phys_addr; /* 32-bit flat physical address of data buffer */
volatile u16 count; /* buffer size/data count */
volatile u16 status; /* Control/status field */
volatile u16 rcc; /* character count field */
u16 reserved; /* padding required by 16C32 */
This was there in the original code when it was merged in 2.2.5pre1.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [static analysis] memory corruption in tty/synclink.c on 64bit
2012-09-17 11:18 [static analysis] memory corruption in tty/synclink.c on 64bit Dan Carpenter
@ 2012-09-17 13:16 ` Alan Cox
0 siblings, 0 replies; 2+ messages in thread
From: Alan Cox @ 2012-09-17 13:16 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-kernel, Jiri Slaby
On Mon, 17 Sep 2012 14:18:19 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> I don't think anyone really cares about this but just for laughs here
> is the warning:
>
> drivers/tty/synclink.c:5418 usc_process_rxoverrun_sync() warn: potential memory corrupting cast 8 vs 2 bytes
> drivers/tty/synclink.c:6414 mgsl_reset_tx_dma_buffers() warn: potential memory corrupting cast 8 vs 2 bytes
> drivers/tty/synclink.c:6455 mgsl_reset_rx_dma_buffers() warn: potential memory corrupting cast 8 vs 2 bytes
> drivers/tty/synclink.c:6500 mgsl_free_rx_frame_buffers() warn: potential memory corrupting cast 8 vs 2 bytes
>
> 6489 /* reset current buffer for reuse */
> 6490 // pBufEntry->status = 0;
> 6491 // pBufEntry->count = DMABUFFERSIZE;
> 6492 *((unsigned long *)&(pBufEntry->count)) = DMABUFFERSIZE;
>
> It looks like the commented out code is the correct code and the code
> on line 6492 is the "faster" version? My static checker complains that
> it would corrupt the next struct elements on 64 bit. Also it only works
> on little endian systems.
>
> typedef struct _DMABUFFERENTRY
> {
> u32 phys_addr; /* 32-bit flat physical address of data buffer */
> volatile u16 count; /* buffer size/data count */
> volatile u16 status; /* Control/status field */
> volatile u16 rcc; /* character count field */
> u16 reserved; /* padding required by 16C32 */
>
> This was there in the original code when it was merged in 2.2.5pre1.
Should probably be changed to *((u32 *) at least. As it happens as far as
I can see its harmless however.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-17 13:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-17 11:18 [static analysis] memory corruption in tty/synclink.c on 64bit Dan Carpenter
2012-09-17 13:16 ` Alan Cox
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®