* [PATCH 1/1] pnfs-submit: prevent bad CB_LAYOUTRECALL from crashing client
@ 2010-11-15 20:20 Fred Isaman
2010-11-17 17:27 ` Benny Halevy
0 siblings, 1 reply; 2+ messages in thread
From: Fred Isaman @ 2010-11-15 20:20 UTC (permalink / raw)
To: linux-nfs
An incorrect recall type sent by the server should result in
the client returning BADXDR, not crashing the client.
Signed-off-by: Fred Isaman <iisaman@netapp.com>
---
fs/nfs/callback_proc.c | 3 +++
fs/nfs/callback_xdr.c | 5 ++++-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index b4c68e9..2274b6f 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -139,6 +139,9 @@ _recall_matches_lget(struct pnfs_cb_lrecall_info *cb_info,
return (ino == cb_info->pcl_ino) &&
should_free_lseg(range, &cb_args->cbl_range);
default:
+ /* Should never hit here, as decode_layoutrecall_args()
+ * will verify cb_info from server.
+ */
BUG();
}
}
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index a77877c..2e1a33b 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -246,7 +246,7 @@ static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp,
args->cbl_layoutchanged = ntohl(*p++);
args->cbl_recall_type = ntohl(*p++);
- if (likely(args->cbl_recall_type == RETURN_FILE)) {
+ if (args->cbl_recall_type == RETURN_FILE) {
args->cbl_range.iomode = iomode;
status = decode_fh(xdr, &args->cbl_fh);
if (unlikely(status != 0))
@@ -270,6 +270,9 @@ static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp,
}
p = xdr_decode_hyper(p, &args->cbl_fsid.major);
p = xdr_decode_hyper(p, &args->cbl_fsid.minor);
+ } else if (args->cbl_recall_type != RETURN_ALL) {
+ status = htonl(NFS4ERR_BADXDR);
+ goto out;
}
dprintk("%s: ltype 0x%x iomode %d changed %d recall_type %d\n",
__func__,
--
1.7.2.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] pnfs-submit: prevent bad CB_LAYOUTRECALL from crashing client
2010-11-15 20:20 [PATCH 1/1] pnfs-submit: prevent bad CB_LAYOUTRECALL from crashing client Fred Isaman
@ 2010-11-17 17:27 ` Benny Halevy
0 siblings, 0 replies; 2+ messages in thread
From: Benny Halevy @ 2010-11-17 17:27 UTC (permalink / raw)
To: Fred Isaman; +Cc: linux-nfs
Thanks! Merged in pnfs-all-2.6.37-rc2-2010-11-17
Benny
On 2010-11-15 22:20, Fred Isaman wrote:
> An incorrect recall type sent by the server should result in
> the client returning BADXDR, not crashing the client.
>
> Signed-off-by: Fred Isaman <iisaman@netapp.com>
> ---
> fs/nfs/callback_proc.c | 3 +++
> fs/nfs/callback_xdr.c | 5 ++++-
> 2 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
> index b4c68e9..2274b6f 100644
> --- a/fs/nfs/callback_proc.c
> +++ b/fs/nfs/callback_proc.c
> @@ -139,6 +139,9 @@ _recall_matches_lget(struct pnfs_cb_lrecall_info *cb_info,
> return (ino == cb_info->pcl_ino) &&
> should_free_lseg(range, &cb_args->cbl_range);
> default:
> + /* Should never hit here, as decode_layoutrecall_args()
> + * will verify cb_info from server.
> + */
> BUG();
> }
> }
> diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
> index a77877c..2e1a33b 100644
> --- a/fs/nfs/callback_xdr.c
> +++ b/fs/nfs/callback_xdr.c
> @@ -246,7 +246,7 @@ static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp,
> args->cbl_layoutchanged = ntohl(*p++);
> args->cbl_recall_type = ntohl(*p++);
>
> - if (likely(args->cbl_recall_type == RETURN_FILE)) {
> + if (args->cbl_recall_type == RETURN_FILE) {
> args->cbl_range.iomode = iomode;
> status = decode_fh(xdr, &args->cbl_fh);
> if (unlikely(status != 0))
> @@ -270,6 +270,9 @@ static __be32 decode_layoutrecall_args(struct svc_rqst *rqstp,
> }
> p = xdr_decode_hyper(p, &args->cbl_fsid.major);
> p = xdr_decode_hyper(p, &args->cbl_fsid.minor);
> + } else if (args->cbl_recall_type != RETURN_ALL) {
> + status = htonl(NFS4ERR_BADXDR);
> + goto out;
> }
> dprintk("%s: ltype 0x%x iomode %d changed %d recall_type %d\n",
> __func__,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-17 17:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-15 20:20 [PATCH 1/1] pnfs-submit: prevent bad CB_LAYOUTRECALL from crashing client Fred Isaman
2010-11-17 17:27 ` Benny Halevy
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).