Skip to content

Commit a6ed569

Browse files
committed
Merge patch series "coredump: further cleanups"
Christian Brauner <[email protected]> says: Continue reworking the coredump code so it's easier to follow and modify in the future. * Each method is moved into a separate helper. * The cleanup code is simplified and unified. * Entangle the dependency between the pipe coredump rate limiting and the common exit path. It's likely that there'll be more. * patches from https://lore.kernel.org/[email protected]: (24 commits) coredump: add coredump_skip() helper coredump: avoid pointless variable coredump: order auto cleanup variables at the top coredump: add coredump_cleanup() coredump: auto cleanup prepare_creds() cred: add auto cleanup method coredump: directly return coredump: auto cleanup argv coredump: add coredump_write() coredump: use a single helper for the socket coredump: move pipe specific file check into coredump_pipe() coredump: split pipe coredumping into coredump_pipe() coredump: move core_pipe_count to global variable coredump: prepare to simplify exit paths coredump: split file coredumping into coredump_file() coredump: rename do_coredump() to vfs_coredump() selftests/coredump: make sure invalid paths are rejected coredump: validate socket path in coredump_parse() coredump: don't allow ".." in coredump socket path fs: move name_contains_dotdot() to header ... Link: https://lore.kernel.org/[email protected] Signed-off-by: Christian Brauner <[email protected]>
2 parents e04f97c + da9029b commit a6ed569

File tree

9 files changed

+366
-279
lines changed

9 files changed

+366
-279
lines changed

Documentation/security/credentials.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,5 +555,5 @@ the VFS, and that can be done by calling into such as ``vfs_mkdir()`` with a
555555
different set of credentials. This is done in the following places:
556556

557557
* ``sys_faccessat()``.
558-
* ``do_coredump()``.
558+
* ``vfs_coredump()``.
559559
* nfs4recover.c.

Documentation/translations/zh_CN/security/credentials.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,5 +475,5 @@ const指针上操作,因此不需要进行类型转换,但需要临时放弃
475475
如 ``vfs_mkdir()`` 来实现。以下是一些进行此操作的位置:
476476

477477
* ``sys_faccessat()``.
478-
* ``do_coredump()``.
478+
* ``vfs_coredump()``.
479479
* nfs4recover.c.

drivers/base/firmware_loader/main.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -822,26 +822,6 @@ static void fw_log_firmware_info(const struct firmware *fw, const char *name,
822822
{}
823823
#endif
824824

825-
/*
826-
* Reject firmware file names with ".." path components.
827-
* There are drivers that construct firmware file names from device-supplied
828-
* strings, and we don't want some device to be able to tell us "I would like to
829-
* be sent my firmware from ../../../etc/shadow, please".
830-
*
831-
* Search for ".." surrounded by either '/' or start/end of string.
832-
*
833-
* This intentionally only looks at the firmware name, not at the firmware base
834-
* directory or at symlink contents.
835-
*/
836-
static bool name_contains_dotdot(const char *name)
837-
{
838-
size_t name_len = strlen(name);
839-
840-
return strcmp(name, "..") == 0 || strncmp(name, "../", 3) == 0 ||
841-
strstr(name, "/../") != NULL ||
842-
(name_len >= 3 && strcmp(name+name_len-3, "/..") == 0);
843-
}
844-
845825
/* called from request_firmware() and request_firmware_work_func() */
846826
static int
847827
_request_firmware(const struct firmware **firmware_p, const char *name,
@@ -862,6 +842,17 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
862842
goto out;
863843
}
864844

845+
846+
/*
847+
* Reject firmware file names with ".." path components.
848+
* There are drivers that construct firmware file names from
849+
* device-supplied strings, and we don't want some device to be
850+
* able to tell us "I would like to be sent my firmware from
851+
* ../../../etc/shadow, please".
852+
*
853+
* This intentionally only looks at the firmware name, not at
854+
* the firmware base directory or at symlink contents.
855+
*/
865856
if (name_contains_dotdot(name)) {
866857
dev_warn(device,
867858
"Firmware load for '%s' refused, path contains '..' component\n",

0 commit comments

Comments
 (0)