mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
UPSTREAM: block: disable entropy contributions for nonrot devices
(cherry picked from commitb277da0a8a
) Clear QUEUE_FLAG_ADD_RANDOM in all block drivers that set QUEUE_FLAG_NONROT. Historically, all block devices have automatically made entropy contributions. But as previously stated in commite2e1a148
("block: add sysfs knob for turning off disk entropy contributions"): - On SSD disks, the completion times aren't as random as they are for rotational drives. So it's questionable whether they should contribute to the random pool in the first place. - Calling add_disk_randomness() has a lot of overhead. There are more reliable sources for randomness than non-rotational block devices. From a security perspective it is better to err on the side of caution than to allow entropy contributions from unreliable "random" sources. Change-Id: I8e9005feeedf301e486cf1aa13c804e322a3591b Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Jens Axboe <axboe@fb.com> Signed-off-by: Artem Borisov <dedsa2002@gmail.com>
This commit is contained in:
parent
bf67753ca2
commit
efc542e8fd
6 changed files with 10 additions and 2 deletions
|
@ -3632,6 +3632,7 @@ skip_create_disk:
|
|||
|
||||
/* Set device limits. */
|
||||
set_bit(QUEUE_FLAG_NONROT, &dd->queue->queue_flags);
|
||||
clear_bit(QUEUE_FLAG_ADD_RANDOM, &dd->queue->queue_flags);
|
||||
blk_queue_max_segments(dd->queue, MTIP_MAX_SG);
|
||||
blk_queue_physical_block_size(dd->queue, 4096);
|
||||
blk_queue_io_min(dd->queue, 4096);
|
||||
|
|
|
@ -1150,6 +1150,7 @@ static int create_device(struct zram *zram, int device_id)
|
|||
set_capacity(zram->disk, 0);
|
||||
/* zram devices sort of resembles non-rotational disks */
|
||||
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue);
|
||||
queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, zram->disk->queue);
|
||||
/*
|
||||
* To ensure that we always get PAGE_SIZE aligned
|
||||
* and n*PAGE_SIZED sized I/O requests.
|
||||
|
|
|
@ -686,8 +686,10 @@ static void ide_disk_setup(ide_drive_t *drive)
|
|||
printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name,
|
||||
queue_max_sectors(q) / 2);
|
||||
|
||||
if (ata_id_is_ssd(id))
|
||||
if (ata_id_is_ssd(id)) {
|
||||
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
|
||||
queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, q);
|
||||
}
|
||||
|
||||
/* calculate drive capacity, and select LBA if possible */
|
||||
ide_disk_get_capacity(drive);
|
||||
|
|
|
@ -202,6 +202,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
|
|||
|
||||
blk_queue_prep_rq(mq->queue, mmc_prep_request);
|
||||
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, mq->queue);
|
||||
queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, mq->queue);
|
||||
if (mmc_can_erase(card))
|
||||
mmc_queue_setup_discard(mq->queue, card);
|
||||
|
||||
|
|
|
@ -441,6 +441,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
|
|||
blk_queue_logical_block_size(new->rq, tr->blksize);
|
||||
|
||||
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, new->rq);
|
||||
queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, new->rq);
|
||||
|
||||
if (tr->discard) {
|
||||
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, new->rq);
|
||||
|
|
|
@ -2398,8 +2398,10 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp)
|
|||
|
||||
rot = get_unaligned_be16(&buffer[4]);
|
||||
|
||||
if (rot == 1)
|
||||
if (rot == 1) {
|
||||
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, sdkp->disk->queue);
|
||||
queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, sdkp->disk->queue);
|
||||
}
|
||||
|
||||
out:
|
||||
kfree(buffer);
|
||||
|
|
Loading…
Reference in a new issue