Skip to content

Commit 15bd1cf

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
* 'for-linus' of git://git.kernel.dk/linux-block: block: add missed trace_block_plug paride: fix potential information leak in pg_read() bio: change some signed vars to unsigned block: avoid unnecessary plug list flush cciss: auto engage SCSI mid layer at driver load time loop: cleanup set_status interface include/linux/bio.h: use a static inline function for bio_integrity_clone() loop: prevent information leak after failed read block: Always check length of all iov entries in blk_rq_map_user_iov() The Windows driver .inf disables ASPM on all cciss devices. Do the same. backing-dev: ensure wakeup_timer is deleted block: Revert "[SCSI] genhd: add a new attribute "alias" in gendisk"
2 parents 9545eb6 + 019ceb7 commit 15bd1cf

13 files changed

Lines changed: 79 additions & 128 deletions

File tree

‎Documentation/ABI/testing/sysfs-block‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,3 @@ Description:
206206
when a discarded area is read the discard_zeroes_data
207207
parameter will be set to one. Otherwise it will be 0 and
208208
the result of reading a discarded area is undefined.
209-
What: /sys/block/<disk>/alias
210-
Date: Aug 2011
211-
Contact: Nao Nishijima <nao.nishijima.xt@hitachi.com>
212-
Description:
213-
A raw device name of a disk does not always point a same disk
214-
each boot-up time. Therefore, users have to use persistent
215-
device names, which udev creates when the kernel finds a disk,
216-
instead of raw device name. However, kernel doesn't show those
217-
persistent names on its messages (e.g. dmesg).
218-
This file can store an alias of the disk and it would be
219-
appeared in kernel messages if it is set. A disk can have an
220-
alias which length is up to 255bytes. Users can use alphabets,
221-
numbers, "-" and "_" in alias name. This file is writeonce.

‎Documentation/blockdev/cciss.txt‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,12 @@ You must enable "SCSI tape drive support for Smart Array 5xxx" and
9898
"SCSI support" in your kernel configuration to be able to use SCSI
9999
tape drives with your Smart Array 5xxx controller.
100100

101-
Additionally, note that the driver will not engage the SCSI core at init
102-
time. The driver must be directed to dynamically engage the SCSI core via
103-
the /proc filesystem entry which the "block" side of the driver creates as
104-
/proc/driver/cciss/cciss* at runtime. This is because at driver init time,
105-
the SCSI core may not yet be initialized (because the driver is a block
106-
driver) and attempting to register it with the SCSI core in such a case
107-
would cause a hang. This is best done via an initialization script
108-
(typically in /etc/init.d, but could vary depending on distribution).
101+
Additionally, note that the driver will engage the SCSI core at init
102+
time if any tape drives or medium changers are detected. The driver may
103+
also be directed to dynamically engage the SCSI core via the /proc filesystem
104+
entry which the "block" side of the driver creates as
105+
/proc/driver/cciss/cciss* at runtime. This is best done via a script.
106+
109107
For example:
110108

111109
for x in /proc/driver/cciss/cciss[0-9]*

‎block/blk-core.c‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,15 +1379,19 @@ void blk_queue_bio(struct request_queue *q, struct bio *bio)
13791379
*/
13801380
if (list_empty(&plug->list))
13811381
trace_block_plug(q);
1382-
else if (!plug->should_sort) {
1383-
struct request *__rq;
1382+
else {
1383+
if (!plug->should_sort) {
1384+
struct request *__rq;
13841385

1385-
__rq = list_entry_rq(plug->list.prev);
1386-
if (__rq->q != q)
1387-
plug->should_sort = 1;
1386+
__rq = list_entry_rq(plug->list.prev);
1387+
if (__rq->q != q)
1388+
plug->should_sort = 1;
1389+
}
1390+
if (request_count >= BLK_MAX_REQUEST_COUNT) {
1391+
blk_flush_plug_list(plug, false);
1392+
trace_block_plug(q);
1393+
}
13881394
}
1389-
if (request_count >= BLK_MAX_REQUEST_COUNT)
1390-
blk_flush_plug_list(plug, false);
13911395
list_add_tail(&req->queuelist, &plug->list);
13921396
drive_stat_acct(req, 1);
13931397
} else {

‎block/blk-map.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,11 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
204204
if (!iov[i].iov_len)
205205
return -EINVAL;
206206

207-
if (uaddr & queue_dma_alignment(q)) {
207+
/*
208+
* Keep going so we check length of all segments
209+
*/
210+
if (uaddr & queue_dma_alignment(q))
208211
unaligned = 1;
209-
break;
210-
}
211212
}
212213

213214
if (unaligned || (q->dma_pad_mask & len) || map_data)

‎block/genhd.c‎

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <linux/mutex.h>
2020
#include <linux/idr.h>
2121
#include <linux/log2.h>
22-
#include <linux/ctype.h>
2322

2423
#include "blk.h"
2524

@@ -916,74 +915,6 @@ static int __init genhd_device_init(void)
916915

917916
subsys_initcall(genhd_device_init);
918917

919-
static ssize_t alias_show(struct device *dev,
920-
struct device_attribute *attr, char *buf)
921-
{
922-
struct gendisk *disk = dev_to_disk(dev);
923-
ssize_t ret = 0;
924-
925-
if (disk->alias)
926-
ret = snprintf(buf, ALIAS_LEN, "%s\n", disk->alias);
927-
return ret;
928-
}
929-
930-
static ssize_t alias_store(struct device *dev, struct device_attribute *attr,
931-
const char *buf, size_t count)
932-
{
933-
struct gendisk *disk = dev_to_disk(dev);
934-
char *alias;
935-
char *envp[] = { NULL, NULL };
936-
unsigned char c;
937-
int i;
938-
ssize_t ret = count;
939-
940-
if (!count)
941-
return -EINVAL;
942-
943-
if (count >= ALIAS_LEN) {
944-
printk(KERN_ERR "alias: alias is too long\n");
945-
return -EINVAL;
946-
}
947-
948-
/* Validation check */
949-
for (i = 0; i < count; i++) {
950-
c = buf[i];
951-
if (i == count - 1 && c == '\n')
952-
break;
953-
if (!isalnum(c) && c != '_' && c != '-') {
954-
printk(KERN_ERR "alias: invalid alias\n");
955-
return -EINVAL;
956-
}
957-
}
958-
959-
if (disk->alias) {
960-
printk(KERN_INFO "alias: %s is already assigned (%s)\n",
961-
disk->disk_name, disk->alias);
962-
return -EINVAL;
963-
}
964-
965-
alias = kasprintf(GFP_KERNEL, "%s", buf);
966-
if (!alias)
967-
return -ENOMEM;
968-
969-
if (alias[count - 1] == '\n')
970-
alias[count - 1] = '\0';
971-
972-
envp[0] = kasprintf(GFP_KERNEL, "ALIAS=%s", alias);
973-
if (!envp[0]) {
974-
kfree(alias);
975-
return -ENOMEM;
976-
}
977-
978-
disk->alias = alias;
979-
printk(KERN_INFO "alias: assigned %s to %s\n", alias, disk->disk_name);
980-
981-
kobject_uevent_env(&dev->kobj, KOBJ_ADD, envp);
982-
983-
kfree(envp[0]);
984-
return ret;
985-
}
986-
987918
static ssize_t disk_range_show(struct device *dev,
988919
struct device_attribute *attr, char *buf)
989920
{
@@ -1043,7 +974,6 @@ static ssize_t disk_discard_alignment_show(struct device *dev,
1043974
return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue));
1044975
}
1045976

1046-
static DEVICE_ATTR(alias, S_IRUGO|S_IWUSR, alias_show, alias_store);
1047977
static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL);
1048978
static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL);
1049979
static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL);
@@ -1066,7 +996,6 @@ static struct device_attribute dev_attr_fail_timeout =
1066996
#endif
1067997

1068998
static struct attribute *disk_attrs[] = {
1069-
&dev_attr_alias.attr,
1070999
&dev_attr_range.attr,
10711000
&dev_attr_ext_range.attr,
10721001
&dev_attr_removable.attr,

‎drivers/block/cciss.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/interrupt.h>
2525
#include <linux/types.h>
2626
#include <linux/pci.h>
27+
#include <linux/pci-aspm.h>
2728
#include <linux/kernel.h>
2829
#include <linux/slab.h>
2930
#include <linux/delay.h>
@@ -4319,6 +4320,10 @@ static int __devinit cciss_pci_init(ctlr_info_t *h)
43194320
dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
43204321
return -ENODEV;
43214322
}
4323+
4324+
pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
4325+
PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
4326+
43224327
err = pci_enable_device(h->pdev);
43234328
if (err) {
43244329
dev_warn(&h->pdev->dev, "Unable to Enable PCI device\n");
@@ -5158,6 +5163,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
51585163
h->cciss_max_sectors = 8192;
51595164

51605165
rebuild_lun_table(h, 1, 0);
5166+
cciss_engage_scsi(h);
51615167
h->busy_initializing = 0;
51625168
return 1;
51635169

‎drivers/block/cciss_scsi.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,5 +1720,6 @@ static int cciss_eh_abort_handler(struct scsi_cmnd *scsicmd)
17201720
/* If no tape support, then these become defined out of existence */
17211721

17221722
#define cciss_scsi_setup(cntl_num)
1723+
#define cciss_engage_scsi(h)
17231724

17241725
#endif /* CONFIG_CISS_SCSI_TAPE */

‎drivers/block/loop.c‎

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -161,35 +161,45 @@ static struct loop_func_table *xfer_funcs[MAX_LO_CRYPT] = {
161161
&xor_funcs
162162
};
163163

164-
static loff_t get_loop_size(struct loop_device *lo, struct file *file)
164+
static loff_t get_size(loff_t offset, loff_t sizelimit, struct file *file)
165165
{
166-
loff_t size, offset, loopsize;
166+
loff_t size, loopsize;
167167

168168
/* Compute loopsize in bytes */
169169
size = i_size_read(file->f_mapping->host);
170-
offset = lo->lo_offset;
171170
loopsize = size - offset;
172-
if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize)
173-
loopsize = lo->lo_sizelimit;
171+
/* offset is beyond i_size, wierd but possible */
172+
if (loopsize < 0)
173+
return 0;
174174

175+
if (sizelimit > 0 && sizelimit < loopsize)
176+
loopsize = sizelimit;
175177
/*
176178
* Unfortunately, if we want to do I/O on the device,
177179
* the number of 512-byte sectors has to fit into a sector_t.
178180
*/
179181
return loopsize >> 9;
180182
}
181183

184+
static loff_t get_loop_size(struct loop_device *lo, struct file *file)
185+
{
186+
return get_size(lo->lo_offset, lo->lo_sizelimit, file);
187+
}
188+
182189
static int
183-
figure_loop_size(struct loop_device *lo)
190+
figure_loop_size(struct loop_device *lo, loff_t offset, loff_t sizelimit)
184191
{
185-
loff_t size = get_loop_size(lo, lo->lo_backing_file);
192+
loff_t size = get_size(offset, sizelimit, lo->lo_backing_file);
186193
sector_t x = (sector_t)size;
187194

188195
if (unlikely((loff_t)x != size))
189196
return -EFBIG;
190-
197+
if (lo->lo_offset != offset)
198+
lo->lo_offset = offset;
199+
if (lo->lo_sizelimit != sizelimit)
200+
lo->lo_sizelimit = sizelimit;
191201
set_capacity(lo->lo_disk, x);
192-
return 0;
202+
return 0;
193203
}
194204

195205
static inline int
@@ -372,7 +382,8 @@ do_lo_receive(struct loop_device *lo,
372382

373383
if (retval < 0)
374384
return retval;
375-
385+
if (retval != bvec->bv_len)
386+
return -EIO;
376387
return 0;
377388
}
378389

@@ -1058,9 +1069,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
10581069

10591070
if (lo->lo_offset != info->lo_offset ||
10601071
lo->lo_sizelimit != info->lo_sizelimit) {
1061-
lo->lo_offset = info->lo_offset;
1062-
lo->lo_sizelimit = info->lo_sizelimit;
1063-
if (figure_loop_size(lo))
1072+
if (figure_loop_size(lo, info->lo_offset, info->lo_sizelimit))
10641073
return -EFBIG;
10651074
}
10661075
loop_config_discard(lo);
@@ -1246,7 +1255,7 @@ static int loop_set_capacity(struct loop_device *lo, struct block_device *bdev)
12461255
err = -ENXIO;
12471256
if (unlikely(lo->lo_state != Lo_bound))
12481257
goto out;
1249-
err = figure_loop_size(lo);
1258+
err = figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit);
12501259
if (unlikely(err))
12511260
goto out;
12521261
sec = get_capacity(lo->lo_disk);
@@ -1284,13 +1293,19 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
12841293
goto out_unlocked;
12851294
break;
12861295
case LOOP_SET_STATUS:
1287-
err = loop_set_status_old(lo, (struct loop_info __user *) arg);
1296+
err = -EPERM;
1297+
if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))
1298+
err = loop_set_status_old(lo,
1299+
(struct loop_info __user *)arg);
12881300
break;
12891301
case LOOP_GET_STATUS:
12901302
err = loop_get_status_old(lo, (struct loop_info __user *) arg);
12911303
break;
12921304
case LOOP_SET_STATUS64:
1293-
err = loop_set_status64(lo, (struct loop_info64 __user *) arg);
1305+
err = -EPERM;
1306+
if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))
1307+
err = loop_set_status64(lo,
1308+
(struct loop_info64 __user *) arg);
12941309
break;
12951310
case LOOP_GET_STATUS64:
12961311
err = loop_get_status64(lo, (struct loop_info64 __user *) arg);

‎drivers/block/paride/pg.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ static ssize_t pg_read(struct file *filp, char __user *buf, size_t count, loff_t
630630
if (dev->status & 0x10)
631631
return -ETIME;
632632

633+
memset(&hdr, 0, sizeof(hdr));
633634
hdr.magic = PG_MAGIC;
634635
hdr.dlen = dev->dlen;
635636
copy = 0;

‎fs/bio.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static void bio_fs_destructor(struct bio *bio)
337337
* RETURNS:
338338
* Pointer to new bio on success, NULL on failure.
339339
*/
340-
struct bio *bio_alloc(gfp_t gfp_mask, int nr_iovecs)
340+
struct bio *bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs)
341341
{
342342
struct bio *bio = bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set);
343343

@@ -365,7 +365,7 @@ static void bio_kmalloc_destructor(struct bio *bio)
365365
* %__GFP_WAIT, the allocation is guaranteed to succeed.
366366
*
367367
**/
368-
struct bio *bio_kmalloc(gfp_t gfp_mask, int nr_iovecs)
368+
struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned int nr_iovecs)
369369
{
370370
struct bio *bio;
371371

@@ -696,7 +696,8 @@ static void bio_free_map_data(struct bio_map_data *bmd)
696696
kfree(bmd);
697697
}
698698

699-
static struct bio_map_data *bio_alloc_map_data(int nr_segs, int iov_count,
699+
static struct bio_map_data *bio_alloc_map_data(int nr_segs,
700+
unsigned int iov_count,
700701
gfp_t gfp_mask)
701702
{
702703
struct bio_map_data *bmd;

0 commit comments

Comments
 (0)