From patchwork Wed Mar 29 18:15:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9652187 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 05D53602C8 for ; Wed, 29 Mar 2017 18:16:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E46BC28510 for ; Wed, 29 Mar 2017 18:16:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D92E52851A; Wed, 29 Mar 2017 18:16:51 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 24AB428510 for ; Wed, 29 Mar 2017 18:16:50 +0000 (UTC) Received: (qmail 23601 invoked by uid 550); 29 Mar 2017 18:16:49 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 20392 invoked from network); 29 Mar 2017 18:16:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=920E8IiQPXj4gcwdOJFBtnnGgv+Igp1RPVnUZ3PFZ5k=; b=FYz837HFvLqgi8fxwWdBSoJHjIZvqFssIrhp6a9k+VhnoiapLkvYEJeUq0yyENmZf2 vxsB6Fgm+VPyByxmJ31BWTsyPpoZ3AvnHdxRXegUmD6cFLanwdfGOaHOz/fhvpoC64T/ YXFvzj4IHgEzkQ6h23TXbrr1ExbtGwXnqHq/Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=920E8IiQPXj4gcwdOJFBtnnGgv+Igp1RPVnUZ3PFZ5k=; b=eoa3sTb8ifufM53MGRr4eROLNXcaUPBOsCaAzj6q9yjq3pxYMbNJNOtAdjOwnxNAdP OPLtm1v0/tE2fGIS5xFLlS46dUHcLOUJbA3ZihQEqGnGjSudhMJCh42cfHyzyjNdkfqv 8qeEkmb/c7khb6rfmAJ63IaF0scXzaq9YkUAvvy5XHHpej05nbtcVn9hSm1Ja3bA1Guv Kognv8RIy78O5JGvUHW6Qog5X3YI3MS3SRQnTir/R7VusvaMlFkUI9wmzW+qlwtF8Fbe 3g5xZWMoDPsPCaEEnVoTHkYnSaOB3wErjN4HH12167JNwJO3nVT7jFisF229T3XlEd0f qgnQ== X-Gm-Message-State: AFeK/H0Ae78lNXlLZJTPvld6rBEgN4CM7K+quImTZcMiglfZsJ7Jf+1UqFqMCz8+4I7lAay8 X-Received: by 10.99.120.206 with SMTP id t197mr1863676pgc.21.1490811383399; Wed, 29 Mar 2017 11:16:23 -0700 (PDT) From: Kees Cook To: kernel-hardening@lists.openwall.com Cc: Kees Cook , Mark Rutland , Andy Lutomirski , Hoeun Ryu , PaX Team , Emese Revfy , Russell King , x86@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Date: Wed, 29 Mar 2017 11:15:55 -0700 Message-Id: <1490811363-93944-4-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490811363-93944-1-git-send-email-keescook@chromium.org> References: <1490811363-93944-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [RFC v2][PATCH 03/11] net: switch sock_diag handlers to rare_write() X-Virus-Scanned: ClamAV using ClamSMTP This is a simple example a register/unregister case for __wr_rare markings, which only needs a simple rare_write() call to make updates. Signed-off-by: Kees Cook --- net/core/sock_diag.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c index 6b10573cc9fa..67253026106f 100644 --- a/net/core/sock_diag.c +++ b/net/core/sock_diag.c @@ -14,7 +14,7 @@ #include #include -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX]; +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __wr_rare; static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh); static DEFINE_MUTEX(sock_diag_table_mutex); static struct workqueue_struct *broadcast_wq; @@ -194,7 +194,7 @@ int sock_diag_register(const struct sock_diag_handler *hndl) if (sock_diag_handlers[hndl->family]) err = -EBUSY; else - sock_diag_handlers[hndl->family] = hndl; + rare_write(sock_diag_handlers[hndl->family], hndl); mutex_unlock(&sock_diag_table_mutex); return err; @@ -210,7 +210,7 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld) mutex_lock(&sock_diag_table_mutex); BUG_ON(sock_diag_handlers[family] != hnld); - sock_diag_handlers[family] = NULL; + rare_write(sock_diag_handlers[family], NULL); mutex_unlock(&sock_diag_table_mutex); } EXPORT_SYMBOL_GPL(sock_diag_unregister);