svn commit: r340857 - head/stand/common
Maxim Sobolev
sobomax at FreeBSD.org
Fri Nov 23 22:36:57 UTC 2018
Author: sobomax
Date: Fri Nov 23 22:36:56 2018
New Revision: 340857
URL: https://svnweb.freebsd.org/changeset/base/340857
Log:
Nuke out buffer overflow safety marker code, it duplicates similar code in
the malloc()/free() as well as having potential of softening the handling
in case error is detected down to a mere warning as compared to hard panic
in free().
Submitted by: tsoome
Differential Revision: https://reviews.freebsd.org/D18299
Modified:
head/stand/common/bcache.c
Modified: head/stand/common/bcache.c
==============================================================================
--- head/stand/common/bcache.c Fri Nov 23 22:24:59 2018 (r340856)
+++ head/stand/common/bcache.c Fri Nov 23 22:36:56 2018 (r340857)
@@ -86,7 +86,6 @@ static u_int bcache_rablks;
((bc)->bcache_ctl[BHASH((bc), (blkno))].bc_blkno != (blkno))
#define BCACHE_READAHEAD 256
#define BCACHE_MINREADAHEAD 32
-#define BCACHE_MARKER 0xdeadbeef
static void bcache_invalidate(struct bcache *bc, daddr_t blkno);
static void bcache_insert(struct bcache *bc, daddr_t blkno);
@@ -123,7 +122,6 @@ bcache_allocate(void)
u_int i;
struct bcache *bc = malloc(sizeof (struct bcache));
int disks = bcache_numdev;
- uint32_t *marker;
if (disks == 0)
disks = 1; /* safe guard */
@@ -142,8 +140,7 @@ bcache_allocate(void)
bc->bcache_nblks = bcache_total_nblks >> i;
bcache_unit_nblks = bc->bcache_nblks;
- bc->bcache_data = malloc(bc->bcache_nblks * bcache_blksize +
- sizeof(uint32_t));
+ bc->bcache_data = malloc(bc->bcache_nblks * bcache_blksize);
if (bc->bcache_data == NULL) {
/* dont error out yet. fall back to 32 blocks and try again */
bc->bcache_nblks = 32;
@@ -158,9 +155,6 @@ bcache_allocate(void)
errno = ENOMEM;
return (NULL);
}
- /* Insert cache end marker. */
- marker = (uint32_t *)(bc->bcache_data + bc->bcache_nblks * bcache_blksize);
- *marker = BCACHE_MARKER;
/* Flush the cache */
for (i = 0; i < bc->bcache_nblks; i++) {
@@ -222,15 +216,12 @@ read_strategy(void *devdata, int rw, daddr_t blk, size
int result;
daddr_t p_blk;
caddr_t p_buf;
- uint32_t *marker;
if (bc == NULL) {
errno = ENODEV;
return (-1);
}
- marker = (uint32_t *)(bc->bcache_data + bc->bcache_nblks * bcache_blksize);
-
if (rsize != NULL)
*rsize = 0;
@@ -348,12 +339,6 @@ read_strategy(void *devdata, int rw, daddr_t blk, size
if (size != 0) {
bcopy(bc->bcache_data + (bcache_blksize * BHASH(bc, blk)), buf, size);
result = 0;
- }
-
- if (*marker != BCACHE_MARKER) {
- printf("BUG: bcache corruption detected: nblks: %zu p_blk: %lu, "
- "p_size: %zu, ra: %zu\n", bc->bcache_nblks,
- (long unsigned)BHASH(bc, p_blk), p_size, ra);
}
done:
More information about the svn-src-all
mailing list