One patch for making it possible to execute usermode driver's path.

tomoyo: Loosen pathname/domainname validation.
 
  security/tomoyo/util.c |   29 +++++++++++++++++++++++------
  1 file changed, 23 insertions(+), 6 deletions(-)
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJfhDj0AAoJEEJfEo0MZPUqKBYP/in6mwhoEs8EczqSJ04cRYf9
 zD1BRwubpwsiQgD6TBxHcJ1Kplpd1vp+IRtLYCG38HDZlLjRnSMKDn6dOUEwi3bf
 Uc8cBZ4FgUSxlFIyBoUjiG5IbUSndFbigJrbrMno8xKEedUcnoSntDTYsfDjuHAL
 5G6yBgCGZd3UI57Utgt+se73eptdseTLtGlCd/fD6tfZJpwiWpBlRdqM3C6PVAS5
 M9hFblYTVcR7mh1zB2fGxclgX0PIB9l8eq24yrWqOMyGaQP1C7aFuoonTxJbh295
 g4Ea5jLBmZkvjE0L1Wxu9WFLBfdepNVnKoDLayKasLFIl4OLoWUad1R+ALb5RhgM
 6pVlaJO7FjSKOc1gTq3R8WGUI0xUhP3BEwRKOron0x5n2CDew0+qZ0GIntv9K27A
 mSzk4US4T2rwKUp6L5kwsCSvh2GEvYrEdKACz8Ey0hqLSJgoUgowISh5+dpCNSd/
 GosDlZ1m35MyINT827YTVqzg7KN+HGrH/dt/vfHXCAprpcr33RBS/UniUqERA5y4
 aNHY+bwy2/uw6UUmpwwNuAVM97jIGQAfr13CxCOztCo4oXos4ksFU/BEp2fh6rJV
 5zW1+QoEQOKuDNvRT+KeFPxXunX45FcRceh7SumFvGA0vk9X6kMS5I1B2gmcMqIT
 3BZYCqGPm73o0xzhE3Xf
 =onIp
 -----END PGP SIGNATURE-----

Merge tag 'tomoyo-pr-20201012' of git://git.osdn.net/gitroot/tomoyo/tomoyo-test1

Pull tomoyo fix from Tetsuo HandaL
 "One patch to make it possible to execute usermode-driver's path"

* tag 'tomoyo-pr-20201012' of git://git.osdn.net/gitroot/tomoyo/tomoyo-test1:
  tomoyo: Loosen pathname/domainname validation.
This commit is contained in:
Linus Torvalds 2020-10-13 16:10:37 -07:00
commit b274279a0b

View File

@ -143,6 +143,8 @@ char *tomoyo_read_token(struct tomoyo_acl_param *param)
return pos;
}
static bool tomoyo_correct_path2(const char *filename, const size_t len);
/**
* tomoyo_get_domainname - Read a domainname from a line.
*
@ -157,10 +159,10 @@ const struct tomoyo_path_info *tomoyo_get_domainname
char *pos = start;
while (*pos) {
if (*pos++ != ' ' || *pos++ == '/')
if (*pos++ != ' ' ||
tomoyo_correct_path2(pos, strchrnul(pos, ' ') - pos))
continue;
pos -= 2;
*pos++ = '\0';
*(pos - 1) = '\0';
break;
}
param->data = pos;
@ -513,6 +515,22 @@ bool tomoyo_correct_word(const char *string)
return tomoyo_correct_word2(string, strlen(string));
}
/**
* tomoyo_correct_path2 - Check whether the given pathname follows the naming rules.
*
* @filename: The pathname to check.
* @len: Length of @filename.
*
* Returns true if @filename follows the naming rules, false otherwise.
*/
static bool tomoyo_correct_path2(const char *filename, const size_t len)
{
const char *cp1 = memchr(filename, '/', len);
const char *cp2 = memchr(filename, '.', len);
return cp1 && (!cp2 || (cp1 < cp2)) && tomoyo_correct_word2(filename, len);
}
/**
* tomoyo_correct_path - Validate a pathname.
*
@ -523,7 +541,7 @@ bool tomoyo_correct_word(const char *string)
*/
bool tomoyo_correct_path(const char *filename)
{
return *filename == '/' && tomoyo_correct_word(filename);
return tomoyo_correct_path2(filename, strlen(filename));
}
/**
@ -545,8 +563,7 @@ bool tomoyo_correct_domain(const unsigned char *domainname)
if (!cp)
break;
if (*domainname != '/' ||
!tomoyo_correct_word2(domainname, cp - domainname))
if (!tomoyo_correct_path2(domainname, cp - domainname))
return false;
domainname = cp + 1;
}