* [PATCH 1/2] 9p: fix error handling in v9fs_file_do_lock
@ 2014-12-29 13:00 Kirill A. Shutemov
2014-12-29 13:00 ` [PATCH 2/2] 9p: do not crash on unknown lock status code Kirill A. Shutemov
0 siblings, 1 reply; 3+ messages in thread
From: Kirill A. Shutemov @ 2014-12-29 13:00 UTC (permalink / raw)
To: Eric Van Hensbergen, Ron Minnich, Latchesar Ionkov
Cc: v9fs-developer, linux-fsdevel, Kirill A. Shutemov
p9_client_lock_dotl() doesn't set status if p9_client_rpc() fails.
It can lead to 'default:' case in switch below and kernel crashes.
[ 17.965643] ------------[ cut here ]------------
[ 17.965646] kernel BUG at /home/kas/git/public/linux-next/fs/9p/vfs_file.c:220!
[ 17.965651] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC
[ 17.965657] Dumping ftrace buffer:
[ 17.965690] (ftrace buffer empty)
[ 17.965696] Modules linked in:
[ 17.965699] CPU: 11 PID: 197 Comm: trinity-c22 Not tainted 3.19.0-rc1-next-20141226-00038-g0cd9dce957f9-dirty #379
[ 17.965700] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.7.5.1-0-g8936dbb-20141113_115728-nilsson.home.kraxel.org 04/01/2014
[ 17.965702] task: ffff880476e2bfc0 ti: ffff880476eac000 task.ti: ffff880476eac000
[ 17.965713] RIP: 0010:[<ffffffff8139cf98>] [<ffffffff8139cf98>] v9fs_file_do_lock+0x168/0x1b0
[ 17.965714] warning: process `trinity-c12' used the obsolete bdflush system call
[ 17.965716] RSP: 0000:ffff880476eafea8 EFLAGS: 00010286
[ 17.965716] Fix your initscripts?
[ 17.965718] RAX: 00000000000000ff RBX: 0000000000000006 RCX: 0000000000000001
[ 17.965720] RDX: ffff880476e2bfc0 RSI: 0000000000000000 RDI: ffffffff81e47c20
[ 17.965721] RBP: ffff880476eafef8 R08: 0000000000000035 R09: 0000000000000005
[ 17.965722] R10: 0000000000000000 R11: 0000000000000001 R12: ffff88047c081730
[ 17.965723] R13: ffff88047b920000 R14: ffff8800035de4c0 R15: 00007fd277f54690
[ 17.965724] FS: 00007fd277f54700(0000) GS:ffff880484600000(0000) knlGS:0000000000000000
[ 17.965725] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 17.965729] CR2: 00007fd277e4e044 CR3: 0000000476e6e000 CR4: 00000000001406e0
[ 17.965730] Stack:
[ 17.965734] ffff8800035de4c0 0000000000000000 0000000000000000 0000000000000000
[ 17.965737] 00000000000000c5 ffff88047c708884 ffff88047b920000 ffff8800035de4c0
[ 17.965740] 0000000000000006 ffff88007ad68c98 ffff880476eaff38 ffffffff8139d0b6
[ 17.965742] Call Trace:
[ 17.965749] [<ffffffff8139d0b6>] v9fs_file_flock_dotl+0xd6/0xf0
[ 17.965756] [<ffffffff81216133>] SyS_flock+0xf3/0x190
[ 17.965762] [<ffffffff818607a9>] ia32_do_call+0x13/0x13
[ 17.965812] Code: 41 5c 41 5d 41 5e 5d c3 0f 1f 00 c6 45 b8 02 e9 2a ff ff ff 0f 1f 80 00 00 00 00 c6 45 b8 01 e9 1a ff ff ff 0f 1f 80 00 00 00 00 <0f> 0b 66 0f 1f 44 00 00 0f b6 45 b7 3c 01 75 90 b8 f5 ff ff ff
[ 17.965815] RIP [<ffffffff8139cf98>] v9fs_file_do_lock+0x168/0x1b0
[ 17.965816] RSP <ffff880476eafea8>
[ 17.965824] ---[ end trace 1cfc767bf06625a1 ]---
Let's bypass the switch if p9_client_lock_dotl() fails.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
fs/9p/vfs_file.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index b40133796b87..8d29e1e03dfa 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -194,7 +194,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
for (;;) {
res = p9_client_lock_dotl(fid, &flock, &status);
if (res < 0)
- break;
+ goto out_unlock;
if (status != P9_LOCK_BLOCKED)
break;
@@ -220,6 +220,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
BUG();
}
+out_unlock:
/*
* incase server returned error for lock request, revert
* it locally
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] 9p: do not crash on unknown lock status code
2014-12-29 13:00 [PATCH 1/2] 9p: fix error handling in v9fs_file_do_lock Kirill A. Shutemov
@ 2014-12-29 13:00 ` Kirill A. Shutemov
2015-01-06 12:14 ` [V9fs-developer] " Dominique Martinet
0 siblings, 1 reply; 3+ messages in thread
From: Kirill A. Shutemov @ 2014-12-29 13:00 UTC (permalink / raw)
To: Eric Van Hensbergen, Ron Minnich, Latchesar Ionkov
Cc: v9fs-developer, linux-fsdevel, Kirill A. Shutemov
Current 9p implementation will crash whole system if sees unkown lock
status code. It's trivial target for DOS: 9p server can produce such
code easily.
Let's fallback more gracefully: warning in dmesg + -ENOLCK.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
fs/9p/vfs_file.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 8d29e1e03dfa..0db033e698eb 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -212,12 +212,13 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
case P9_LOCK_BLOCKED:
res = -EAGAIN;
break;
+ default:
+ WARN_ONCE(1, "unknown lock status clode: %d\n", status);
+ /* fallthough */
case P9_LOCK_ERROR:
case P9_LOCK_GRACE:
res = -ENOLCK;
break;
- default:
- BUG();
}
out_unlock:
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [V9fs-developer] [PATCH 2/2] 9p: do not crash on unknown lock status code
2014-12-29 13:00 ` [PATCH 2/2] 9p: do not crash on unknown lock status code Kirill A. Shutemov
@ 2015-01-06 12:14 ` Dominique Martinet
0 siblings, 0 replies; 3+ messages in thread
From: Dominique Martinet @ 2015-01-06 12:14 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: Eric Van Hensbergen, Ron Minnich, Latchesar Ionkov, linux-fsdevel,
v9fs-developer
Hi,
Kirill A. Shutemov wrote on Mon, Dec 29, 2014 at 03:00:18PM +0200:
> p9_client_lock_dotl() doesn't set status if p9_client_rpc() fails.
> It can lead to 'default:' case in switch below and kernel crashes.
>
> [ 17.965643] ------------[ cut here ]------------
> ...
> [ 17.965824] ---[ end trace 1cfc767bf06625a1 ]---
>
> Let's bypass the switch if p9_client_lock_dotl() fails.
Kirill A. Shutemov wrote on Mon, Dec 29, 2014 at 03:00:19PM +0200:
> Current 9p implementation will crash whole system if sees unkown lock
> status code. It's trivial target for DOS: 9p server can produce such
> code easily.
>
> Let's fallback more gracefully: warning in dmesg + -ENOLCK.
Both patches look good to me, for what it's worth.
There's alot of work waiting if we want to protect ourselves from
malicious servers, but it's all good to take :)
--
Dominique Martinet,
CEA
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-06 12:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-29 13:00 [PATCH 1/2] 9p: fix error handling in v9fs_file_do_lock Kirill A. Shutemov
2014-12-29 13:00 ` [PATCH 2/2] 9p: do not crash on unknown lock status code Kirill A. Shutemov
2015-01-06 12:14 ` [V9fs-developer] " Dominique Martinet
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).