bugfindutils - Bugs: bug #62621, xargs/find: buildcmd incorrectly...

 
 

bug #62621: xargs/find: buildcmd incorrectly sizes argv and envp

Submitter:  Thomas Hurst <freaky>
Submitted:  Mon 13 Jun 2022 01:24:21 PM UTC
 
Category:  xargs Severity:  3 - Normal
Item Group:  Wrong result Status:  None
Privacy:  Public Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  None Fixed Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Mon 13 Jun 2022 03:37:47 PM UTC, comment #1: 

Another thing: hypothetically, `xargs` could be built as a 32-bit binary, launching a 64-bit binary.  In that case, `sizeof(void *)` is not enough, since `xargs` will think it's 4 while the kernel will think it's 8.

Tavian Barnes <tavianator>
Mon 13 Jun 2022 01:24:21 PM UTC, original submission:  

buildcmd.c calculates the size of both arguments and environment entries as strlen(s) + 1 - the size of the string plus delimiter.

This fails to take into account the argv/envp pointer to each entry, which at least on Linux also contributes to the limit. To quote bprm_stack_limits() from fs/exec.c:

> We must account for the size of all the argv and envp pointers to
> the argv and envp strings, since they will also take up space in
> the stack.


And indeed, sizeof(void*)*argc+envc are subtracted from the limit it enforces.

This issue is masked by xargs defaulting to quite modest limits, and retrying automatically with smaller sizes on E2BIG - though in testing this I find what appears to be another issue, which I will file separately.

Thomas Hurst <freaky>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by tavianator (Posted a comment)
  • -email is unavailable- added by freaky (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

     

     

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.10