From patchwork Thu Oct 5 00:49:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9986257 X-Patchwork-Delegate: johannes@sipsolutions.net 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 5B12E605A8 for ; Thu, 5 Oct 2017 01:08:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C2A828BDC for ; Thu, 5 Oct 2017 01:08:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 406CF28C45; Thu, 5 Oct 2017 01:08:00 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable 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 B231D28BDC for ; Thu, 5 Oct 2017 01:07:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752230AbdJEAt7 (ORCPT ); Wed, 4 Oct 2017 20:49:59 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:54140 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752199AbdJEAtz (ORCPT ); Wed, 4 Oct 2017 20:49:55 -0400 Received: by mail-pg0-f54.google.com with SMTP id y192so68736pgd.10 for ; Wed, 04 Oct 2017 17:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=tCgjkwn4K1zukFsfAHNRbPD9NmeGNMbKHWLeSFC86sw=; b=oHAXCifPJYA3wES73WIn2sc5Sb5c+b0kaS2PVlAkRzk13YfqjwOepo81lJ+vq9NZ+Y IU0wZuK92Se23L/nr+JN2WO98Ks8KZswL6G6iGOyGATdd4/LNFUWYXSpn4ku3prW+gzI luyEWUTDjA5z1JFygJaLeCo11SXnmlhF+tf6k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=tCgjkwn4K1zukFsfAHNRbPD9NmeGNMbKHWLeSFC86sw=; b=mes+Hm8grQWYCTkGwwz/J+Y9lTp4993PeVJ3uEYBeS56PxBmbSEPivBc/bRBk+LVav 4OqgugQnjGLP7rPd7bv2I3y9iOGpunXmq37UCPbUSMFCLaOtvN8Q2QlxlmafOVabw6xS +WlgAG00bG1XLULPf6X5CVSjL56LsKHcaB5ykHCt4uKDsuXV4QapdqfHXcmxMIJsYg0Q uyA3G2wkwFo3I4ZhWIc4qlDlEH/MLWUcb4k5iBVJrWATDW3XvGpwZsUuIMzwfgzA1BVT xLcfr6RS+KutiaXbcHAScLG4bjvA5TgfQGVEKgKLDWMDNkkjpjpWk/8bNTkKAilhBP1B VNnQ== X-Gm-Message-State: AMCzsaXfFeEKr1R5ynUvKUMM5ZZXgsQjXqVmmOzhq+fQjZe8bFBdu59Y W5wBsSc+8YfDmF3HHZA1PggyBw== X-Google-Smtp-Source: AOwi7QCJJE4H+Ek248nzN0AQLenzKoLU4shXldAl4p57OKH7c6uWXq/pH/DEABXpyYU7+CYrmvt2gQ== X-Received: by 10.98.35.194 with SMTP id q63mr643649pfj.15.1507164594639; Wed, 04 Oct 2017 17:49:54 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id j13sm29217635pfk.107.2017.10.04.17.49.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 17:49:53 -0700 (PDT) Date: Wed, 4 Oct 2017 17:49:52 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Johannes Berg , "David S. Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Thomas Gleixner Subject: [PATCH] net/mac80211/mesh_plink: Convert timers to use Message-ID: <20171005004952.GA23133@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. This requires adding a pointer back to the sta_info since container_of() can't resolve the sta_info. Cc: Johannes Berg Cc: "David S. Miller" Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Cc: Thomas Gleixner Signed-off-by: Kees Cook --- This requires commit 686fef928bba ("timer: Prepare to change timer callback argument type") in v4.14-rc3, but should be otherwise stand-alone. --- net/mac80211/mesh_plink.c | 9 +++++---- net/mac80211/sta_info.c | 2 +- net/mac80211/sta_info.h | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index f69c6c38ca43..fcc02beaee6d 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c @@ -604,8 +604,9 @@ void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata, ieee80211_mbss_info_change_notify(sdata, changed); } -static void mesh_plink_timer(unsigned long data) +static void mesh_plink_timer(struct timer_list *t) { + struct mesh_sta *mesh = from_timer(mesh, t, plink_timer); struct sta_info *sta; u16 reason = 0; struct ieee80211_sub_if_data *sdata; @@ -617,7 +618,7 @@ static void mesh_plink_timer(unsigned long data) * del_timer_sync() this timer after having made sure * it cannot be readded (by deleting the plink.) */ - sta = (struct sta_info *) data; + sta = mesh->plink_sta; if (sta->sdata->local->quiescing) return; @@ -698,8 +699,8 @@ static void mesh_plink_timer(unsigned long data) static inline void mesh_plink_timer_set(struct sta_info *sta, u32 timeout) { sta->mesh->plink_timer.expires = jiffies + msecs_to_jiffies(timeout); - sta->mesh->plink_timer.data = (unsigned long) sta; - sta->mesh->plink_timer.function = mesh_plink_timer; + sta->mesh->plink_sta = sta; + sta->mesh->plink_timer.function = (TIMER_FUNC_TYPE)mesh_plink_timer; sta->mesh->plink_timeout = timeout; add_timer(&sta->mesh->plink_timer); } diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 69615016d5bf..5e5de9455e4e 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -332,7 +332,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata, spin_lock_init(&sta->mesh->plink_lock); if (ieee80211_vif_is_mesh(&sdata->vif) && !sdata->u.mesh.user_mpm) - init_timer(&sta->mesh->plink_timer); + timer_setup(&sta->mesh->plink_timer, NULL, 0); sta->mesh->nonpeer_pm = NL80211_MESH_POWER_ACTIVE; } #endif diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 3acbdfa9f649..21d9760ce5c3 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -344,6 +344,7 @@ DECLARE_EWMA(mesh_fail_avg, 20, 8) * @plink_state: peer link state * @plink_timeout: timeout of peer link * @plink_timer: peer link watch timer + * @plink_sta: peer link watch timer's sta_info * @t_offset: timing offset relative to this host * @t_offset_setpoint: reference timing offset of this sta to be used when * calculating clockdrift @@ -356,6 +357,7 @@ DECLARE_EWMA(mesh_fail_avg, 20, 8) */ struct mesh_sta { struct timer_list plink_timer; + struct sta_info *plink_sta; s64 t_offset; s64 t_offset_setpoint;