From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754686AbdKIOIm (ORCPT ); Thu, 9 Nov 2017 09:08:42 -0500 Received: from mail-io0-f177.google.com ([209.85.223.177]:43123 "EHLO mail-io0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754553AbdKIOIk (ORCPT ); Thu, 9 Nov 2017 09:08:40 -0500 X-Google-Smtp-Source: AGs4zMZS4nJDjpe6PcHn+A6prpnCLQcRymvKdURrsG5tSAAuzfj28SZweWxPy31WyBGUNlSJl+PE5xfWvIMJC+BV7sg= MIME-Version: 1.0 In-Reply-To: References: <20171108223020.24487-1-linux@rasmusvillemoes.dk> From: Rasmus Villemoes Date: Thu, 9 Nov 2017 15:08:39 +0100 Message-ID: Subject: Re: [RFC 0/6] some compile- and run-time format checking To: Kees Cook Cc: kernel-hardening@lists.openwall.com, LKML , Andrew Morton Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9 November 2017 at 02:11, Kees Cook wrote: > On Wed, Nov 8, 2017 at 2:30 PM, Rasmus Villemoes > wrote: >> >> Rasmus Villemoes (6): >> plugins: implement format_template attribute >> compiler.h: add __format_template > > Could you split these two off and send separately? This seems like a > fine thing to get in now. Will do. > Probably the second patch should be split up > between adding __format_template, and additions of its usage. Yeah. > Do you have any good ways to find and extract all the dynamic format strings > we need to mark? IIRC, I just did a git grep for designated initializers where the RHS was a string literal containing a % char. Not sure that counts as a good way :) Doing that now finds stuff like drivers/scsi/hisi_sas/hisi_sas_v2_hw.c, where the .msg member cannot be annotated with a single template. Maybe one can work around that by replacing .msg with an anon union of msg_onebit/msg_multibit, with each their own template; I don't know if that will work, or if it will be deemed too much churn (it doesn't provide that much safety, since it would then just rely on accessing the right union member). Maybe the run-time checking is best for that case. Rasmus From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <20171108223020.24487-1-linux@rasmusvillemoes.dk> From: Rasmus Villemoes Date: Thu, 9 Nov 2017 15:08:39 +0100 Message-ID: Content-Type: text/plain; charset="UTF-8" Subject: [kernel-hardening] Re: [RFC 0/6] some compile- and run-time format checking To: Kees Cook Cc: kernel-hardening@lists.openwall.com, LKML , Andrew Morton List-ID: On 9 November 2017 at 02:11, Kees Cook wrote: > On Wed, Nov 8, 2017 at 2:30 PM, Rasmus Villemoes > wrote: >> >> Rasmus Villemoes (6): >> plugins: implement format_template attribute >> compiler.h: add __format_template > > Could you split these two off and send separately? This seems like a > fine thing to get in now. Will do. > Probably the second patch should be split up > between adding __format_template, and additions of its usage. Yeah. > Do you have any good ways to find and extract all the dynamic format strings > we need to mark? IIRC, I just did a git grep for designated initializers where the RHS was a string literal containing a % char. Not sure that counts as a good way :) Doing that now finds stuff like drivers/scsi/hisi_sas/hisi_sas_v2_hw.c, where the .msg member cannot be annotated with a single template. Maybe one can work around that by replacing .msg with an anon union of msg_onebit/msg_multibit, with each their own template; I don't know if that will work, or if it will be deemed too much churn (it doesn't provide that much safety, since it would then just rely on accessing the right union member). Maybe the run-time checking is best for that case. Rasmus