From patchwork Fri Jul 28 12:41:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9868677 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 18D8A60382 for ; Fri, 28 Jul 2017 12:41:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1740F288BB for ; Fri, 28 Jul 2017 12:41:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C1B0288BD; Fri, 28 Jul 2017 12:41:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C919288BB for ; Fri, 28 Jul 2017 12:41:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751948AbdG1Mln (ORCPT ); Fri, 28 Jul 2017 08:41:43 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36712 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751722AbdG1Mll (ORCPT ); Fri, 28 Jul 2017 08:41:41 -0400 Received: by mail-wm0-f66.google.com with SMTP id 184so27285584wmo.3 for ; Fri, 28 Jul 2017 05:41:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=0h19cNdVSQnCzwPA7heNCUhHBettYGe1to8OLt0tKyQ=; b=eSoELNspV8Ud3PokWg5Qy/vm0/1fySnmYx6YAFgJOqZAYOa1he5L9USEfIBK0PMiL2 nj4iIFyedlrXw/oWoVFksb6ObqczTzeL5PZERoc0bgvc9l61EF8QmrsDcgtEdZgo6FWj 8qGUc2/8W3K3qNJT7gj3l3ajJ98zFl6kIeqrvKVq6UAF2p80ZwsTpqUr5jEBEk+8Te8c BRXCFzw7cuQjConrcJksroSh6/PAfgU4afdvAQEU2kiSmLZnJRCHCNj1j2LoG6fkI1Yx pQfGtDe4Tz/cqhLcrY14QxBdVfwQ+DHkykc/lLSUUqQ3hpASnR8mDhz8Q98N0ETajKUD M6jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=0h19cNdVSQnCzwPA7heNCUhHBettYGe1to8OLt0tKyQ=; b=f7G27UmJUxtqPkL2+sKjMAnPqiD0Me0MZI1VQLSOVCcipEN/8qjjpj5/K6nXEeBK6Z cNVbtugy1ImpV/5NKXNRcC97X9F057ywTcMuTjd3Q3ULib0TzCgnoa7xUS0ImyaJzUEf rg8z2r/WflBtLEJNbwy1F4hMsPHDRRONIYoAjpmQBpZSO7TkO59Ppg6a605HGrjXqkmg n6KcL9qI+LsRUlUzalXcdVCvFe+U2IGHNKPLCXzhCYAxJFI8/aoPCWN0jhi+5OF4ZnRS DjNOq40aRq+CZxBpFH4WuTmJGohpRqO1mKiUTHYsQQbAS6CHx7HmVc7+flvpQnbjBHSC jAmA== X-Gm-Message-State: AIVw1121WLCLtFIcYL7C1cvT31apwwjfTV2BxVWIxsVYFyaGEccvAwZU O7cpMcCdEshXwPEDoPo= X-Received: by 10.28.48.214 with SMTP id w205mr5435565wmw.0.1501245699707; Fri, 28 Jul 2017 05:41:39 -0700 (PDT) Received: from orange.brq.redhat.com. (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id c13sm8263773wrc.7.2017.07.28.05.41.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Jul 2017 05:41:39 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 1/6] libceph: make encode_request_*() work with r_mempool requests Date: Fri, 28 Jul 2017 14:41:25 +0200 Message-Id: <1501245690-2362-2-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1501245690-2362-1-git-send-email-idryomov@gmail.com> References: <1501245690-2362-1-git-send-email-idryomov@gmail.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Messages allocated out of ceph_msgpool have a fixed front length (pool->front_len). Asserting that the entire front has been filled while encoding is thus wrong. Fixes: 8cb441c0545d ("libceph: MOSDOp v8 encoding (actual spgid + full hash)") Reported-by: "Yan, Zheng" Signed-off-by: Ilya Dryomov Reviewed-by: "Yan, Zheng" --- net/ceph/osd_client.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 901bb8221366..b5f016cb9569 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -1918,10 +1918,12 @@ static void encode_request_partial(struct ceph_osd_request *req, } ceph_encode_32(&p, req->r_attempts); /* retry_attempt */ - BUG_ON(p != end - 8); /* space for features */ + BUG_ON(p > end - 8); /* space for features */ msg->hdr.version = cpu_to_le16(8); /* MOSDOp v8 */ /* front_len is finalized in encode_request_finish() */ + msg->front.iov_len = p - msg->front.iov_base; + msg->hdr.front_len = cpu_to_le32(msg->front.iov_len); msg->hdr.data_len = cpu_to_le32(data_len); /* * The header "data_off" is a hint to the receiver allowing it @@ -1937,11 +1939,12 @@ static void encode_request_partial(struct ceph_osd_request *req, static void encode_request_finish(struct ceph_msg *msg) { void *p = msg->front.iov_base; + void *const partial_end = p + msg->front.iov_len; void *const end = p + msg->front_alloc_len; if (CEPH_HAVE_FEATURE(msg->con->peer_features, RESEND_ON_SPLIT)) { /* luminous OSD -- encode features and be done */ - p = end - 8; + p = partial_end; ceph_encode_64(&p, msg->con->peer_features); } else { struct { @@ -1984,7 +1987,7 @@ static void encode_request_finish(struct ceph_msg *msg) oid_len = p - oid; tail = p; - tail_len = (end - p) - 8; + tail_len = partial_end - p; p = msg->front.iov_base; ceph_encode_copy(&p, &head.client_inc, sizeof(head.client_inc));