All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: Alejandro Colomar <alx@kernel.org>,
	Alex Elder <elder@riscstar.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Azeem Shaikh <azeemshaikh38@gmail.com>,
	Alex Elder <elder@kernel.org>, Sumit Garg <sumit.garg@kernel.org>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] EISA: Increase length of device names
Date: Mon, 7 Apr 2025 10:12:28 -0700	[thread overview]
Message-ID: <202504070957.A97CCC289B@keescook> (raw)
In-Reply-To: <alpine.DEB.2.21.2504021652130.53907@angie.orcam.me.uk>

On Thu, Apr 03, 2025 at 12:23:31AM +0100, Maciej W. Rozycki wrote:
> On Sat, 15 Mar 2025, Alejandro Colomar wrote:
> 
> > > > GCC 15's -Wunterminated-string-initialization warned about truncated
> > > > name strings. Instead of marking them with the "nonstring" attribute[1],
> > > > increase their length to correctly include enough space for the
> > > > terminating NUL character, as they are used with %s format specifiers.
> > 
> > It might be interesting to mention where they are used with %s.
> 
>  Indeed.  I seem to be missing something here as I can't see an issue in 
> reality:
> 
> # cat /proc/ioports | sed -n '/EISA/,$p'
> 0c80-0c83 : 486EI EISA System Board
> 5000-50ff : DEC FDDIcontroller/EISA Adapter
>   5000-503f : defxx
>   5040-5043 : defxx
> 5400-54ff : DEC FDDIcontroller/EISA Adapter
> 5800-58ff : DEC FDDIcontroller/EISA Adapter
> 5c00-5cff : DEC FDDIcontroller/EISA Adapter
>   5c80-5cbf : defxx
> 6000-60ff : Network Peripherals NP-EISA-3E Enhanced FDDI Inte
> 6400-64ff : Network Peripherals NP-EISA-3E Enhanced FDDI Inte
> 6800-68ff : Network Peripherals NP-EISA-3E Enhanced FDDI Inte
> 6c00-6cff : Network Peripherals NP-EISA-3E Enhanced FDDI Inte
> 8000-80ff : 3Com 3C509-Combo Network Adapter
>   8000-800f : 3c579-eisa
> 8400-84ff : 3Com 3C509-Combo Network Adapter
> 8800-88ff : 3Com 3C509-Combo Network Adapter
> 8c00-8cff : 3Com 3C509-Combo Network Adapter
> # 
> 
> nor why incrementing the length specifically to 51 (where eisa.ids names 
> are up to 73 characters; one of the longer entries can be seen truncated 
> above) is going to change anything here.  Overall since the string length 
> is fixed I'd expect just using `%.50s' instead.

These are produced from:

        seq_printf(m, "%*s%0*llx-%0*llx : %s\n", ..., r->name);

which is struct resource::name, which is unbounded.

> 
> > > For what it's worth, it looks fine to me.
> > 
> > LGTM too.  Assuming that changing the size of the arrays doesn't break
> > something else, it looks good.
> 
>  ISTM increasing to 74 instead might make more sense (I don't know what 
> the actual maximum size was according to the ECU standard, but it might 

The only mention of names I could find in the EISA spec just says,
"The NAME field contains text that describes the board. The MFR field
contains the full name of the board manufacturer." This is in the
configuration files, though, so it seems unbounded.

I suspect the right choice is to use eisa.ids as the length guide, as
you suggest.

> not be that we'll ever add any new entries to our list), once the origin 
> of the problem is known, though I think we need to evaluate what effect 
> such a change will have on the size of the compiled kernel.

I also see this hard limit of 50 in the Makefile:

# Ugly hack to get DEVICE_NAME_SIZE value...
DEVICE_NAME_SIZE = 50

$(obj)/eisa-bus.o: $(obj)/devlist.h

quiet_cmd_eisaid = GEN     $@
      cmd_eisaid = sed -e '/^\#/D' -e 's/^\([[:alnum:]]\{7\}\) \+"\([^"]\{1,$(DEVICE_NAME_SIZE)\}\).*"/EISA_DEVINFO ("\1", "\2"),/' $< > $@

The 50 was chosen seemingly at random in commit ca52a49846f1 ("driver
core: remove DEVICE_NAME_SIZE define").

I think that limit can be removed entirely.

-- 
Kees Cook

  reply	other threads:[~2025-04-07 17:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-10 22:24 [PATCH] EISA: Increase length of device names Kees Cook
2025-03-15 14:27 ` Alex Elder
2025-03-15 16:02   ` Alejandro Colomar
2025-04-02 23:23     ` Maciej W. Rozycki
2025-04-07 17:12       ` Kees Cook [this message]
2025-04-07 16:49   ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202504070957.A97CCC289B@keescook \
    --to=kees@kernel.org \
    --cc=alx@kernel.org \
    --cc=azeemshaikh38@gmail.com \
    --cc=elder@kernel.org \
    --cc=elder@riscstar.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macro@orcam.me.uk \
    --cc=sumit.garg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.