From: Michal Feix <michal@feix.cz>
To: Paul.Clements@steeleye.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] nbd: Check magic before doing anything else
Date: Sun, 16 Jul 2006 15:06:45 +0200 [thread overview]
Message-ID: <44BA39E5.7060002@feix.cz> (raw)
[-- Attachment #1: Type: text/plain, Size: 274 bytes --]
We should check magic sequence in reply packet before trying to find
request with it's request handle. This also solves the problem with
"Unexpected reply" message beeing logged, when packet with invalid magic
is received.
Signed-off-by: Michal Feix <michal@feix.cz>
---
[-- Attachment #2: nbd.c.magic-check.diff --]
[-- Type: text/plain, Size: 1082 bytes --]
diff -upr 2.6.18-rc2.orig/drivers/block/nbd.c 2.6.18-rc2/drivers/block/nbd.c
--- 2.6.18-rc2.orig/drivers/block/nbd.c 2006-07-16 14:34:09.106878500 +0200
+++ 2.6.18-rc2/drivers/block/nbd.c 2006-07-16 14:48:59.000000000 +0200
@@ -300,6 +300,15 @@ static struct request *nbd_read_stat(str
lo->disk->disk_name, result);
goto harderror;
}
+
+ if (ntohl(reply.magic) != NBD_REPLY_MAGIC) {
+ printk(KERN_ERR "%s: Wrong magic (0x%lx)\n",
+ lo->disk->disk_name,
+ (unsigned long)ntohl(reply.magic));
+ result = -EPROTO;
+ goto harderror;
+ }
+
req = nbd_find_request(lo, reply.handle);
if (unlikely(IS_ERR(req))) {
result = PTR_ERR(req);
@@ -312,13 +321,6 @@ static struct request *nbd_read_stat(str
goto harderror;
}
- if (ntohl(reply.magic) != NBD_REPLY_MAGIC) {
- printk(KERN_ERR "%s: Wrong magic (0x%lx)\n",
- lo->disk->disk_name,
- (unsigned long)ntohl(reply.magic));
- result = -EPROTO;
- goto harderror;
- }
if (ntohl(reply.error)) {
printk(KERN_ERR "%s: Other side returned error (%d)\n",
lo->disk->disk_name, ntohl(reply.error));
next reply other threads:[~2006-07-16 13:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-16 13:06 Michal Feix [this message]
2006-07-17 15:30 ` [PATCH] nbd: Check magic before doing anything else Paul Clements
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44BA39E5.7060002@feix.cz \
--to=michal@feix.cz \
--cc=Paul.Clements@steeleye.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox