From patchwork Fri Apr 7 20:34:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Moon X-Patchwork-Id: 13205407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27949C6FD1D for ; Fri, 7 Apr 2023 20:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=UhSdwE+fCg9LyKhQdtLrlW4MnnL1ZEL8iwchUVflo9I=; b=2ItXk0iffh9S1I /pjRmbwXL0zhI5KB1re2WDJJR6Ju8PZy9dlea5CB/zwB6Hz1JRY05IkvWPfh36Ju3a6QfcAVgUwhv iG4Ls3KQwmx/1bgZSN6YEfPcoMYlPbCdFgvP7fio+8nxduKxnKlgHJKG8qtpDm+OT5YI8tZ3PBV3Z o5vhVQPTRuj9MMDLUFv4tsYtLC1bPU4TJMipWjamFnHEa5D1VIBEce5+aawjf0q/6D8ko0YF8VNFu iO+RrxmdBCA0VlYLItRblETZr4AfLGZ9uhwTOQh3cf5PidIgBwPbQse6tiqXbfwduL9eguHu5CbRa +AvKOCJZl6wh4KgX6P0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pksoD-00B6n6-19; Fri, 07 Apr 2023 20:35:45 +0000 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pkso4-00B6lC-28 for linux-arm-kernel@lists.infradead.org; Fri, 07 Apr 2023 20:35:39 +0000 Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 337KZJv0010775; Fri, 7 Apr 2023 20:35:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=qcppdkim1; bh=RnM21H93KsCfKYDZySXqH9aFxlviESAjiVNz4+3cpTA=; b=RPrJDtjxRC/di5+kQ5XwCod2NcCWN/veJ0gIV9Pa6mXN0KrTazVM5xvnFLrSPmLHiQ8h mh0FhyVvzlRrFU0tJ9yA3TB3Uop2LS5d2p4zKkJ+fW/msiXwLsSRpIfnuxAZ872Nll0s CQ54gIHPRZ5phA2+Oh6mnqILEcuZDRahWrK+xZrvWmLRTbgkHnc6oaD2887OUzSlWOeR lFTC6qbNTaylR9ov8j2QlV8opRwF8Iibw9uCtd/XzeI57j4QnQync0T7rQmjlImwL0W6 zld3uYEUnDfUjfZXCVRMV4y/8a4x5/msZOnMFQYLh93TYK4rQ35Wrqrj1ACl5N/M7qbu ow== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3psv4dm47x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 07 Apr 2023 20:35:19 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 337KZI46014700 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 7 Apr 2023 20:35:18 GMT Received: from hu-johmoo-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Fri, 7 Apr 2023 13:35:17 -0700 From: John Moon To: Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , "Nicolas Schier" CC: John Moon , , , , , Greg Kroah-Hartman , Randy Dunlap , "Arnd Bergmann" , Bjorn Andersson , Todd Kjos , Matthias Maennich , Giuliano Procida , , , Jordan Crouse , Trilok Soni , Satya Durga Srinivasu Prabhala , Elliot Berman , "Guru Das Srinagesh" Subject: [PATCH v5 0/2] Validating UAPI backwards compatibility Date: Fri, 7 Apr 2023 13:34:54 -0700 Message-ID: <20230407203456.27141-1-quic_johmoo@quicinc.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: nmIcOJr4FzDw2GJLhfO-FOoFk4ib5q4w X-Proofpoint-ORIG-GUID: nmIcOJr4FzDw2GJLhfO-FOoFk4ib5q4w X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-07_13,2023-04-06_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 spamscore=0 mlxlogscore=954 phishscore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304070184 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230407_133536_815754_BF5EA369 X-CRM114-Status: GOOD ( 23.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The kernel community has rigorously enforced a policy of backwards compatibility in its UAPI headers for a long time. This has allowed user applications to enjoy stability across kernel upgrades without recompiling. Our goal is to add tooling and documentation to help kernel developers maintain this stability. We see in the kernel documentation: "Kernel headers are backwards compatible, but not forwards compatible. This means that a program built against a C library using older kernel headers should run on a newer kernel (although it may not have access to new features), but a program built against newer kernel headers may not work on an older kernel."[1] How does the kernel community enforce this guarantee? As we understand it, it's enforced with thorough code review and testing. Is there any tooling outside of this being used to help the process? Also, could documentation on UAPI maintenance (from a developer's point of view) be expanded? Internally, we have a set of guidelines for our kernel developers regarding UAPI compatibility techniques. If there's interest in supplying a document on this topic with the kernel, we'd be happy to submit a draft detailing what we have so far as a jumping off point. In terms of tooling, I've attached a shell script we've been using internally to validate backwards compatibility of our UAPI headers. The script uses libabigail's[2] tool abidiff[3] to compare a modified header's ABI before and after a patch is applied. If an existing UAPI is modified, the script exits non-zero. We use this script in our continuous integration system to block changes that fail the check. It generates output like this when a backwards-incompatible change is made to a UAPI header: !!! ABI differences detected in include/uapi/linux/bpf.h from HEAD~1 -> HEAD !!! [C] 'struct bpf_insn' changed: type size hasn't changed 1 data member change: type of '__s32 imm' changed: typedef name changed from __s32 to __u32 at int-ll64.h:27:1 underlying type 'int' changed: type name changed from 'int' to 'unsigned int' type size hasn't changed We wanted to share this script with the community and hopefully also receive general feedback when it comes to tooling/policy surrounding this issue. Our hope is that the script will help kernel UAPI authors maintain good discipline and avoid breaking userspace. In v5, we've made a few code quality improvements based on review feedback. Thanks! [1] Documentation/kbuild/headers_install.rst [2] https://sourceware.org/libabigail/manual/libabigail-overview.html [3] https://sourceware.org/libabigail/manual/abidiff.html P.S. While at Qualcomm, Jordan Crouse authored the original version of the UAPI checker script. Thanks Jordan! John Moon (2): check-uapi: Introduce check-uapi.sh docs: dev-tools: Add UAPI checker documentation Documentation/dev-tools/checkuapi.rst | 480 +++++++++++++++++++++++++ Documentation/dev-tools/index.rst | 1 + scripts/check-uapi.sh | 489 ++++++++++++++++++++++++++ 3 files changed, 970 insertions(+) create mode 100644 Documentation/dev-tools/checkuapi.rst create mode 100755 scripts/check-uapi.sh base-commit: f2afccfefe7be1f7346564fe619277110d341f9b --- 2.17.1