Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1624935pxy; Thu, 6 May 2021 11:43:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRowD7kGpNdM07MfHIHf21ZWrjHZBTlhfHs8LwOlox4sHch8L35j8HZBtskwqWpN1dTAna X-Received: by 2002:a17:90a:f009:: with SMTP id bt9mr5967674pjb.137.1620326628380; Thu, 06 May 2021 11:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620326628; cv=none; d=google.com; s=arc-20160816; b=WrukCvk8Yvq6shaGLN1EdoDqozYyL0uLenkNI/yY/qWDN7UMRUBm6UUX3za3HHjflh UXj5dwhTcowe5FloiiPmk+bfkSDK6ecpbkqhRr8NmikENU6nGdkKUmfR9UVfD0nbXKDx j2SsfT6DwPVqtPgmujL0K/MlB4aaf9mjbTJ0L/btylF78dig8HAcccRFbDV6xewz+eRl KUCitNMuUpHygWH0UyhqYadN8GYrVxXrTA1dG191OkBS4TfB2t2sRUYYRPeUgeAjlvl/ LPMizt9XvfxDW+00sjX8x9bySg62rPAAKE6+KyKWGGmsQK+6UzuKAPOLewsRZuOfizJJ Wkyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=9BMU8p5qfGti/xTJnOzpUYWHpECrazIQEd72D2+OXX0=; b=sTWqOQsM3p4v6/RlaI3TuXECFDVIyWJ9fy1TNn9ZgSABIm9aQ8pEma2I6aNc+xmfH1 0KHcjXRcHmTGNt66QVvVtZBKEdjhiHa33PNQnXe9XSp+nuM6Y35tug9fbA0u3rF61JyX dAKrnQe+EAAEbxeEvZAn0DFrcFCPgo04Yw4PcDIc1KPOyfVyRVqyS/oz/L4xEJd71Vr9 F/hFf78rGIkVRJiBt7z/W7HX29o8oJnTE8AkD9TT1TuHPWcr3uAVsNoi/QQcu93FXLXB hLTwEBkCaaCXkljQhOaU2xhzjcymlFQ/8RFYftG8kp4GrGT0/gyushwEtuZHeC2+dXec DNrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jAonvSUM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id n4si3718529plk.422.2021.05.06.11.43.35; Thu, 06 May 2021 11:43:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jAonvSUM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S234048AbhEFNaJ (ORCPT + 99 others); Thu, 6 May 2021 09:30:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234033AbhEFNaF (ORCPT ); Thu, 6 May 2021 09:30:05 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 396F5C061574 for ; Thu, 6 May 2021 06:29:07 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id f20-20020a0caa940000b02901c5058e5813so4071509qvb.23 for ; Thu, 06 May 2021 06:29:07 -0700 (PDT) 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=9BMU8p5qfGti/xTJnOzpUYWHpECrazIQEd72D2+OXX0=; b=jAonvSUMTqq9qzXhGStvl7B5zfMJ0ofgbVwgAyB6xn1JODIJFQwPXoFqgsKHdhELGx 6pKmwoxN1GFV4LtYftGPXxXZiyQto2Y2jr0yzQX8xBrxlX62YIZ0s4D54gZ3lg9dPpA5 J9EamFcrfjKwEcvoInbmf3arS+xE7+o3VO5KcdyTyHf/gEq7srqGZsWfHYhOQVeGh5CG uTnhrBFS4O6QuTQGOyvWe5S9vdzzT2f58xOnI5xqDqvkbDUHeBVxuP70Y/KuBfT+Hqbk Yzl9ChNCR2nqGHFuvCDnNMaVJz+sEtJXP7D9NzZzdpcO6oRkDB01X1Go6J5oQm3wpDNW nccg== 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=9BMU8p5qfGti/xTJnOzpUYWHpECrazIQEd72D2+OXX0=; b=jIETHLxM+7dRHrEYTtbc+YBA2lTIj1aUHsWCIULgCdtpGXMcUg7SlXjATyxbvXLeF6 2degVW/9qZqre1CTsryDYAQkhOFRwsQgvKPd4Ui2HuTpHrZzRujvhkzr5NOopXC0rLP5 apFQdPmcyO1+CQwc+UNbyxUtQ1ccYuRItqS04dYtnG5bTD2rVbzKSXLcK6rsvWGnqWhE Annb4CuElxAiFPBG8fCkodYUSI+H7+XAExF2XQVcijy7JrJdB+6HnI+rbJjSmR5DrUoH jr99cyYFMn82pJFzPcSKCgZFjx1X2PHS2ieyfatp8KDyknwAUAwaWMdPjravnzvtzx2S 2EBA== X-Gm-Message-State: AOAM53254N90/rxwQEhb4l1pXNaOsRqJUwGndziMqYR3tVXJZYsHBgHl cCHzejrZQ9Lf2Em0QtDvESRPxdW0xg== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:56c7:a45c:aa57:32c4]) (user=elver job=sendgmr) by 2002:a05:6214:2125:: with SMTP id r5mr4329047qvc.28.1620307746353; Thu, 06 May 2021 06:29:06 -0700 (PDT) Date: Thu, 6 May 2021 15:28:27 +0200 Message-Id: <20210506132827.3198497-1-elver@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.607.g51e8a6a459-goog Subject: [PATCH] checkpatch: warn about direct use of send_sig_info and force_sig_info From: Marco Elver To: elver@google.com, "Eric W . Biederman" Cc: linux-kernel@vger.kernel.org, apw@canonical.com, joe@perches.com, dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Setting up siginfo and using send_sig_info() and force_sig_info() directly is discouraged. Instead, new code wanting to generate signals should use the appropriate helper specific to the signal. Eric mentioned that he'd like to make these static at some point, but until that can happen, let's try to avoid introducing new users of them. Cc: Eric W. Biederman Signed-off-by: Marco Elver --- Eric, While siginfo doesn't need changing often, when it does, it's quite the adventure. We now have the various static asserts. The other thing is usage of {send,force}_sig_info. I think the best option right now is to teach checkpatch.pl about it until they become static. Fyi, I noticed one such new user here: https://lkml.kernel.org/r/20210421024826.13529-1-wangjunqiang@iscas.ac.cn Thanks, -- Marco --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index ccb412a74725..3a86aafc3bcd 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -7153,6 +7153,12 @@ sub process { "Where possible, use lockdep_assert_held instead of assertions based on spin_is_locked\n" . $herecurr); } +# check for direct use of send_sig_info(), force_sig_info() + if ($line =~ /\b((force|send)_sig_info)\(/) { + WARN("USE_SIGINFO_HELPER", + "Where possible, avoid using '$1' directly and use a signal-specific helper setting required siginfo fields (see include/linux/sched/signal.h).\n" . $herecurr); + } + # check for deprecated apis if ($line =~ /\b($deprecated_apis_search)\b\s*\(/) { my $deprecated_api = $1; -- 2.31.1.607.g51e8a6a459-goog