Re: [PATCH 2/6] Improvements for IMSM_NO_PLATFORM testing.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 20 Mar 2023, Jes Sorensen wrote:
> On 3/12/23 23:42, NeilBrown wrote:
> > Factor out IMSM_NO_PLATFORM testing into a single function that caches
> > the result.
> > 
> > Allow mdmon to explicitly set the result to "1" so that we don't need
> > the ENV var in the unit file
> > 
> > Check if the kernel command line contains "mdadm.imsm.test=1" and in
> > that case assert NO_PLATFORM.  This simplifies testing in a virtual
> > machine.
> > 
> > Signed-off-by: NeilBrown <neilb@xxxxxxx>
> > ---
> >  mdadm.h                |    2 ++
> >  mdmon.c                |    6 ++++++
> >  super-intel.c          |   43 ++++++++++++++++++++++++++++++++++++++++---
> >  systemd/mdmon@.service |    3 ---
> >  4 files changed, 48 insertions(+), 6 deletions(-)
> 
> Hi Neil
> 
> > diff --git a/super-intel.c b/super-intel.c
> > index e155a8ae99cb..a514dea6f95c 100644
> > --- a/super-intel.c
> > +++ b/super-intel.c
> > @@ -629,6 +629,43 @@ static const char *_sys_dev_type[] = {
> >  	[SYS_DEV_VMD] = "VMD"
> >  };
> >  
> > +static int no_platform = -1;
> > +
> > +static int check_no_platform(void)
> > +{
> > +	static const char search[] = "mdadm.imsm.test=1";
> > +	int fd;
> > +	char buf[1024];
> 
> This isn't safe, /proc/cmdline can be longer than 1024 characters.

Why not safe?  I agree that /proc/cmdline can be longer than 1024 but the
only only considers the first 1023 at most, and does so safely.

What would you prefer?  Should I use conf_line() to read the line and
split it into words for us?

Thanks,
NeilBrown


> 
> Cheers,
> Jes
> 
> 




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux