From patchwork Fri Sep 23 07:59:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9347655 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 3CBEB607F2 for ; Fri, 23 Sep 2016 08:00:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D5A029E05 for ; Fri, 23 Sep 2016 08:00:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 203CA2A259; Fri, 23 Sep 2016 08:00:26 +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 DC2AE29E05 for ; Fri, 23 Sep 2016 08:00:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754378AbcIWIAW (ORCPT ); Fri, 23 Sep 2016 04:00:22 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36766 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753675AbcIWIAV (ORCPT ); Fri, 23 Sep 2016 04:00:21 -0400 Received: by mail-wm0-f66.google.com with SMTP id b184so1399969wma.3 for ; Fri, 23 Sep 2016 01:00:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=0bCyUP1I7liAk4gFHt087kY+Dq0TN5AO54uXUZ4HwFE=; b=H8Ew3DC/TCoz8+9i3glJgQpgJT2UvyNeAncEZGyQSxzORHwAurnjOshtXhuWxtecjt sSHwwPJ0hOSq3RuOAkEzJSk9X5MIrnIbdvOpvbs4LiWh9utVD0f0nMAfWVxqOi4UT1ZK sK7KigrtcSwp9uxWYSkLWa+MKv/s0eEQ2KzYCerjBfszqO59NCqTeb0MUFcJTYQoQtDh 5DDj1BoYpwDi6dTALC8zx4cjkIzJYjFSRVf/v3L5zRgj6O6fui96Pi1y2sNADxtrOsuY a/Soo1NAzW+EylnH64Co/S+BfTTVTKMsm9bWot3lVPRFrIgs89ScSV8REgBXCnlmVu3i mAhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0bCyUP1I7liAk4gFHt087kY+Dq0TN5AO54uXUZ4HwFE=; b=hh06O9f2KI/zP3KlmjAvNK5Ss5/5D7aEL672WU471NLYh8F70BP+6SVCo9m9/0New7 7ItS3p3Fi6JZuzXO9n8e3+munY11ZdW2+Ujc4BEDEf7R+53x9ZX4sn0qmXR1/ehnEf0w O1bX13Bkopk7vtLSE57bvvHt0gAzszfJiFCMv6uz04enpg83ekqLnND1FgtsPx9y8Hb4 7c0AGJ7f20BWu5VoDTOydjvUvBvdZysuz++/YMHvOT413WURbx+Yyb2lh19icTUhUsZI KEiDjs8NOUyOQyfz51FfZyeMDhBs8uKrk+KE75gL+pn8ABAspVYDrCmcZEeZZ//mzxPX a9jw== X-Gm-Message-State: AE9vXwOy9VzV3eMMVJTy31h3Nqm3Vx6pGo6NA5BQBajTWjenz9s/ZpjaxaXo2rgVE2DLIA== X-Received: by 10.194.42.133 with SMTP id o5mr6631917wjl.200.1474617620316; Fri, 23 Sep 2016 01:00:20 -0700 (PDT) Received: from localhost.localdomain (ip-78-45-38-98.net.upcbroadband.cz. [78.45.38.98]) by smtp.gmail.com with ESMTPSA id r194sm1781895wmf.22.2016.09.23.01.00.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Sep 2016 01:00:19 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: Iago Abal Subject: [PATCH] libceph: ceph_build_auth() doesn't need ceph_auth_build_hello() Date: Fri, 23 Sep 2016 09:59:50 +0200 Message-Id: <1474617590-24456-1-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 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 A static bug finder (EBA) on Linux 4.7: Double lock in net/ceph/auth.c second lock at 108: mutex_lock(& ac->mutex); [ceph_auth_build_hello] after calling from 263: ret = ceph_auth_build_hello(ac, msg_buf, msg_len); if ! ac->protocol -> true at 262 first lock at 261: mutex_lock(& ac->mutex); [ceph_build_auth] ceph_auth_build_hello() is never called, because the protocol is always initialized, whether we are checking existing tickets (in delayed_work()) or getting new ones after invalidation (in invalidate_authorizer()). Reported-by: Iago Abal Signed-off-by: Ilya Dryomov --- net/ceph/auth.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/ceph/auth.c b/net/ceph/auth.c index 53aa2d27e36b..c822b3ae1bd3 100644 --- a/net/ceph/auth.c +++ b/net/ceph/auth.c @@ -262,9 +262,7 @@ int ceph_build_auth(struct ceph_auth_client *ac, int ret = 0; mutex_lock(&ac->mutex); - if (!ac->protocol) - ret = ceph_auth_build_hello(ac, msg_buf, msg_len); - else if (ac->ops->should_authenticate(ac)) + if (ac->ops->should_authenticate(ac)) ret = ceph_build_auth_request(ac, msg_buf, msg_len); mutex_unlock(&ac->mutex); return ret;