From patchwork Wed Oct 12 19:42:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Colin Vidal X-Patchwork-Id: 9373749 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 7E2F1607FD for ; Wed, 12 Oct 2016 19:42:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E36329587 for ; Wed, 12 Oct 2016 19:42:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 607EB2958A; Wed, 12 Oct 2016 19:42:36 +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 BF6FD29587 for ; Wed, 12 Oct 2016 19:42:31 +0000 (UTC) Received: (qmail 13806 invoked by uid 550); 12 Oct 2016 19:42:28 -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: Reply-To: kernel-hardening@lists.openwall.com Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 13770 invoked from network); 12 Oct 2016 19:42:26 -0000 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=cvidal.org; h= content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=WAR Ezx/FyFBaySP0DRQsK1hbom0=; b=EqVezeg085BgVEt0B5osVNg4ZngZC6QgR+g lXtm6MPfLtqXiTW82zeXc68ykCisemOvMt3uB9QYBc0jR9RbCkBHe026mp1FGK4S KRMas95oRCFbowG2mx8mHcc4FFjST2zST3PTdYvKBd/B9gw5fVH6YcaITuWFDN0S IO0cbN/E= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=WAREzx/FyFBaySP0DRQsK1hbom0=; b=hKb1W IvTR+0sLR6z1Lc+I/OSKjFZGQo0aAwr0p00hpulzFV5bEdopphFRDi4alrSoON2A 97uY2QJo/2csKEZ7Pac6OKVqJiN5mOgxevxsQgUyaYn6ecgII69vvbAkVbNsgZzW fwXlt5OgSNQZLE/dGoYfX57fbMcyxh8n5pUXRQ= X-Sasl-enc: Jj4r8uaMklimDYF/tWGLTEWw6dXs75oEZZ9ExRWrat9c 1476301334 Message-ID: <1476301332.19131.24.camel@cvidal.org> From: Colin Vidal To: "kernel-hardening@lists.openwall.com" , "Reshetova, Elena" Date: Wed, 12 Oct 2016 21:42:12 +0200 X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Subject: [kernel-hardening] atomic64_wrap_t generic implementation X-Virus-Scanned: ClamAV using ClamSMTP Hi Elena, atomic64_wrap_t atom_wrap; atomic64_read_wrap(atom_wrap) will be expanded into atomic64_read(atom_wrap), which would lead to a type error (atomic64_t expected). Perhaps the more simple thing to do would be -typedef atomic64_t atomic64_wrap_t; +#define atomic64_wrap_t atomic64_t since the implementations are the same here. Or I missed something obvious? Thanks, Colin diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h index dad68bf..4987419 100644 --- a/include/asm-generic/atomic64.h +++ b/include/asm-generic/atomic64.h @@ -16,6 +16,8 @@ typedef struct {         long long counter;  } atomic64_t;   +typedef atomic64_t atomic64_wrap_t; +  #define ATOMIC64_INIT(i)       { (i) }    extern long long atomic64_read(const atomic64_t *v); @@ -62,4 +64,15 @@ extern int    atomic64_add_unless(atomic64_t *v, long long a, long long u);  #define atomic64_dec_and_test(v)       (atomic64_dec_return((v)) == 0)  #define atomic64_inc_not_zero(v)       atomic64_add_unless((v), 1LL, 0LL)   +#define atomic64_read_wrap(v) atomic64_read(v) +#define atomic64_set_wrap(v, i) atomic64_set((v), (i)) +#define atomic64_add_wrap(a, v) atomic64_add((a), (v)) +#define atomic64_add_return_wrap(a, v) atomic64_add_return((a), (v)) +#define atomic64_sub_wrap(a, v) atomic64_sub((a), (v)) +#define atomic64_inc_wrap(v) atomic64_inc(v) +#define atomic64_inc_return_wrap(v) atomic64_inc_return(v) +#define atomic64_dec_wrap(v) atomic64_dec(v) +#define atomic64_cmpxchg_wrap(v, o, n) atomic64_cmpxchg((v), (o), (n)) +#define atomic64_xchg_wrap(v, n) atomic64_xchg((v), (n)) Isen't there a type error ? For instance: