Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp709172ybl; Fri, 6 Dec 2019 05:07:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwxelyJ7RjSrX5U+xOxYlSO7Cwv7YMTaLsesnGcfdSwT7kg4eHKkK5gs8XjdM3JI1EOU8O3 X-Received: by 2002:aca:4785:: with SMTP id u127mr11578031oia.94.1575637632677; Fri, 06 Dec 2019 05:07:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575637632; cv=none; d=google.com; s=arc-20160816; b=b3jTeCbY/J9jUO4XmKuQMdgeFwg64nAFdJ1wp/I2jw4u6asG8vtzE8f0CLo0vO4t+/ +wFGkbRXwZsSatz7YuJDH6aPhtGBBIVOtm23hTM52CwRf7CajCyZC6gc1DOxpIXqJv4F /pKzwrx3m7vZayAAujNe5njUY+rb2jvOFHWCIFVdma5m1xo+iGZdrSQ1PHEYvIulsnB+ BDDlcILKhylVdYY8Mr9HSXWUFS6t6mx//lGCT/vNmH4s7Qj0i8Dtj/N3RbxRE7l0Dn/w vWIPsmwIvKBTi2rK3vnjEaqQJ28fSajyvAwVSH1ywXSVo2rF36AjRZmomeDB2/9C3Y2+ zS4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=1KX2oVUMaou01lixSYTFwapcBrG5FrybP5vWFBurigw=; b=sfp1oIQcJG6zqu0pXdXDI5rCoEO0mkJRphYsZSYOT+C0d8WMHeAE1rVcqYcTyIq+no M4KU4U7oJufXW6R7DrqTYuNOH/0M13AA/JlkIjwGcuOTdNvYqpRD6h4LFtddLFpLQ9fQ slFrGNEZlqXhDAnhIsCJ3jyZZTJP2gRD99M54Q+sC4LxIZLvVh0ah2BPA/hvu5MTKKwr xjVOeUG24y8BpFPnEljcFddHDMQUAC6RkRxHsC6Nyt+j/eMjYc9k3UTk375zcfmSXrsz jRt/7k6saeUoIMq8hJA4sugkbgj5mcxl81pmSdV0yck7+W+31nwbfww4/YmwpeE+4YzG i/pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=v8+wwL2q; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e5si7091807otr.247.2019.12.06.05.06.52; Fri, 06 Dec 2019 05:07:12 -0800 (PST) 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=@google.com header.s=20161025 header.b=v8+wwL2q; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726245AbfLFNFD (ORCPT + 99 others); Fri, 6 Dec 2019 08:05:03 -0500 Received: from mail-vs1-f74.google.com ([209.85.217.74]:34081 "EHLO mail-vs1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbfLFNFD (ORCPT ); Fri, 6 Dec 2019 08:05:03 -0500 Received: by mail-vs1-f74.google.com with SMTP id f24so797757vsk.1 for ; Fri, 06 Dec 2019 05:05:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=1KX2oVUMaou01lixSYTFwapcBrG5FrybP5vWFBurigw=; b=v8+wwL2q9iG843UGD4A0cogB3dxJSmi2LipG5QFco6E/i+nwbeY3esudqL8m5tu+Cm MppitP4cF9bwXbPW8OlNOTBoKY3jQove2CgxRlOHygymF38AwTamn9rpw8nHWMSiCBYs XrLyEnuJYGHFi9nHT50zrqMRwESibfcb5C4HD2x+HBqcW94pUj90Wtxc5xuliyCeZE/o OBOaQMZbU9J1Y/svvv22OAPzXH7evpztB1kfZ+omGab2ntS+a+NMtc4QkXDQaIH5mSsV 9UpEl2NpIkQ0ZAUVS25f56Uyj/YQOe1ENmBywJyQk/0soUQNdnQZDIM/xrEXdwhDOzvG rM0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=1KX2oVUMaou01lixSYTFwapcBrG5FrybP5vWFBurigw=; b=H/y5mwxXXUCRU3gLmYFjWkQV5DjFMhbGaQDp7r3gO1434RM1EqmPsNj7y/UJx8nDlG iq9GvKNGSpKTxm5VLmUri4VswYSdJSnbvL946KtT4019//LoaN88L0WFuzm5jf4GKHwz MeKN8dO5egD1l9wbxsUetlVbbjzv+oX+rH0+GTiSySvjQYOAd8ERE88yyCv+E6m1GB+s gtpIkTyANCAwODBED5X6EWjqRMRY21oiZkpQeR6ZLwLYVOFMbrNCNPk3N6BXQiHc47or eiFkkUEBQ8u6SwAgdcsFfuCN4osU1/n76qZiCG4kIr/UKNLbRSsndgolguwNTyYvhnqr v7JA== X-Gm-Message-State: APjAAAXd5BSngARYuQZGEaYJfC2XaWBRgk/7xCEf03m5HoBZIEmlZQ1e M7KVuSlPvOVukYWDDG8DZmgrEL69CVOo6DJ6 X-Received: by 2002:a1f:1e13:: with SMTP id e19mr11541636vke.88.1575637501944; Fri, 06 Dec 2019 05:05:01 -0800 (PST) Date: Fri, 6 Dec 2019 14:04:55 +0100 Message-Id: <46cee2a09d53921057cd4b87d1ed3796a2ab15bb.1575637022.git.andreyknvl@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog Subject: [PATCH] kcov: fix struct layout for kcov_remote_arg From: Andrey Konovalov To: Andrew Morton , Dmitry Vyukov , linux-kernel@vger.kernel.org Cc: Alexander Potapenko , Marco Elver , Andrey Konovalov 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 Make the layout of kcov_remote_arg the same for 32-bit and 64-bit code. This makes it more convenient to write userspace apps that can be compiled into 32-bit or 64-bit binaries and still work with the same 64-bit kernel. Also use proper __u32 types in uapi headers instead of unsigned ints. Signed-off-by: Andrey Konovalov --- Hi Andrew, We've noticed failures on 32 bit syzbot instances when the kcov patches got merged into mainline. The reason is that the layout of kcov_remote_arg depends on the alignment rules, which are different for 32/64 bit code. We can deal with this issue in syzkaller [1], but I think it would be cleander to get this fixed in the kernel. I hope this patch is acceptable, since the change has just been merged and is not included into a release kernel version. The patch breaks the newly introduced kcov API for 32 bit apps. Sorry for not testing it with 32 bit code earlier. Thanks! [1] https://github.com/google/syzkaller/commit/ba97c611a36b7729d489ebca5f97183c2ba7a90a Documentation/dev-tools/kcov.rst | 7 ++++--- include/uapi/linux/kcov.h | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Documentation/dev-tools/kcov.rst b/Documentation/dev-tools/kcov.rst index 36890b026e77..744df2bae1ed 100644 --- a/Documentation/dev-tools/kcov.rst +++ b/Documentation/dev-tools/kcov.rst @@ -251,9 +251,10 @@ selectively from different subsystems. .. code-block:: c struct kcov_remote_arg { - unsigned trace_mode; - unsigned area_size; - unsigned num_handles; + uint32_t trace_mode; + uint32_t area_size; + uint32_t num_handles; + uint32_t reserved; uint64_t common_handle; uint64_t handles[0]; }; diff --git a/include/uapi/linux/kcov.h b/include/uapi/linux/kcov.h index 409d3ad1e6e2..53267f9f1665 100644 --- a/include/uapi/linux/kcov.h +++ b/include/uapi/linux/kcov.h @@ -9,11 +9,12 @@ * and the comment before kcov_remote_start() for usage details. */ struct kcov_remote_arg { - unsigned int trace_mode; /* KCOV_TRACE_PC or KCOV_TRACE_CMP */ - unsigned int area_size; /* Length of coverage buffer in words */ - unsigned int num_handles; /* Size of handles array */ - __u64 common_handle; - __u64 handles[0]; + __u32 trace_mode; /* KCOV_TRACE_PC or KCOV_TRACE_CMP */ + __u32 area_size; /* Length of coverage buffer in words */ + __u32 num_handles; /* Size of handles array */ + __u32 reserved; + __u64 common_handle; + __u64 handles[0]; }; #define KCOV_REMOTE_MAX_HANDLES 0x100 -- 2.24.0.393.g34dc348eaf-goog