* [PATCH] pnfs/blocklayout: off by one in bl_map_stripe()
@ 2018-07-04 9:59 Dan Carpenter
2018-07-05 19:40 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2018-07-04 9:59 UTC (permalink / raw)
To: Trond Myklebust, Christoph Hellwig
Cc: Anna Schumaker, Philippe Ombredanne, Benjamin Coddington,
linux-nfs
"dev->nr_children" is the number of children which were parsed
successfully in bl_parse_stripe(). It could be all of them and then, in
that case, it is equal to v->stripe.volumes_count. Either way, the >
should be >= so that we don't go beyond the end of what we're supposed
to.
Fixes: 5c83746a0cf2 ("pnfs/blocklayout: in-kernel GETDEVICEINFO XDR parsing")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/fs/nfs/blocklayout/dev.c b/fs/nfs/blocklayout/dev.c
index a7efd83779d2..dec5880ac6de 100644
--- a/fs/nfs/blocklayout/dev.c
+++ b/fs/nfs/blocklayout/dev.c
@@ -204,7 +204,7 @@ static bool bl_map_stripe(struct pnfs_block_dev *dev, u64 offset,
chunk = div_u64(offset, dev->chunk_size);
div_u64_rem(chunk, dev->nr_children, &chunk_idx);
- if (chunk_idx > dev->nr_children) {
+ if (chunk_idx >= dev->nr_children) {
dprintk("%s: invalid chunk idx %d (%lld/%lld)\n",
__func__, chunk_idx, offset, dev->chunk_size);
/* error, should not happen */
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] pnfs/blocklayout: off by one in bl_map_stripe()
2018-07-04 9:59 [PATCH] pnfs/blocklayout: off by one in bl_map_stripe() Dan Carpenter
@ 2018-07-05 19:40 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2018-07-05 19:40 UTC (permalink / raw)
To: Dan Carpenter
Cc: Trond Myklebust, Christoph Hellwig, Anna Schumaker,
Philippe Ombredanne, Benjamin Coddington, linux-nfs
On Wed, Jul 04, 2018 at 12:59:58PM +0300, Dan Carpenter wrote:
> "dev->nr_children" is the number of children which were parsed
> successfully in bl_parse_stripe(). It could be all of them and then, in
> that case, it is equal to v->stripe.volumes_count. Either way, the >
> should be >= so that we don't go beyond the end of what we're supposed
> to.
>
> Fixes: 5c83746a0cf2 ("pnfs/blocklayout: in-kernel GETDEVICEINFO XDR parsing")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-05 19:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-04 9:59 [PATCH] pnfs/blocklayout: off by one in bl_map_stripe() Dan Carpenter
2018-07-05 19:40 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.