History

Merge branches 'misc.misc' and 'work.iov_iter' into for-linus

Al Viro committed 7 years ago

Commit e4f22833 parents 4addd26 a40612e f9152895 files · +74 −47Browse files

Unified · Split

5 files
  1. fs/aio.c +1 −0
  2. fs/exportfs/expfs.c +2 −1
  3. fs/sysv/inode.c +1 −1
  4. lib/iov_iter.c +61 −25
  5. scripts/selinux/genheaders/genheaders.c +9 −20
fs/aio.c+1−0
@@ -1436,6 +1436,7 @@ static int aio_prep_rw(struct kiocb *req, struct iocb *iocb) · 1435 unmodified lines
14361436 ret = ioprio_check_cap(iocb->aio_reqprio);
14371437 if (ret) {
14381438 pr_debug("aio ioprio check cap error: %d\n", ret);
1439+ fput(req->ki_filp);
14391440 return ret;
14401441 }
14411442
fs/exportfs/expfs.c+2−1
@@ -77,7 +77,7 @@ static bool dentry_connected(struct dentry *dentry) · 76 unmodified lines
7777 struct dentry *parent = dget_parent(dentry);
7878
7979 dput(dentry);
80− if (IS_ROOT(dentry)) {
80+ if (dentry == parent) {
8181 dput(parent);
8282 return false;
8383 }
@@ -147,6 +147,7 @@ static struct dentry *reconnect_one(struct vfsmount *mnt, · 63 unmodified lines
147147 tmp = lookup_one_len_unlocked(nbuf, parent, strlen(nbuf));
148148 if (IS_ERR(tmp)) {
149149 dprintk("%s: lookup failed: %d\n", __func__, PTR_ERR(tmp));
150+ err = PTR_ERR(tmp);
150151 goto out_err;
151152 }
152153 if (tmp != dentry) {
fs/sysv/inode.c+1−1
@@ -275,7 +275,7 @@ static int __sysv_write_inode(struct inode *inode, int wait) · 274 unmodified lines
275275 }
276276 }
277277 brelse(bh);
278− return 0;
278+ return err;
279279 }
280280
281281 int sysv_write_inode(struct inode *inode, struct writeback_control *wbc)
lib/iov_iter.c+61−25
@@ -560,6 +560,44 @@ static size_t copy_pipe_to_iter(const void *addr, size_t bytes, · 559 unmodified lines
560560 return bytes;
561561 }
562562
563+static __wsum csum_and_memcpy(void *to, const void *from, size_t len,
564+ __wsum sum, size_t off)
565+{
566+ __wsum next = csum_partial_copy_nocheck(from, to, len, 0);
567+ return csum_block_add(sum, next, off);
568+}
569+
570+static size_t csum_and_copy_to_pipe_iter(const void *addr, size_t bytes,
571+ __wsum *csum, struct iov_iter *i)
572+{
573+ struct pipe_inode_info *pipe = i->pipe;
574+ size_t n, r;
575+ size_t off = 0;
576+ __wsum sum = *csum;
577+ int idx;
578+
579+ if (!sanity(i))
580+ return 0;
581+
582+ bytes = n = push_pipe(i, bytes, &idx, &r);
583+ if (unlikely(!n))
584+ return 0;
585+ for ( ; n; idx = next_idx(idx, pipe), r = 0) {
586+ size_t chunk = min_t(size_t, n, PAGE_SIZE - r);
587+ char *p = kmap_atomic(pipe->bufs[idx].page);
588+ sum = csum_and_memcpy(p + r, addr, chunk, sum, off);
589+ kunmap_atomic(p);
590+ i->idx = idx;
591+ i->iov_offset = r + chunk;
592+ n -= chunk;
593+ off += chunk;
594+ addr += chunk;
595+ }
596+ i->count -= bytes;
597+ *csum = sum;
598+ return bytes;
599+}
600+
563601 size_t _copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i)
564602 {
565603 const char *from = addr;
@@ -1368,17 +1406,15 @@ size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, · 802 unmodified lines
13681406 err ? v.iov_len : 0;
13691407 }), ({
13701408 char *p = kmap_atomic(v.bv_page);
1371− next = csum_partial_copy_nocheck(p + v.bv_offset,
1372− (to += v.bv_len) - v.bv_len,
1373− v.bv_len, 0);
1409+ sum = csum_and_memcpy((to += v.bv_len) - v.bv_len,
1410+ p + v.bv_offset, v.bv_len,
1411+ sum, off);
13741412 kunmap_atomic(p);
1375− sum = csum_block_add(sum, next, off);
13761413 off += v.bv_len;
13771414 }),({
1378− next = csum_partial_copy_nocheck(v.iov_base,
1379− (to += v.iov_len) - v.iov_len,
1380− v.iov_len, 0);
1381− sum = csum_block_add(sum, next, off);
1415+ sum = csum_and_memcpy((to += v.iov_len) - v.iov_len,
1416+ v.iov_base, v.iov_len,
1417+ sum, off);
13821418 off += v.iov_len;
13831419 })
13841420 )
@@ -1412,17 +1448,15 @@ bool csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum, · 27 unmodified lines
14121448 0;
14131449 }), ({
14141450 char *p = kmap_atomic(v.bv_page);
1415− next = csum_partial_copy_nocheck(p + v.bv_offset,
1416− (to += v.bv_len) - v.bv_len,
1417− v.bv_len, 0);
1451+ sum = csum_and_memcpy((to += v.bv_len) - v.bv_len,
1452+ p + v.bv_offset, v.bv_len,
1453+ sum, off);
14181454 kunmap_atomic(p);
1419− sum = csum_block_add(sum, next, off);
14201455 off += v.bv_len;
14211456 }),({
1422− next = csum_partial_copy_nocheck(v.iov_base,
1423− (to += v.iov_len) - v.iov_len,
1424− v.iov_len, 0);
1425− sum = csum_block_add(sum, next, off);
1457+ sum = csum_and_memcpy((to += v.iov_len) - v.iov_len,
1458+ v.iov_base, v.iov_len,
1459+ sum, off);
14261460 off += v.iov_len;
14271461 })
14281462 )
@@ -1438,8 +1472,12 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, __wsum *csum, · 9 unmodified lines
14381472 const char *from = addr;
14391473 __wsum sum, next;
14401474 size_t off = 0;
1475+
1476+ if (unlikely(iov_iter_is_pipe(i)))
1477+ return csum_and_copy_to_pipe_iter(addr, bytes, csum, i);
1478+
14411479 sum = *csum;
1442− if (unlikely(iov_iter_is_pipe(i) || iov_iter_is_discard(i))) {
1480+ if (unlikely(iov_iter_is_discard(i))) {
14431481 WARN_ON(1); /* for now */
14441482 return 0;
14451483 }
@@ -1455,17 +1493,15 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, __wsum *csum, · 9 unmodified lines
14551493 err ? v.iov_len : 0;
14561494 }), ({
14571495 char *p = kmap_atomic(v.bv_page);
1458− next = csum_partial_copy_nocheck((from += v.bv_len) - v.bv_len,
1459− p + v.bv_offset,
1460− v.bv_len, 0);
1496+ sum = csum_and_memcpy(p + v.bv_offset,
1497+ (from += v.bv_len) - v.bv_len,
1498+ v.bv_len, sum, off);
14611499 kunmap_atomic(p);
1462− sum = csum_block_add(sum, next, off);
14631500 off += v.bv_len;
14641501 }),({
1465− next = csum_partial_copy_nocheck((from += v.iov_len) - v.iov_len,
1466− v.iov_base,
1467− v.iov_len, 0);
1468− sum = csum_block_add(sum, next, off);
1502+ sum = csum_and_memcpy(v.iov_base,
1503+ (from += v.iov_len) - v.iov_len,
1504+ v.iov_len, sum, off);
14691505 off += v.iov_len;
14701506 })
14711507 )
scripts/selinux/genheaders/genheaders.c+9−20
@@ -19,8 +19,6 @@ struct security_class_mapping { · 18 unmodified lines
1919 #include "classmap.h"
2020 #include "initial_sid_to_string.h"
2121
22−#define max(x, y) (((int)(x) > (int)(y)) ? x : y)
23−
2422 const char *progname;
2523
2624 static void usage(void)
@@ -46,11 +44,9 @@ static char *stoupperx(const char *s) · 19 unmodified lines
4644
4745 int main(int argc, char *argv[])
4846 {
49− int i, j, k;
47+ int i, j;
5048 int isids_len;
5149 FILE *fout;
52− const char *needle = "SOCKET";
53− char *substr;
5450
5551 progname = argv[0];
5652
@@ -80,20 +76,14 @@ int main(int argc, char *argv[]) · 23 unmodified lines
8076
8177 for (i = 0; secclass_map[i].name; i++) {
8278 struct security_class_mapping *map = &secclass_map[i];
83− fprintf(fout, "#define SECCLASS_%s", map->name);
84− for (j = 0; j < max(1, 40 - strlen(map->name)); j++)
85− fprintf(fout, " ");
86− fprintf(fout, "%2d\n", i+1);
79+ fprintf(fout, "#define SECCLASS_%-39s %2d\n", map->name, i+1);
8780 }
8881
8982 fprintf(fout, "\n");
9083
9184 for (i = 1; i < isids_len; i++) {
9285 const char *s = initial_sid_to_string[i];
93− fprintf(fout, "#define SECINITSID_%s", s);
94− for (j = 0; j < max(1, 40 - strlen(s)); j++)
95− fprintf(fout, " ");
96− fprintf(fout, "%2d\n", i);
86+ fprintf(fout, "#define SECINITSID_%-39s %2d\n", s, i);
9787 }
9888 fprintf(fout, "\n#define SECINITSID_NUM %d\n", i-1);
9989 fprintf(fout, "\nstatic inline bool security_is_socket_class(u16 kern_tclass)\n");
@@ -101,9 +91,10 @@ int main(int argc, char *argv[]) · 1 unmodified line
10191 fprintf(fout, "\tbool sock = false;\n\n");
10292 fprintf(fout, "\tswitch (kern_tclass) {\n");
10393 for (i = 0; secclass_map[i].name; i++) {
94+ static char s[] = "SOCKET";
10495 struct security_class_mapping *map = &secclass_map[i];
105− substr = strstr(map->name, needle);
106− if (substr && strcmp(substr, needle) == 0)
96+ int len = strlen(map->name), l = sizeof(s) - 1;
97+ if (len >= l && memcmp(map->name + len - l, s, l) == 0)
10798 fprintf(fout, "\tcase SECCLASS_%s:\n", map->name);
10899 }
109100 fprintf(fout, "\t\tsock = true;\n");
@@ -129,17 +120,15 @@ int main(int argc, char *argv[]) · 19 unmodified lines
129120
130121 for (i = 0; secclass_map[i].name; i++) {
131122 struct security_class_mapping *map = &secclass_map[i];
123+ int len = strlen(map->name);
132124 for (j = 0; map->perms[j]; j++) {
133125 if (j >= 32) {
134126 fprintf(stderr, "Too many permissions to fit into an access vector at (%s, %s).\n",
135127 map->name, map->perms[j]);
136128 exit(5);
137129 }
138− fprintf(fout, "#define %s__%s", map->name,
139− map->perms[j]);
140− for (k = 0; k < max(1, 40 - strlen(map->name) - strlen(map->perms[j])); k++)
141− fprintf(fout, " ");
142− fprintf(fout, "0x%08xU\n", (1<<j));
130+ fprintf(fout, "#define %s__%-*s 0x%08xU\n", map->name,
131+ 39-len, map->perms[j], 1U<<j);
143132 }
144133 }
145134