Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
1bec5152
Commit
1bec5152
authored
Oct 28, 2002
by
Alexander Viro
Committed by
James Bottomley
Oct 28, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] randomness made per-disk
* per-major array eliminated, every disk is a separate source of randomness
parent
288ed82d
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
24 additions
and
32 deletions
+24
-32
drivers/block/DAC960.c
drivers/block/DAC960.c
+2
-2
drivers/block/floppy.c
drivers/block/floppy.c
+1
-1
drivers/block/genhd.c
drivers/block/genhd.c
+2
-0
drivers/char/random.c
drivers/char/random.c
+10
-22
drivers/ide/ide.c
drivers/ide/ide.c
+1
-1
drivers/s390/block/dasd.c
drivers/s390/block/dasd.c
+1
-1
drivers/scsi/scsi_lib.c
drivers/scsi/scsi_lib.c
+1
-1
include/linux/blk.h
include/linux/blk.h
+3
-2
include/linux/genhd.h
include/linux/genhd.h
+3
-0
include/linux/random.h
include/linux/random.h
+0
-2
No files found.
drivers/block/DAC960.c
View file @
1bec5152
...
...
@@ -3014,7 +3014,7 @@ static void DAC960_V1_ProcessCompletedCommand(DAC960_Command_T *Command)
complete
(
Command
->
Completion
);
Command
->
Completion
=
NULL
;
}
add_
blkdev_randomness
(
DAC960_MAJOR
+
Controller
->
ControllerNumber
);
add_
disk_randomness
(
Controller
->
disks
[
Command
->
LogicalDriveNumber
]
);
}
else
if
((
CommandStatus
==
DAC960_V1_IrrecoverableDataError
||
CommandStatus
==
DAC960_V1_BadDataEncountered
)
&&
...
...
@@ -4120,7 +4120,7 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
complete
(
Command
->
Completion
);
Command
->
Completion
=
NULL
;
}
add_
blkdev_randomness
(
DAC960_MAJOR
+
Controller
->
ControllerNumber
);
add_
disk_randomness
(
Controller
->
disks
[
Command
->
LogicalDriveNumber
]
);
}
else
if
(
Command
->
V2
.
RequestSense
.
SenseKey
==
DAC960_SenseKey_MediumError
&&
...
...
drivers/block/floppy.c
View file @
1bec5152
...
...
@@ -2297,7 +2297,7 @@ static inline void end_request(struct request *req, int uptodate)
{
if
(
end_that_request_first
(
req
,
uptodate
,
current_count_sectors
))
return
;
add_
blkdev_randomness
(
MAJOR_NR
);
add_
disk_randomness
(
req
->
rq_disk
);
floppy_off
((
int
)
req
->
rq_disk
->
private_data
);
blkdev_dequeue_request
(
req
);
end_that_request_last
(
req
);
...
...
drivers/block/genhd.c
View file @
1bec5152
...
...
@@ -289,6 +289,7 @@ EXPORT_SYMBOL(disk_devclass);
static
void
disk_release
(
struct
device
*
dev
)
{
struct
gendisk
*
disk
=
dev
->
driver_data
;
kfree
(
disk
->
random
);
kfree
(
disk
->
part
);
kfree
(
disk
);
}
...
...
@@ -316,6 +317,7 @@ struct gendisk *alloc_disk(int minors)
disk
->
disk_dev
.
driver_data
=
disk
;
device_initialize
(
&
disk
->
disk_dev
);
}
rand_initialize_disk
(
disk
);
return
disk
;
}
...
...
drivers/char/random.c
View file @
1bec5152
...
...
@@ -253,6 +253,7 @@
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/workqueue.h>
#include <linux/genhd.h>
#include <asm/processor.h>
#include <asm/uaccess.h>
...
...
@@ -718,7 +719,6 @@ static struct timer_rand_state keyboard_timer_state;
static
struct
timer_rand_state
mouse_timer_state
;
static
struct
timer_rand_state
extract_timer_state
;
static
struct
timer_rand_state
*
irq_timer_state
[
NR_IRQS
];
static
struct
timer_rand_state
*
blkdev_timer_state
[
MAX_BLKDEV
];
/*
* This function adds entropy to the entropy "pool" by using timing
...
...
@@ -812,18 +812,12 @@ void add_interrupt_randomness(int irq)
add_timer_randomness
(
irq_timer_state
[
irq
],
0x100
+
irq
);
}
void
add_
blkdev_randomness
(
int
major
)
void
add_
disk_randomness
(
struct
gendisk
*
disk
)
{
if
(
major
>=
MAX_BLKDEV
)
if
(
!
disk
||
!
disk
->
random
)
return
;
if
(
blkdev_timer_state
[
major
]
==
0
)
{
rand_initialize_blkdev
(
major
,
GFP_ATOMIC
);
if
(
blkdev_timer_state
[
major
]
==
0
)
return
;
}
add_timer_randomness
(
blkdev_timer_state
[
major
],
0x200
+
major
);
/* first major is 1, so we get >= 0x200 here */
add_timer_randomness
(
disk
->
random
,
0x100
+
MKDEV
(
disk
->
major
,
disk
->
first_minor
));
}
/******************************************************************
...
...
@@ -1447,8 +1441,6 @@ void __init rand_initialize(void)
#endif
for
(
i
=
0
;
i
<
NR_IRQS
;
i
++
)
irq_timer_state
[
i
]
=
NULL
;
for
(
i
=
0
;
i
<
MAX_BLKDEV
;
i
++
)
blkdev_timer_state
[
i
]
=
NULL
;
memset
(
&
keyboard_timer_state
,
0
,
sizeof
(
struct
timer_rand_state
));
memset
(
&
mouse_timer_state
,
0
,
sizeof
(
struct
timer_rand_state
));
memset
(
&
extract_timer_state
,
0
,
sizeof
(
struct
timer_rand_state
));
...
...
@@ -1472,26 +1464,22 @@ void rand_initialize_irq(int irq)
irq_timer_state
[
irq
]
=
state
;
}
}
void
rand_initialize_
blkdev
(
int
major
,
int
mode
)
void
rand_initialize_
disk
(
struct
gendisk
*
disk
)
{
struct
timer_rand_state
*
state
;
if
(
major
>=
MAX_BLKDEV
||
blkdev_timer_state
[
major
])
return
;
/*
* If kmalloc returns null, we just won't use that entropy
* source.
*/
state
=
kmalloc
(
sizeof
(
struct
timer_rand_state
),
mode
);
state
=
kmalloc
(
sizeof
(
struct
timer_rand_state
),
GFP_KERNEL
);
if
(
state
)
{
memset
(
state
,
0
,
sizeof
(
struct
timer_rand_state
));
blkdev_timer_state
[
major
]
=
state
;
disk
->
random
=
state
;
}
}
static
ssize_t
random_read
(
struct
file
*
file
,
char
*
buf
,
size_t
nbytes
,
loff_t
*
ppos
)
{
...
...
@@ -2309,7 +2297,7 @@ __u32 check_tcp_syn_cookie(__u32 cookie, __u32 saddr, __u32 daddr, __u16 sport,
EXPORT_SYMBOL
(
add_keyboard_randomness
);
EXPORT_SYMBOL
(
add_mouse_randomness
);
EXPORT_SYMBOL
(
add_interrupt_randomness
);
EXPORT_SYMBOL
(
add_
blkdev
_randomness
);
EXPORT_SYMBOL
(
add_
disk
_randomness
);
EXPORT_SYMBOL
(
batch_entropy_store
);
EXPORT_SYMBOL
(
generate_random_uuid
);
drivers/ide/ide.c
View file @
1bec5152
...
...
@@ -406,7 +406,7 @@ int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors)
}
if
(
!
end_that_request_first
(
rq
,
uptodate
,
nr_sectors
))
{
add_
blkdev_randomness
(
major
(
rq
->
rq_dev
)
);
add_
disk_randomness
(
rq
->
rq_disk
);
if
(
!
blk_rq_tagged
(
rq
))
blkdev_dequeue_request
(
rq
);
else
...
...
drivers/s390/block/dasd.c
View file @
1bec5152
...
...
@@ -1496,7 +1496,7 @@ dasd_end_request(struct request *req, int uptodate)
{
if
(
end_that_request_first
(
req
,
uptodate
,
req
->
hard_nr_sectors
))
BUG
();
add_
blkdev_randomness
(
major
(
req
->
rq_dev
)
);
add_
disk_randomness
(
req
->
rq_disk
);
end_that_request_last
(
req
);
return
;
}
...
...
drivers/scsi/scsi_lib.c
View file @
1bec5152
...
...
@@ -357,7 +357,7 @@ static Scsi_Cmnd *__scsi_end_request(Scsi_Cmnd * SCpnt,
return
SCpnt
;
}
add_
blkdev_randomness
(
major
(
req
->
rq_dev
)
);
add_
disk_randomness
(
req
->
rq_disk
);
spin_lock_irqsave
(
q
->
queue_lock
,
flags
);
...
...
include/linux/blk.h
View file @
1bec5152
...
...
@@ -8,7 +8,8 @@
#include <linux/compiler.h>
extern
void
set_device_ro
(
kdev_t
dev
,
int
flag
);
extern
void
add_blkdev_randomness
(
int
major
);
extern
void
add_disk_randomness
(
struct
gendisk
*
disk
);
extern
void
rand_initialize_disk
(
struct
gendisk
*
disk
);
#ifdef CONFIG_BLK_DEV_RAM
...
...
@@ -62,7 +63,7 @@ static inline void end_request(struct request *req, int uptodate)
if
(
end_that_request_first
(
req
,
uptodate
,
req
->
hard_cur_sectors
))
return
;
add_
blkdev_randomness
(
major
(
req
->
rq_dev
)
);
add_
disk_randomness
(
req
->
rq_disk
);
blkdev_dequeue_request
(
req
);
end_that_request_last
(
req
);
}
...
...
include/linux/genhd.h
View file @
1bec5152
...
...
@@ -93,6 +93,9 @@ struct gendisk {
struct
device
*
driverfs_dev
;
struct
device
disk_dev
;
struct
timer_rand_state
*
random
;
unsigned
sync_io
;
/* RAID */
unsigned
reads
,
writes
;
unsigned
rio
,
wio
;
...
...
include/linux/random.h
View file @
1bec5152
...
...
@@ -44,14 +44,12 @@ struct rand_pool_info {
extern
void
rand_initialize
(
void
);
extern
void
rand_initialize_irq
(
int
irq
);
extern
void
rand_initialize_blkdev
(
int
irq
,
int
mode
);
extern
void
batch_entropy_store
(
u32
a
,
u32
b
,
int
num
);
extern
void
add_keyboard_randomness
(
unsigned
char
scancode
);
extern
void
add_mouse_randomness
(
__u32
mouse_data
);
extern
void
add_interrupt_randomness
(
int
irq
);
extern
void
add_blkdev_randomness
(
int
major
);
extern
void
get_random_bytes
(
void
*
buf
,
int
nbytes
);
void
generate_random_uuid
(
unsigned
char
uuid_out
[
16
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment