Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3000918yba; Mon, 6 May 2019 15:21:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRFzkWv/q08OEBsKPZevCVHPUom8NejSecNnxezsYnC/5PT8n8j6o2L297MvFJtvu+FHiw X-Received: by 2002:aa7:8046:: with SMTP id y6mr37538669pfm.251.1557181285494; Mon, 06 May 2019 15:21:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557181285; cv=none; d=google.com; s=arc-20160816; b=vpzrQ5P2GrT8mjmdJwpfu21FwB4qkWuaJsBlLAbJxXAhbEIcupqC2GO4UKfWgffFOf 6J80sNzHQbDXLtuf4of/RIYm5G4lDSiWDesXMAgiB4K9NkdgaeHTD2IcU+T0dnl845YN FePIZRmdgzXvtR8O6QDzI+i8iHHh6wlejipmWNYemagaeq6klyjjptUynG2/gPqrmOHX yDfAm2c3vEOhfM4b2Qm/CCX0a5QcAwqsGJmkmcpymoNxq3GAHdZ/0ZoTx2yEFnLIIU0z foJ4NKM6GGeiGFejrJb7ZceiVV9xX0lrsCxrs1W971pNr0ZJjdZt8tTWuHVb3yjXFF/T iedQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=LFigoZJymqmAaPzjvAFIhkqDgKas3FocYI4lCQ70qnE=; b=nIhAnAGJUrYjoT0Zao/ljf+fmUwlNMc1IdiuV+/fwNDhyOJRGspj7/aKTvJULnBA1T 7g5ioqO8pZlX5VnDrrDcuNQ0fPW8GRG8Qgq9UFffrLjx7TlxibfCogQr9DVUQyUhIE+D IsaAneQZZivM3xz/Ag8OFI5ohdwfmKiMqzY9nTzWP0OE7ne9+wltOozHce+2IXzDK/lJ zrhB/37Gni8Jui6PhPpGPVc3P+QMcee5W6YA3uwm9mHtF3623PUg5wyM0fifdmW5OpJ1 dhzeqJ630C5a4rT6PEc4cHwHIhvgyX5/wvJI00mLxV+1hllLkP0hPIG5AjZWiyrW1g4A pYmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ABG4sOkP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g22si7962646pgb.107.2019.05.06.15.21.06; Mon, 06 May 2019 15:21:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ABG4sOkP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726393AbfEFWUL (ORCPT + 99 others); Mon, 6 May 2019 18:20:11 -0400 Received: from mail-ua1-f66.google.com ([209.85.222.66]:34714 "EHLO mail-ua1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfEFWUK (ORCPT ); Mon, 6 May 2019 18:20:10 -0400 Received: by mail-ua1-f66.google.com with SMTP id f9so5271948ual.1 for ; Mon, 06 May 2019 15:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LFigoZJymqmAaPzjvAFIhkqDgKas3FocYI4lCQ70qnE=; b=ABG4sOkPQqPowCgFecCPGKupz44mONVpCKnynPqbD1PBGzbJqzFzk7rgRpOY/O+YM1 Trx119D7VlwsARtPhJ2zsjkzziHTWrE0bXmWqFXdHnEDiyHV+Vn05EYT4zYqTMg6yNcq d+IBEMobGQ+IHeDSQ4cy77I4r/gGPKXy6dXWw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LFigoZJymqmAaPzjvAFIhkqDgKas3FocYI4lCQ70qnE=; b=XcEbfHunCZPGM2A7qprXsSsapEwvJ3qrcuBg9t+TjElhmSLaaOm9FtUsLUaDx1V1eC Ua09OXE70FTFaTyyEZsy99PI5aOOfNU/CKTPz7PK03wONht7PUayLwjiJYS5y/vD2KWL uMu3O3RJM61Tggr9dlTCmVWNoHY3qRBW4j2baXvgMxLXMy5bQlYYKkdQd09o8s+hxAyj 1wDg4ejW79BcjwQ1Kzb+v/8oxLBQ0FaMKScBY2+vbFCYwe1esKjASSodz63YXI3AR2jq KJS2A3Rma+jcePTzXbmX9zGxpjYdZkC6qU9JYNXTjH1wZr2AsysjNDdDcPRu85JZ07Ga DNyg== X-Gm-Message-State: APjAAAVGeu2/C5KqTOnVjf3tbv8B+jPRBPAxL/HrL3MI9JKBJ3vlYJqG bE3vqRe10HtjpwCq9wdJAZX4o7nQhuE= X-Received: by 2002:ab0:7348:: with SMTP id k8mr288589uap.64.1557181208906; Mon, 06 May 2019 15:20:08 -0700 (PDT) Received: from mail-vs1-f49.google.com (mail-vs1-f49.google.com. [209.85.217.49]) by smtp.gmail.com with ESMTPSA id i14sm3472331vsf.29.2019.05.06.15.20.07 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2019 15:20:07 -0700 (PDT) Received: by mail-vs1-f49.google.com with SMTP id g127so9133867vsd.6 for ; Mon, 06 May 2019 15:20:07 -0700 (PDT) X-Received: by 2002:a05:6102:397:: with SMTP id m23mr5277776vsq.222.1557181207040; Mon, 06 May 2019 15:20:07 -0700 (PDT) MIME-Version: 1.0 References: <20190506191950.9521-1-jmoreira@suse.de> <20190506191950.9521-4-jmoreira@suse.de> In-Reply-To: <20190506191950.9521-4-jmoreira@suse.de> From: Kees Cook Date: Mon, 6 May 2019 15:19:55 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v2 3/4] Fix twofish crypto functions prototype casts To: Joao Moreira Cc: Kernel Hardening , LKML , X86 ML , Herbert Xu , "David S. Miller" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Greg KH Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 6, 2019 at 12:20 PM Joao Moreira wrote: > RFC: twofish_enc_blk_ctr_3way is assigned both to .ecb and to .ctr, > what makes its declaration through the macro undoable, as thought in > this patch. Suggestions on how to fix this are welcome. This looks like a typo in the original code (due to the lack of type checking!) typedef void (*common_glue_func_t)(void *ctx, u8 *dst, const u8 *src); ... #define GLUE_FUNC_CAST(fn) ((common_glue_func_t)(fn)) ... void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src, le128 *iv) static const struct common_glue_ctx twofish_ctr = { ... .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_ctr_3way) } ... return glue_ctr_req_128bit(&twofish_ctr, req); int glue_ctr_req_128bit(const struct common_glue_ctx *gctx, struct skcipher_request *req) ... gctx->funcs[i].fn_u.ctr(ctx, dst, src, &ctrblk); The twofish_ctr structure is actually only ever using the .ctr assignment in the code, but it's a union, so the assignment via .ecb is the same as .ctr. -- Kees Cook