From patchwork Wed Apr 10 22:49:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2424041 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C6099DFB79 for ; Wed, 10 Apr 2013 22:49:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937395Ab3DJWt2 (ORCPT ); Wed, 10 Apr 2013 18:49:28 -0400 Received: from mail-ia0-f169.google.com ([209.85.210.169]:56278 "EHLO mail-ia0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934682Ab3DJWt0 (ORCPT ); Wed, 10 Apr 2013 18:49:26 -0400 Received: by mail-ia0-f169.google.com with SMTP id h23so768188iae.0 for ; Wed, 10 Apr 2013 15:49:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=cEuVRyrlA6HlOR3ivFdUWSvQI2J+FtJc6xfiyGUfsJo=; b=Lx0T7949tY8yMSaUTOkR73KEoulFAG4lVC1peDir4kv8TCsWi74c9hQ3yisYS9I5rR HM/mnkdIha/K5B6DczRhP5FiMG9WakTV4dlQtpKu6PrADySr8k8TcumVqOvfk6YHtKQ+ ilA+q0kGmhXWuTuThrf8chDnla54j53UAScpFZASFJK3Jdum6ED5q9x8R/vVjNByih34 2R5Nl9Pxx1ZPP3ONzX6hM2Xx4Ur4Q7o4UqqdDJhaaxmZi7fOomrtDw3zc1t8odQGj5MZ YtndCzzKCp+9lZnb4H3W6ojDi6OWLdOM8nOKNVscWQIhBtay0iL+jEChH4FgJAROdoRf 2evA== X-Received: by 10.50.12.229 with SMTP id b5mr2763154igc.105.1365634166168; Wed, 10 Apr 2013 15:49:26 -0700 (PDT) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPS id wn10sm29295775igb.2.2013.04.10.15.49.24 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Apr 2013 15:49:25 -0700 (PDT) Message-ID: <5165EC73.5000600@inktank.com> Date: Wed, 10 Apr 2013 17:49:23 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH] rbd: do a safe list traversal in rbd_img_request_submit() X-Gm-Message-State: ALoCoQkesrKXVgSGWhXWrtuLSJZLh82rM/C2hwfCC2bBy4pvE0aqnteZvFT/kpG9RNuCRasU+UYN Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org It's possible that the reference to the object request dropped inside the loop in rbd_img_request_submit() will be the last one, in which case the content of the object pointer can't be trusted. Use a safe form of the object request list traversal to avoid problems. This resolves: http://tracker.ceph.com/issues/4705 Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) ret = rbd_obj_request_submit(osdc, obj_request); diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 3c0abe6..7eb1032 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1652,9 +1652,10 @@ static int rbd_img_request_submit(struct rbd_img_request *img_request) struct rbd_device *rbd_dev = img_request->rbd_dev; struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; struct rbd_obj_request *obj_request; + struct rbd_obj_request *next_obj_request; dout("%s: img %p\n", __func__, img_request); - for_each_obj_request(img_request, obj_request) { + for_each_obj_request_safe(img_request, obj_request, next_obj_request) { int ret;