From patchwork Wed Aug 1 19:03:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 10552835 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6793D15E2 for ; Wed, 1 Aug 2018 19:04:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6482A2BA07 for ; Wed, 1 Aug 2018 19:04:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 591CB2BACC; Wed, 1 Aug 2018 19:04:25 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,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 06F892BAC7 for ; Wed, 1 Aug 2018 19:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387611AbeHAUvf (ORCPT ); Wed, 1 Aug 2018 16:51:35 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:51307 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387528AbeHAUve (ORCPT ); Wed, 1 Aug 2018 16:51:34 -0400 Received: by mail-wm0-f67.google.com with SMTP id y2-v6so172389wma.1 for ; Wed, 01 Aug 2018 12:04:22 -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=pBaih0sE8ym1oJPYkBsRFm6iuu54DeB++aLB8sH2Sw4=; b=bIiwwM1Eqr7eNfQzUsFFHca56xdZaFM7sUgrHth95lNtzRxclj1qxLKcm1CylbFkLy weWDkOpWA3gXpIV/fnDtQJuK8NzaGNV8T2vASauOnFUDxeZZZ8uioPudFBcA1XSdO3dm nplo/Gfyjrk80N0kiy50pZBrs8w5w0azzyS+Bz6tesN4Um57OwRa8ye4PyvMKB9+cIvb AmOJ9gC9pnwo+Qh0zQuupZuphX+Vn/GiksWRUHuioLVnCCFfGP+DioasBot/K47C9go2 mOQ89N+4SAZrlqO2iJFrlBYXBnNj0wGZetLZgWdjIvOSA5aYqHPjSvD2GzuRzeHDg5v/ EHCQ== 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=pBaih0sE8ym1oJPYkBsRFm6iuu54DeB++aLB8sH2Sw4=; b=shhZyz8Mr8MNBKEk5g0B/WTC6K24zYpixmuYatLbwNWfjgx3Dpi7TlNWuHXnKgokrb ZwT0gvIrq5DTs4L1xxEJvRDxo70X9OSxdbGD+CvezKqKuuNl/XlhaW2CUOOrxgy2ScP0 zoxDsi1Gp39hySXP5bHhvYzNOv6r0y//xtr4/hqIRozXCptL5Ga6SVovpPKQDUpICi2t gvfbt11KQV2rn1fdQF0IFCA6JtkI46S0WUWLeGLAw+/yhJm4nDZ0VJHrXJCUleb2AmQ5 BHtxzT5heoROOV15lcARqnpLv8TtoQtPH1zTFM/8z2INquPxBlLqeBhE4mhZDp+l6Ecz 6oMg== X-Gm-Message-State: AOUpUlHevPef3QLZmhftQQXSeMdP9ZR3ELArBq1kDzu5CdwpyN5NSZsZ RCz7kpZcb4yafUkE+jpdMZ1Ivhp7 X-Google-Smtp-Source: AAOMgpcbDAaNao1KatAHdkmucr6yQPfDwH5OJhpEyuH8hZQohosB54rUYL6hOtio0eJJi31y2DJwyA== X-Received: by 2002:a1c:a8d6:: with SMTP id r205-v6mr91732wme.6.1533150261477; Wed, 01 Aug 2018 12:04:21 -0700 (PDT) Received: from orange.redhat.com ([213.175.37.12]) by smtp.gmail.com with ESMTPSA id r17-v6sm15401322wrt.44.2018.08.01.12.04.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Aug 2018 12:04:20 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 7/8] libceph: check authorizer reply/challenge length before reading Date: Wed, 1 Aug 2018 21:03:49 +0200 Message-Id: <20180801190350.857-8-idryomov@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180801190350.857-1-idryomov@gmail.com> References: <20180801190350.857-1-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 Avoid scribbling over memory if the received reply/challenge is larger than the buffer supplied with the authorizer. Signed-off-by: Ilya Dryomov --- net/ceph/messenger.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index e915c8bce117..0a187196aeed 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -1782,6 +1782,13 @@ static int read_partial_connect(struct ceph_connection *con) if (con->auth) { size = le32_to_cpu(con->in_reply.authorizer_len); + if (size > con->auth->authorizer_reply_buf_len) { + pr_err("authorizer reply too big: %d > %zu\n", size, + con->auth->authorizer_reply_buf_len); + ret = -EINVAL; + goto out; + } + end += size; ret = read_partial(con, end, size, con->auth->authorizer_reply_buf);