Skip to content

Commit 0710f3f

Browse files
committed
Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull misc final vfs updates from Al Viro: "A few unrelated patches that got beating in -next. Everything else will have to go into the next window ;-/" * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: hfs: fix hfs_readdir() selftest for default_file_splice_read() infoleak 9p: constify ->d_name handling
2 parents a3b4924 + eec1153 commit 0710f3f

File tree

11 files changed

+67
-43
lines changed

11 files changed

+67
-43
lines changed

fs/9p/fid.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any)
9191
* dentry names.
9292
*/
9393
static int build_path_from_dentry(struct v9fs_session_info *v9ses,
94-
struct dentry *dentry, char ***names)
94+
struct dentry *dentry, const unsigned char ***names)
9595
{
9696
int n = 0, i;
97-
char **wnames;
97+
const unsigned char **wnames;
9898
struct dentry *ds;
9999

100100
for (ds = dentry; !IS_ROOT(ds); ds = ds->d_parent)
@@ -105,7 +105,7 @@ static int build_path_from_dentry(struct v9fs_session_info *v9ses,
105105
goto err_out;
106106

107107
for (ds = dentry, i = (n-1); i >= 0; i--, ds = ds->d_parent)
108-
wnames[i] = (char *)ds->d_name.name;
108+
wnames[i] = ds->d_name.name;
109109

110110
*names = wnames;
111111
return n;
@@ -117,7 +117,7 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
117117
kuid_t uid, int any)
118118
{
119119
struct dentry *ds;
120-
char **wnames, *uname;
120+
const unsigned char **wnames, *uname;
121121
int i, n, l, clone, access;
122122
struct v9fs_session_info *v9ses;
123123
struct p9_fid *fid, *old_fid = NULL;
@@ -137,7 +137,7 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
137137
fid = v9fs_fid_find(ds, uid, any);
138138
if (fid) {
139139
/* Found the parent fid do a lookup with that */
140-
fid = p9_client_walk(fid, 1, (char **)&dentry->d_name.name, 1);
140+
fid = p9_client_walk(fid, 1, &dentry->d_name.name, 1);
141141
goto fid_out;
142142
}
143143
up_read(&v9ses->rename_sem);

fs/9p/vfs_inode.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
643643
struct dentry *dentry, char *extension, u32 perm, u8 mode)
644644
{
645645
int err;
646-
char *name;
646+
const unsigned char *name;
647647
struct p9_fid *dfid, *ofid, *fid;
648648
struct inode *inode;
649649

@@ -652,7 +652,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
652652
err = 0;
653653
ofid = NULL;
654654
fid = NULL;
655-
name = (char *) dentry->d_name.name;
655+
name = dentry->d_name.name;
656656
dfid = v9fs_parent_fid(dentry);
657657
if (IS_ERR(dfid)) {
658658
err = PTR_ERR(dfid);
@@ -788,7 +788,7 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
788788
struct v9fs_session_info *v9ses;
789789
struct p9_fid *dfid, *fid;
790790
struct inode *inode;
791-
char *name;
791+
const unsigned char *name;
792792

793793
p9_debug(P9_DEBUG_VFS, "dir: %p dentry: (%pd) %p flags: %x\n",
794794
dir, dentry, dentry, flags);
@@ -802,7 +802,7 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
802802
if (IS_ERR(dfid))
803803
return ERR_CAST(dfid);
804804

805-
name = (char *) dentry->d_name.name;
805+
name = dentry->d_name.name;
806806
fid = p9_client_walk(dfid, 1, &name, 1);
807807
if (IS_ERR(fid)) {
808808
if (fid == ERR_PTR(-ENOENT)) {
@@ -1012,7 +1012,7 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
10121012
}
10131013
v9fs_blank_wstat(&wstat);
10141014
wstat.muid = v9ses->uname;
1015-
wstat.name = (char *) new_dentry->d_name.name;
1015+
wstat.name = new_dentry->d_name.name;
10161016
retval = p9_client_wstat(oldfid, &wstat);
10171017

10181018
clunk_newdir:

fs/9p/vfs_inode_dotl.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
244244
int err = 0;
245245
kgid_t gid;
246246
umode_t mode;
247-
char *name = NULL;
247+
const unsigned char *name = NULL;
248248
struct p9_qid qid;
249249
struct inode *inode;
250250
struct p9_fid *fid = NULL;
@@ -269,7 +269,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
269269

270270
v9ses = v9fs_inode2v9ses(dir);
271271

272-
name = (char *) dentry->d_name.name;
272+
name = dentry->d_name.name;
273273
p9_debug(P9_DEBUG_VFS, "name:%s flags:0x%x mode:0x%hx\n",
274274
name, flags, omode);
275275

@@ -385,7 +385,7 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
385385
struct v9fs_session_info *v9ses;
386386
struct p9_fid *fid = NULL, *dfid = NULL;
387387
kgid_t gid;
388-
char *name;
388+
const unsigned char *name;
389389
umode_t mode;
390390
struct inode *inode;
391391
struct p9_qid qid;
@@ -416,7 +416,7 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
416416
err);
417417
goto error;
418418
}
419-
name = (char *) dentry->d_name.name;
419+
name = dentry->d_name.name;
420420
err = p9_client_mkdir_dotl(dfid, name, mode, gid, &qid);
421421
if (err < 0)
422422
goto error;
@@ -679,14 +679,14 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
679679
{
680680
int err;
681681
kgid_t gid;
682-
char *name;
682+
const unsigned char *name;
683683
struct p9_qid qid;
684684
struct inode *inode;
685685
struct p9_fid *dfid;
686686
struct p9_fid *fid = NULL;
687687
struct v9fs_session_info *v9ses;
688688

689-
name = (char *) dentry->d_name.name;
689+
name = dentry->d_name.name;
690690
p9_debug(P9_DEBUG_VFS, "%lu,%s,%s\n", dir->i_ino, name, symname);
691691
v9ses = v9fs_inode2v9ses(dir);
692692

@@ -700,7 +700,7 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
700700
gid = v9fs_get_fsgid_for_create(dir);
701701

702702
/* Server doesn't alter fid on TSYMLINK. Hence no need to clone it. */
703-
err = p9_client_symlink(dfid, name, (char *)symname, gid, &qid);
703+
err = p9_client_symlink(dfid, name, symname, gid, &qid);
704704

705705
if (err < 0) {
706706
p9_debug(P9_DEBUG_VFS, "p9_client_symlink failed %d\n", err);
@@ -776,7 +776,7 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
776776
if (IS_ERR(oldfid))
777777
return PTR_ERR(oldfid);
778778

779-
err = p9_client_link(dfid, oldfid, (char *)dentry->d_name.name);
779+
err = p9_client_link(dfid, oldfid, dentry->d_name.name);
780780

781781
if (err < 0) {
782782
p9_debug(P9_DEBUG_VFS, "p9_client_link failed %d\n", err);
@@ -813,7 +813,7 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
813813
{
814814
int err;
815815
kgid_t gid;
816-
char *name;
816+
const unsigned char *name;
817817
umode_t mode;
818818
struct v9fs_session_info *v9ses;
819819
struct p9_fid *fid = NULL, *dfid = NULL;
@@ -843,7 +843,7 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
843843
err);
844844
goto error;
845845
}
846-
name = (char *) dentry->d_name.name;
846+
name = dentry->d_name.name;
847847

848848
err = p9_client_mknod_dotl(dfid, name, mode, rdev, gid, &qid);
849849
if (err < 0)

fs/hfs/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static int hfs_readdir(struct file *file, struct dir_context *ctx)
169169
* Can be done after the list insertion; exclusion with
170170
* hfs_delete_cat() is provided by directory lock.
171171
*/
172-
memcpy(&rd->key, &fd.key, sizeof(struct hfs_cat_key));
172+
memcpy(&rd->key, &fd.key->cat, sizeof(struct hfs_cat_key));
173173
out:
174174
hfs_find_exit(&fd);
175175
return err;

include/net/9p/9p.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,10 @@ struct p9_wstat {
402402
u32 atime;
403403
u32 mtime;
404404
u64 length;
405-
char *name;
406-
char *uid;
407-
char *gid;
408-
char *muid;
405+
const char *name;
406+
const char *uid;
407+
const char *gid;
408+
const char *muid;
409409
char *extension; /* 9p2000.u extensions */
410410
kuid_t n_uid; /* 9p2000.u extensions */
411411
kgid_t n_gid; /* 9p2000.u extensions */

include/net/9p/client.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,16 @@ void p9_client_destroy(struct p9_client *clnt);
223223
void p9_client_disconnect(struct p9_client *clnt);
224224
void p9_client_begin_disconnect(struct p9_client *clnt);
225225
struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
226-
char *uname, kuid_t n_uname, char *aname);
226+
const char *uname, kuid_t n_uname, const char *aname);
227227
struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
228-
char **wnames, int clone);
228+
const unsigned char * const *wnames, int clone);
229229
int p9_client_open(struct p9_fid *fid, int mode);
230-
int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
230+
int p9_client_fcreate(struct p9_fid *fid, const char *name, u32 perm, int mode,
231231
char *extension);
232-
int p9_client_link(struct p9_fid *fid, struct p9_fid *oldfid, char *newname);
233-
int p9_client_symlink(struct p9_fid *fid, char *name, char *symname, kgid_t gid,
234-
struct p9_qid *qid);
235-
int p9_client_create_dotl(struct p9_fid *ofid, char *name, u32 flags, u32 mode,
232+
int p9_client_link(struct p9_fid *fid, struct p9_fid *oldfid, const char *newname);
233+
int p9_client_symlink(struct p9_fid *fid, const char *name, const char *symname,
234+
kgid_t gid, struct p9_qid *qid);
235+
int p9_client_create_dotl(struct p9_fid *ofid, const char *name, u32 flags, u32 mode,
236236
kgid_t gid, struct p9_qid *qid);
237237
int p9_client_clunk(struct p9_fid *fid);
238238
int p9_client_fsync(struct p9_fid *fid, int datasync);
@@ -250,9 +250,9 @@ int p9_client_setattr(struct p9_fid *fid, struct p9_iattr_dotl *attr);
250250
struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid,
251251
u64 request_mask);
252252

253-
int p9_client_mknod_dotl(struct p9_fid *oldfid, char *name, int mode,
253+
int p9_client_mknod_dotl(struct p9_fid *oldfid, const char *name, int mode,
254254
dev_t rdev, kgid_t gid, struct p9_qid *);
255-
int p9_client_mkdir_dotl(struct p9_fid *fid, char *name, int mode,
255+
int p9_client_mkdir_dotl(struct p9_fid *fid, const char *name, int mode,
256256
kgid_t gid, struct p9_qid *);
257257
int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status);
258258
int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *fl);

net/9p/client.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ void p9_client_begin_disconnect(struct p9_client *clnt)
11011101
EXPORT_SYMBOL(p9_client_begin_disconnect);
11021102

11031103
struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
1104-
char *uname, kuid_t n_uname, char *aname)
1104+
const char *uname, kuid_t n_uname, const char *aname)
11051105
{
11061106
int err = 0;
11071107
struct p9_req_t *req;
@@ -1149,7 +1149,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
11491149
EXPORT_SYMBOL(p9_client_attach);
11501150

11511151
struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
1152-
char **wnames, int clone)
1152+
const unsigned char * const *wnames, int clone)
11531153
{
11541154
int err;
11551155
struct p9_client *clnt;
@@ -1271,7 +1271,7 @@ int p9_client_open(struct p9_fid *fid, int mode)
12711271
}
12721272
EXPORT_SYMBOL(p9_client_open);
12731273

1274-
int p9_client_create_dotl(struct p9_fid *ofid, char *name, u32 flags, u32 mode,
1274+
int p9_client_create_dotl(struct p9_fid *ofid, const char *name, u32 flags, u32 mode,
12751275
kgid_t gid, struct p9_qid *qid)
12761276
{
12771277
int err = 0;
@@ -1316,7 +1316,7 @@ int p9_client_create_dotl(struct p9_fid *ofid, char *name, u32 flags, u32 mode,
13161316
}
13171317
EXPORT_SYMBOL(p9_client_create_dotl);
13181318

1319-
int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
1319+
int p9_client_fcreate(struct p9_fid *fid, const char *name, u32 perm, int mode,
13201320
char *extension)
13211321
{
13221322
int err;
@@ -1361,8 +1361,8 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
13611361
}
13621362
EXPORT_SYMBOL(p9_client_fcreate);
13631363

1364-
int p9_client_symlink(struct p9_fid *dfid, char *name, char *symtgt, kgid_t gid,
1365-
struct p9_qid *qid)
1364+
int p9_client_symlink(struct p9_fid *dfid, const char *name,
1365+
const char *symtgt, kgid_t gid, struct p9_qid *qid)
13661366
{
13671367
int err = 0;
13681368
struct p9_client *clnt;
@@ -1395,7 +1395,7 @@ int p9_client_symlink(struct p9_fid *dfid, char *name, char *symtgt, kgid_t gid,
13951395
}
13961396
EXPORT_SYMBOL(p9_client_symlink);
13971397

1398-
int p9_client_link(struct p9_fid *dfid, struct p9_fid *oldfid, char *newname)
1398+
int p9_client_link(struct p9_fid *dfid, struct p9_fid *oldfid, const char *newname)
13991399
{
14001400
struct p9_client *clnt;
14011401
struct p9_req_t *req;
@@ -2117,7 +2117,7 @@ int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset)
21172117
}
21182118
EXPORT_SYMBOL(p9_client_readdir);
21192119

2120-
int p9_client_mknod_dotl(struct p9_fid *fid, char *name, int mode,
2120+
int p9_client_mknod_dotl(struct p9_fid *fid, const char *name, int mode,
21212121
dev_t rdev, kgid_t gid, struct p9_qid *qid)
21222122
{
21232123
int err;
@@ -2148,7 +2148,7 @@ int p9_client_mknod_dotl(struct p9_fid *fid, char *name, int mode,
21482148
}
21492149
EXPORT_SYMBOL(p9_client_mknod_dotl);
21502150

2151-
int p9_client_mkdir_dotl(struct p9_fid *fid, char *name, int mode,
2151+
int p9_client_mkdir_dotl(struct p9_fid *fid, const char *name, int mode,
21522152
kgid_t gid, struct p9_qid *qid)
21532153
{
21542154
int err;

tools/testing/selftests/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ TARGETS += ptrace
2626
TARGETS += seccomp
2727
TARGETS += sigaltstack
2828
TARGETS += size
29+
TARGETS += splice
2930
TARGETS += static_keys
3031
TARGETS += sync
3132
TARGETS += sysctl
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
TEST_PROGS := default_file_splice_read.sh
2+
EXTRA := default_file_splice_read
3+
all: $(TEST_PROGS) $(EXTRA)
4+
5+
include ../lib.mk
6+
7+
clean:
8+
rm -fr $(TEST_PROGS) $(EXTRA)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#define _GNU_SOURCE
2+
#include <fcntl.h>
3+
4+
int main(int argc, char **argv)
5+
{
6+
splice(0, 0, 1, 0, 1<<30, 0);
7+
return 0;
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
n=`./default_file_splice_read </dev/null | wc -c`
3+
4+
test "$n" = 0 && exit 0
5+
6+
echo "default_file_splice_read broken: leaked $n"
7+
exit 1

0 commit comments

Comments
 (0)