tangled
alpha
login
or
join now
tjh.dev
/
kernel
1
fork
atom
Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1
fork
atom
overview
issues
pulls
pipelines
Merge branches 'misc.misc' and 'work.iov_iter' into for-linus
Al Viro
7 years ago
e4f2283c
4addd264
+74
-47
5 changed files
expand all
collapse all
unified
split
fs
aio.c
exportfs
expfs.c
sysv
inode.c
lib
iov_iter.c
scripts
selinux
genheaders
genheaders.c
+1
fs/aio.c
reviewed
···
1436
1436
ret = ioprio_check_cap(iocb->aio_reqprio);
1437
1437
if (ret) {
1438
1438
pr_debug("aio ioprio check cap error: %d\n", ret);
1439
1439
+
fput(req->ki_filp);
1439
1440
return ret;
1440
1441
}
1441
1442
+2
-1
fs/exportfs/expfs.c
reviewed
···
77
77
struct dentry *parent = dget_parent(dentry);
78
78
79
79
dput(dentry);
80
80
-
if (IS_ROOT(dentry)) {
80
80
+
if (dentry == parent) {
81
81
dput(parent);
82
82
return false;
83
83
}
···
147
147
tmp = lookup_one_len_unlocked(nbuf, parent, strlen(nbuf));
148
148
if (IS_ERR(tmp)) {
149
149
dprintk("%s: lookup failed: %d\n", __func__, PTR_ERR(tmp));
150
150
+
err = PTR_ERR(tmp);
150
151
goto out_err;
151
152
}
152
153
if (tmp != dentry) {
+1
-1
fs/sysv/inode.c
reviewed
···
275
275
}
276
276
}
277
277
brelse(bh);
278
278
-
return 0;
278
278
+
return err;
279
279
}
280
280
281
281
int sysv_write_inode(struct inode *inode, struct writeback_control *wbc)
+61
-25
lib/iov_iter.c
reviewed
···
560
560
return bytes;
561
561
}
562
562
563
563
+
static __wsum csum_and_memcpy(void *to, const void *from, size_t len,
564
564
+
__wsum sum, size_t off)
565
565
+
{
566
566
+
__wsum next = csum_partial_copy_nocheck(from, to, len, 0);
567
567
+
return csum_block_add(sum, next, off);
568
568
+
}
569
569
+
570
570
+
static size_t csum_and_copy_to_pipe_iter(const void *addr, size_t bytes,
571
571
+
__wsum *csum, struct iov_iter *i)
572
572
+
{
573
573
+
struct pipe_inode_info *pipe = i->pipe;
574
574
+
size_t n, r;
575
575
+
size_t off = 0;
576
576
+
__wsum sum = *csum;
577
577
+
int idx;
578
578
+
579
579
+
if (!sanity(i))
580
580
+
return 0;
581
581
+
582
582
+
bytes = n = push_pipe(i, bytes, &idx, &r);
583
583
+
if (unlikely(!n))
584
584
+
return 0;
585
585
+
for ( ; n; idx = next_idx(idx, pipe), r = 0) {
586
586
+
size_t chunk = min_t(size_t, n, PAGE_SIZE - r);
587
587
+
char *p = kmap_atomic(pipe->bufs[idx].page);
588
588
+
sum = csum_and_memcpy(p + r, addr, chunk, sum, off);
589
589
+
kunmap_atomic(p);
590
590
+
i->idx = idx;
591
591
+
i->iov_offset = r + chunk;
592
592
+
n -= chunk;
593
593
+
off += chunk;
594
594
+
addr += chunk;
595
595
+
}
596
596
+
i->count -= bytes;
597
597
+
*csum = sum;
598
598
+
return bytes;
599
599
+
}
600
600
+
563
601
size_t _copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i)
564
602
{
565
603
const char *from = addr;
···
1406
1368
err ? v.iov_len : 0;
1407
1369
}), ({
1408
1370
char *p = kmap_atomic(v.bv_page);
1409
1409
-
next = csum_partial_copy_nocheck(p + v.bv_offset,
1410
1410
-
(to += v.bv_len) - v.bv_len,
1411
1411
-
v.bv_len, 0);
1371
1371
+
sum = csum_and_memcpy((to += v.bv_len) - v.bv_len,
1372
1372
+
p + v.bv_offset, v.bv_len,
1373
1373
+
sum, off);
1412
1374
kunmap_atomic(p);
1413
1413
-
sum = csum_block_add(sum, next, off);
1414
1375
off += v.bv_len;
1415
1376
}),({
1416
1416
-
next = csum_partial_copy_nocheck(v.iov_base,
1417
1417
-
(to += v.iov_len) - v.iov_len,
1418
1418
-
v.iov_len, 0);
1419
1419
-
sum = csum_block_add(sum, next, off);
1377
1377
+
sum = csum_and_memcpy((to += v.iov_len) - v.iov_len,
1378
1378
+
v.iov_base, v.iov_len,
1379
1379
+
sum, off);
1420
1380
off += v.iov_len;
1421
1381
})
1422
1382
)
···
1448
1412
0;
1449
1413
}), ({
1450
1414
char *p = kmap_atomic(v.bv_page);
1451
1451
-
next = csum_partial_copy_nocheck(p + v.bv_offset,
1452
1452
-
(to += v.bv_len) - v.bv_len,
1453
1453
-
v.bv_len, 0);
1415
1415
+
sum = csum_and_memcpy((to += v.bv_len) - v.bv_len,
1416
1416
+
p + v.bv_offset, v.bv_len,
1417
1417
+
sum, off);
1454
1418
kunmap_atomic(p);
1455
1455
-
sum = csum_block_add(sum, next, off);
1456
1419
off += v.bv_len;
1457
1420
}),({
1458
1458
-
next = csum_partial_copy_nocheck(v.iov_base,
1459
1459
-
(to += v.iov_len) - v.iov_len,
1460
1460
-
v.iov_len, 0);
1461
1461
-
sum = csum_block_add(sum, next, off);
1421
1421
+
sum = csum_and_memcpy((to += v.iov_len) - v.iov_len,
1422
1422
+
v.iov_base, v.iov_len,
1423
1423
+
sum, off);
1462
1424
off += v.iov_len;
1463
1425
})
1464
1426
)
···
1472
1438
const char *from = addr;
1473
1439
__wsum sum, next;
1474
1440
size_t off = 0;
1441
1441
+
1442
1442
+
if (unlikely(iov_iter_is_pipe(i)))
1443
1443
+
return csum_and_copy_to_pipe_iter(addr, bytes, csum, i);
1444
1444
+
1475
1445
sum = *csum;
1476
1476
-
if (unlikely(iov_iter_is_pipe(i) || iov_iter_is_discard(i))) {
1446
1446
+
if (unlikely(iov_iter_is_discard(i))) {
1477
1447
WARN_ON(1); /* for now */
1478
1448
return 0;
1479
1449
}
···
1493
1455
err ? v.iov_len : 0;
1494
1456
}), ({
1495
1457
char *p = kmap_atomic(v.bv_page);
1496
1496
-
next = csum_partial_copy_nocheck((from += v.bv_len) - v.bv_len,
1497
1497
-
p + v.bv_offset,
1498
1498
-
v.bv_len, 0);
1458
1458
+
sum = csum_and_memcpy(p + v.bv_offset,
1459
1459
+
(from += v.bv_len) - v.bv_len,
1460
1460
+
v.bv_len, sum, off);
1499
1461
kunmap_atomic(p);
1500
1500
-
sum = csum_block_add(sum, next, off);
1501
1462
off += v.bv_len;
1502
1463
}),({
1503
1503
-
next = csum_partial_copy_nocheck((from += v.iov_len) - v.iov_len,
1504
1504
-
v.iov_base,
1505
1505
-
v.iov_len, 0);
1506
1506
-
sum = csum_block_add(sum, next, off);
1464
1464
+
sum = csum_and_memcpy(v.iov_base,
1465
1465
+
(from += v.iov_len) - v.iov_len,
1466
1466
+
v.iov_len, sum, off);
1507
1467
off += v.iov_len;
1508
1468
})
1509
1469
)
+9
-20
scripts/selinux/genheaders/genheaders.c
reviewed
···
19
19
#include "classmap.h"
20
20
#include "initial_sid_to_string.h"
21
21
22
22
-
#define max(x, y) (((int)(x) > (int)(y)) ? x : y)
23
23
-
24
22
const char *progname;
25
23
26
24
static void usage(void)
···
44
46
45
47
int main(int argc, char *argv[])
46
48
{
47
47
-
int i, j, k;
49
49
+
int i, j;
48
50
int isids_len;
49
51
FILE *fout;
50
50
-
const char *needle = "SOCKET";
51
51
-
char *substr;
52
52
53
53
progname = argv[0];
54
54
···
76
80
77
81
for (i = 0; secclass_map[i].name; i++) {
78
82
struct security_class_mapping *map = &secclass_map[i];
79
79
-
fprintf(fout, "#define SECCLASS_%s", map->name);
80
80
-
for (j = 0; j < max(1, 40 - strlen(map->name)); j++)
81
81
-
fprintf(fout, " ");
82
82
-
fprintf(fout, "%2d\n", i+1);
83
83
+
fprintf(fout, "#define SECCLASS_%-39s %2d\n", map->name, i+1);
83
84
}
84
85
85
86
fprintf(fout, "\n");
86
87
87
88
for (i = 1; i < isids_len; i++) {
88
89
const char *s = initial_sid_to_string[i];
89
89
-
fprintf(fout, "#define SECINITSID_%s", s);
90
90
-
for (j = 0; j < max(1, 40 - strlen(s)); j++)
91
91
-
fprintf(fout, " ");
92
92
-
fprintf(fout, "%2d\n", i);
90
90
+
fprintf(fout, "#define SECINITSID_%-39s %2d\n", s, i);
93
91
}
94
92
fprintf(fout, "\n#define SECINITSID_NUM %d\n", i-1);
95
93
fprintf(fout, "\nstatic inline bool security_is_socket_class(u16 kern_tclass)\n");
···
91
101
fprintf(fout, "\tbool sock = false;\n\n");
92
102
fprintf(fout, "\tswitch (kern_tclass) {\n");
93
103
for (i = 0; secclass_map[i].name; i++) {
104
104
+
static char s[] = "SOCKET";
94
105
struct security_class_mapping *map = &secclass_map[i];
95
95
-
substr = strstr(map->name, needle);
96
96
-
if (substr && strcmp(substr, needle) == 0)
106
106
+
int len = strlen(map->name), l = sizeof(s) - 1;
107
107
+
if (len >= l && memcmp(map->name + len - l, s, l) == 0)
97
108
fprintf(fout, "\tcase SECCLASS_%s:\n", map->name);
98
109
}
99
110
fprintf(fout, "\t\tsock = true;\n");
···
120
129
121
130
for (i = 0; secclass_map[i].name; i++) {
122
131
struct security_class_mapping *map = &secclass_map[i];
132
132
+
int len = strlen(map->name);
123
133
for (j = 0; map->perms[j]; j++) {
124
134
if (j >= 32) {
125
135
fprintf(stderr, "Too many permissions to fit into an access vector at (%s, %s).\n",
126
136
map->name, map->perms[j]);
127
137
exit(5);
128
138
}
129
129
-
fprintf(fout, "#define %s__%s", map->name,
130
130
-
map->perms[j]);
131
131
-
for (k = 0; k < max(1, 40 - strlen(map->name) - strlen(map->perms[j])); k++)
132
132
-
fprintf(fout, " ");
133
133
-
fprintf(fout, "0x%08xU\n", (1<<j));
139
139
+
fprintf(fout, "#define %s__%-*s 0x%08xU\n", map->name,
140
140
+
39-len, map->perms[j], 1U<<j);
134
141
}
135
142
}
136
143