From patchwork Mon Feb 27 20:43:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9594175 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 325EF60471 for ; Mon, 27 Feb 2017 20:43:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2521927F9F for ; Mon, 27 Feb 2017 20:43:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19ED22832D; Mon, 27 Feb 2017 20:43:57 +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 5AB6B27F9F for ; Mon, 27 Feb 2017 20:43:56 +0000 (UTC) Received: (qmail 7743 invoked by uid 550); 27 Feb 2017 20:43:54 -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 6044 invoked from network); 27 Feb 2017 20:43:44 -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=fJhg8rELWZBO2nnCf8OeHLf2msYkwGFBJCAZVJGhcsHMYepa5mP8gbSzR3k+/sZ6Ot nZaMudUTrr1QiwbmtpZR/yLUBVkij37+aCMwxrRotKv8xybjWJYWskvfoddemUtbmynf 70saUv3/ewKNml0w+jWvfcsK5BHElPnR7xtF4= 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=r9l2oNCQ5DsIW8SrBPY6lCSCtAqwlA1/BwWvJ4SFTzGT83pqwvQCH/D0Gel2QydVQb z2d3F8PpCZ/MG2LTU+0o7gKnOk+aEXLvE7BW6dLdEE+KsCShiXmFsfBb55kAwfWBoJE4 86DbhT3pTFfwwXn0OstvF1wxNNCwEn3VjSCZckrVRLsyJTJlumlEzC0Gi/PrpsHP5XKJ B9kME1U48twaBBU9MFjgEZHBcO7YvtGasZUqjiwFh4x3yztzUShNV+xZYQjQniTjjJnX OcqG4tJDbXfjqMCOIk9Gsh64Ol/VnglAqJoN4lnMHWApN8zFBdej/eD21hQ+BreS6IcM sI+w== X-Gm-Message-State: AMke39mW7095yX4DpCdw1FCdz8VF8EywzLVanEhAtf9GFSLvtIefBAq3yAp4Lz2C3A+EL5UP X-Received: by 10.98.202.80 with SMTP id n77mr22878189pfg.167.1488228212497; Mon, 27 Feb 2017 12:43:32 -0800 (PST) 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 Date: Mon, 27 Feb 2017 12:43:01 -0800 Message-Id: <1488228186-110679-4-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488228186-110679-1-git-send-email-keescook@chromium.org> References: <1488228186-110679-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [RFC][PATCH 3/8] 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);