Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/6] afs: Fixes
@ 2020-06-09 16:13 David Howells
2020-06-09 16:13 ` [PATCH 1/6] afs: Fix memory leak in afs_put_sysnames() David Howells
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: David Howells @ 2020-06-09 16:13 UTC (permalink / raw)
To: linux-afs
Cc: Dave Botsch, Kees Cook, Zhihao Cheng, dhowells, linux-fsdevel,
linux-kernel
Here's a set of patches to fix some things, most of them minor.
(1) Fix a memory leak in afs_put_sysnames().
(2) Fix an oops in AFS file locking.
(3) Fix new use of BUG().
(4) Fix debugging statements containing %px.
(5) Remove afs_zero_fid as it's unused.
(6) Make afs_zap_data() static.
David
---
David Howells (1):
afs: Make afs_zap_data() static
fs/afs/dir.c | 2 +-
fs/afs/flock.c | 2 +-
fs/afs/inode.c | 2 +-
fs/afs/internal.h | 2 --
fs/afs/proc.c | 1 +
fs/afs/vl_alias.c | 5 +++--
fs/afs/yfsclient.c | 2 --
7 files changed, 7 insertions(+), 9 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/6] afs: Fix memory leak in afs_put_sysnames()
2020-06-09 16:13 [PATCH 0/6] afs: Fixes David Howells
@ 2020-06-09 16:13 ` David Howells
2020-06-09 16:13 ` [PATCH 2/6] afs: Fix file locking David Howells
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: David Howells @ 2020-06-09 16:13 UTC (permalink / raw)
To: linux-afs; +Cc: Zhihao Cheng, dhowells, linux-fsdevel, linux-kernel
From: Zhihao Cheng <chengzhihao1@huawei.com>
Fix afs_put_sysnames() to actually free the specified afs_sysnames
object after its reference count has been decreased to zero and
its contents have been released.
Fixes: 6f8880d8e681557 ("afs: Implement @sys substitution handling")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/afs/proc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index 22d00cf1913d..e817fc740ba0 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -567,6 +567,7 @@ void afs_put_sysnames(struct afs_sysnames *sysnames)
if (sysnames->subs[i] != afs_init_sysname &&
sysnames->subs[i] != sysnames->blank)
kfree(sysnames->subs[i]);
+ kfree(sysnames);
}
}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/6] afs: Fix file locking
2020-06-09 16:13 [PATCH 0/6] afs: Fixes David Howells
2020-06-09 16:13 ` [PATCH 1/6] afs: Fix memory leak in afs_put_sysnames() David Howells
@ 2020-06-09 16:13 ` David Howells
2020-06-09 16:13 ` [PATCH 3/6] afs: Fix use of BUG() David Howells
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: David Howells @ 2020-06-09 16:13 UTC (permalink / raw)
To: linux-afs; +Cc: Dave Botsch, Dave Botsch, dhowells, linux-fsdevel, linux-kernel
Fix AFS file locking to use the correct vnode pointer and remove a member
of the afs_operation struct that is never set, but it is read and followed,
causing an oops.
This can be triggered by:
flock -s /afs/example.com/foo sleep 1
when it calls the kernel to get a file lock.
Fixes: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" concept")
Reported-by: Dave Botsch <botsch@cnf.cornell.edu>
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Dave Botsch <botsch@cnf.cornell.edu>
---
fs/afs/flock.c | 2 +-
fs/afs/internal.h | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/afs/flock.c b/fs/afs/flock.c
index 70e518f7bc19..71eea2a908c7 100644
--- a/fs/afs/flock.c
+++ b/fs/afs/flock.c
@@ -71,7 +71,7 @@ static void afs_schedule_lock_extension(struct afs_vnode *vnode)
void afs_lock_op_done(struct afs_call *call)
{
struct afs_operation *op = call->op;
- struct afs_vnode *vnode = op->lock.lvnode;
+ struct afs_vnode *vnode = op->file[0].vnode;
if (call->error == 0) {
spin_lock(&vnode->lock);
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index e1621b0670cc..519ffb104616 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -795,7 +795,6 @@ struct afs_operation {
struct afs_read *req;
} fetch;
struct {
- struct afs_vnode *lvnode; /* vnode being locked */
afs_lock_type_t type;
} lock;
struct {
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/6] afs: Fix use of BUG()
2020-06-09 16:13 [PATCH 0/6] afs: Fixes David Howells
2020-06-09 16:13 ` [PATCH 1/6] afs: Fix memory leak in afs_put_sysnames() David Howells
2020-06-09 16:13 ` [PATCH 2/6] afs: Fix file locking David Howells
@ 2020-06-09 16:13 ` David Howells
2020-06-09 16:19 ` Kees Cook
2020-06-09 16:13 ` [PATCH 4/6] afs: Fix debugging statements with %px to be %p David Howells
` (2 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: David Howells @ 2020-06-09 16:13 UTC (permalink / raw)
To: linux-afs; +Cc: Kees Cook, dhowells, linux-fsdevel, linux-kernel
Fix afs_compare_addrs() to use WARN_ON(1) instead of BUG() and return 1
(ie. srx_a > srx_b).
There's no point trying to put actual error handling in as this should not
occur unless a new transport address type is allowed by AFS. And even if
it does, in this particular case, it'll just never match unknown types of
addresses. This BUG() was more of a 'you need to add a case here'
indicator.
Reported-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/afs/vl_alias.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/afs/vl_alias.c b/fs/afs/vl_alias.c
index 093895c49c21..136fc6164e00 100644
--- a/fs/afs/vl_alias.c
+++ b/fs/afs/vl_alias.c
@@ -73,7 +73,8 @@ static int afs_compare_addrs(const struct sockaddr_rxrpc *srx_a,
}
default:
- BUG();
+ WARN_ON(1);
+ diff = 1;
}
out:
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/6] afs: Fix debugging statements with %px to be %p
2020-06-09 16:13 [PATCH 0/6] afs: Fixes David Howells
` (2 preceding siblings ...)
2020-06-09 16:13 ` [PATCH 3/6] afs: Fix use of BUG() David Howells
@ 2020-06-09 16:13 ` David Howells
2020-06-09 16:18 ` Kees Cook
2020-06-09 17:08 ` Marc Dionne
2020-06-09 16:13 ` [PATCH 5/6] afs: Remove afs_zero_fid as it's not used David Howells
2020-06-09 16:13 ` [PATCH 6/6] afs: Make afs_zap_data() static David Howells
5 siblings, 2 replies; 10+ messages in thread
From: David Howells @ 2020-06-09 16:13 UTC (permalink / raw)
To: linux-afs; +Cc: Kees Cook, dhowells, linux-fsdevel, linux-kernel
Fix a couple of %px to be %x in debugging statements.
Fixes: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" concept")
Fixes: 8a070a964877 ("afs: Detect cell aliases 1 - Cells with root volumes")
Reported-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/afs/dir.c | 2 +-
fs/afs/vl_alias.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 25cbe0aeeec5..aa1d34141ea3 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -980,7 +980,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
if (!IS_ERR_OR_NULL(inode))
fid = AFS_FS_I(inode)->fid;
- _debug("splice %px", dentry->d_inode);
+ _debug("splice %p", dentry->d_inode);
d = d_splice_alias(inode, dentry);
if (!IS_ERR_OR_NULL(d)) {
d->d_fsdata = dentry->d_fsdata;
diff --git a/fs/afs/vl_alias.c b/fs/afs/vl_alias.c
index 136fc6164e00..5082ef04e99c 100644
--- a/fs/afs/vl_alias.c
+++ b/fs/afs/vl_alias.c
@@ -28,7 +28,7 @@ static struct afs_volume *afs_sample_volume(struct afs_cell *cell, struct key *k
};
volume = afs_create_volume(&fc);
- _leave(" = %px", volume);
+ _leave(" = %p", volume);
return volume;
}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/6] afs: Remove afs_zero_fid as it's not used
2020-06-09 16:13 [PATCH 0/6] afs: Fixes David Howells
` (3 preceding siblings ...)
2020-06-09 16:13 ` [PATCH 4/6] afs: Fix debugging statements with %px to be %p David Howells
@ 2020-06-09 16:13 ` David Howells
2020-06-09 16:13 ` [PATCH 6/6] afs: Make afs_zap_data() static David Howells
5 siblings, 0 replies; 10+ messages in thread
From: David Howells @ 2020-06-09 16:13 UTC (permalink / raw)
To: linux-afs; +Cc: dhowells, linux-fsdevel, linux-kernel
Remove afs_zero_fid as it's not used.
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/afs/yfsclient.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/fs/afs/yfsclient.c b/fs/afs/yfsclient.c
index b0a6e40b4da3..52d5af5fcd44 100644
--- a/fs/afs/yfsclient.c
+++ b/fs/afs/yfsclient.c
@@ -15,8 +15,6 @@
#include "xdr_fs.h"
#include "protocol_yfs.h"
-static const struct afs_fid afs_zero_fid;
-
#define xdr_size(x) (sizeof(*x) / sizeof(__be32))
static void xdr_decode_YFSFid(const __be32 **_bp, struct afs_fid *fid)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/6] afs: Make afs_zap_data() static
2020-06-09 16:13 [PATCH 0/6] afs: Fixes David Howells
` (4 preceding siblings ...)
2020-06-09 16:13 ` [PATCH 5/6] afs: Remove afs_zero_fid as it's not used David Howells
@ 2020-06-09 16:13 ` David Howells
5 siblings, 0 replies; 10+ messages in thread
From: David Howells @ 2020-06-09 16:13 UTC (permalink / raw)
To: linux-afs; +Cc: dhowells, linux-fsdevel, linux-kernel
Make afs_zap_data() static as it's only used in the file in which it is
defined.
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/afs/inode.c | 2 +-
fs/afs/internal.h | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 7dde703df40c..cd0a0060950b 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -538,7 +538,7 @@ struct inode *afs_root_iget(struct super_block *sb, struct key *key)
* mark the data attached to an inode as obsolete due to a write on the server
* - might also want to ditch all the outstanding writes and dirty pages
*/
-void afs_zap_data(struct afs_vnode *vnode)
+static void afs_zap_data(struct afs_vnode *vnode)
{
_enter("{%llx:%llu}", vnode->fid.vid, vnode->fid.vnode);
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 519ffb104616..0c9806ef2a19 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -1069,7 +1069,6 @@ extern int afs_ilookup5_test_by_fid(struct inode *, void *);
extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool);
extern struct inode *afs_iget(struct afs_operation *, struct afs_vnode_param *);
extern struct inode *afs_root_iget(struct super_block *, struct key *);
-extern void afs_zap_data(struct afs_vnode *);
extern bool afs_check_validity(struct afs_vnode *);
extern int afs_validate(struct afs_vnode *, struct key *);
extern int afs_getattr(const struct path *, struct kstat *, u32, unsigned int);
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 4/6] afs: Fix debugging statements with %px to be %p
2020-06-09 16:13 ` [PATCH 4/6] afs: Fix debugging statements with %px to be %p David Howells
@ 2020-06-09 16:18 ` Kees Cook
2020-06-09 17:08 ` Marc Dionne
1 sibling, 0 replies; 10+ messages in thread
From: Kees Cook @ 2020-06-09 16:18 UTC (permalink / raw)
To: David Howells; +Cc: linux-afs, linux-fsdevel, linux-kernel
On Tue, Jun 09, 2020 at 05:13:33PM +0100, David Howells wrote:
> Fix a couple of %px to be %x in debugging statements.
>
> Fixes: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" concept")
> Fixes: 8a070a964877 ("afs: Detect cell aliases 1 - Cells with root volumes")
> Reported-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Thanks!
--
Kees Cook
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/6] afs: Fix use of BUG()
2020-06-09 16:13 ` [PATCH 3/6] afs: Fix use of BUG() David Howells
@ 2020-06-09 16:19 ` Kees Cook
0 siblings, 0 replies; 10+ messages in thread
From: Kees Cook @ 2020-06-09 16:19 UTC (permalink / raw)
To: David Howells; +Cc: linux-afs, linux-fsdevel, linux-kernel
On Tue, Jun 09, 2020 at 05:13:26PM +0100, David Howells wrote:
> Fix afs_compare_addrs() to use WARN_ON(1) instead of BUG() and return 1
> (ie. srx_a > srx_b).
>
> There's no point trying to put actual error handling in as this should not
> occur unless a new transport address type is allowed by AFS. And even if
> it does, in this particular case, it'll just never match unknown types of
> addresses. This BUG() was more of a 'you need to add a case here'
> indicator.
>
> Reported-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Thanks!
--
Kees Cook
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 4/6] afs: Fix debugging statements with %px to be %p
2020-06-09 16:13 ` [PATCH 4/6] afs: Fix debugging statements with %px to be %p David Howells
2020-06-09 16:18 ` Kees Cook
@ 2020-06-09 17:08 ` Marc Dionne
1 sibling, 0 replies; 10+ messages in thread
From: Marc Dionne @ 2020-06-09 17:08 UTC (permalink / raw)
To: David Howells
Cc: linux-afs, linux-fsdevel, Kees Cook, Linux Kernel Mailing List
On Tue, Jun 9, 2020 at 1:13 PM David Howells <dhowells@redhat.com> wrote:
>
> Fix a couple of %px to be %x in debugging statements.
>
Nothing critical, but as in the patch subject this should be "%px to
be %p", not %x.
Marc
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-06-09 17:09 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-09 16:13 [PATCH 0/6] afs: Fixes David Howells
2020-06-09 16:13 ` [PATCH 1/6] afs: Fix memory leak in afs_put_sysnames() David Howells
2020-06-09 16:13 ` [PATCH 2/6] afs: Fix file locking David Howells
2020-06-09 16:13 ` [PATCH 3/6] afs: Fix use of BUG() David Howells
2020-06-09 16:19 ` Kees Cook
2020-06-09 16:13 ` [PATCH 4/6] afs: Fix debugging statements with %px to be %p David Howells
2020-06-09 16:18 ` Kees Cook
2020-06-09 17:08 ` Marc Dionne
2020-06-09 16:13 ` [PATCH 5/6] afs: Remove afs_zero_fid as it's not used David Howells
2020-06-09 16:13 ` [PATCH 6/6] afs: Make afs_zap_data() static David Howells
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).