The following issues were found
tools/testing/selftests/bpf/test_lirc_mode2_user.c
4 issues
Line: 68
Column: 11
CWE codes:
362
return 1;
}
lircfd = open(argv[1], O_RDWR | O_NONBLOCK);
if (lircfd == -1) {
printf("failed to open lirc device %s: %m\n", argv[1]);
return 1;
}
Reported by FlawFinder.
Line: 81
Column: 12
CWE codes:
362
return 1;
}
inputfd = open(argv[2], O_RDONLY | O_NONBLOCK);
if (inputfd == -1) {
printf("failed to open input device %s: %m\n", argv[1]);
return 1;
}
Reported by FlawFinder.
Line: 120
Column: 9
CWE codes:
120
20
poll(&pfd, 1, 100);
/* Read decoded IR */
ret = read(inputfd, &event, sizeof(event));
if (ret != sizeof(event)) {
printf("Failed to read decoded IR: %m\n");
return 1;
}
Reported by FlawFinder.
Line: 143
Column: 9
CWE codes:
120
20
poll(&pfd, 1, 100);
/* Read decoded IR */
ret = read(inputfd, &event, sizeof(event));
if (ret != sizeof(event)) {
printf("Failed to read decoded IR: %m\n");
return 1;
}
Reported by FlawFinder.
tools/lib/subcmd/run-command.c
4 issues
Line: 128
Column: 4
CWE codes:
78
Suggestion:
try using a library call that implements the same functionality if available
if (cmd->exec_cmd) {
execv_cmd(cmd->argv);
} else {
execvp(cmd->argv[0], (char *const*) cmd->argv);
}
exit(127);
}
if (cmd->pid < 0) {
Reported by FlawFinder.
Line: 24
Column: 11
CWE codes:
362
static inline void dup_devnull(int to)
{
int fd = open("/dev/null", O_RDWR);
dup2(fd, to);
close(fd);
}
int start_command(struct child_process *cmd)
Reported by FlawFinder.
Line: 33
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
{
int need_in, need_out, need_err;
int fdin[2], fdout[2], fderr[2];
char sbuf[STRERR_BUFSIZE];
/*
* In case of errors we must keep the promise to close FDs
* that have been passed in via ->in and ->out.
*/
Reported by FlawFinder.
Line: 168
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
static int wait_or_whine(pid_t pid)
{
char sbuf[STRERR_BUFSIZE];
for (;;) {
int status, code;
pid_t waiting = waitpid(pid, &status, 0);
Reported by FlawFinder.
tools/perf/util/lzma.c
4 issues
Line: 46
Column: 11
CWE codes:
362
u8 buf_out[BUFSIZE];
FILE *infile;
infile = fopen(input, "rb");
if (!infile) {
pr_err("lzma: fopen failed on %s: '%s'\n",
input, strerror(errno));
return -1;
}
Reported by FlawFinder.
Line: 112
Column: 11
CWE codes:
362
bool lzma_is_compressed(const char *input)
{
int fd = open(input, O_RDONLY);
const uint8_t magic[6] = { 0xFD, '7', 'z', 'X', 'Z', 0x00 };
char buf[6] = { 0 };
ssize_t rc;
if (fd < 0)
Reported by FlawFinder.
Line: 114
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
{
int fd = open(input, O_RDONLY);
const uint8_t magic[6] = { 0xFD, '7', 'z', 'X', 'Z', 0x00 };
char buf[6] = { 0 };
ssize_t rc;
if (fd < 0)
return -1;
Reported by FlawFinder.
tools/testing/selftests/bpf/test_sock_addr.c
4 issues
Line: 62
Column: 1
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
typedef int (*load_fn)(const struct sock_addr_test *test);
typedef int (*info_fn)(int, struct sockaddr *, socklen_t *);
char bpf_log_buf[BPF_LOG_BUF_SIZE];
struct sock_addr_test {
const char *descr;
/* BPF prog properties */
load_fn loadfn;
Reported by FlawFinder.
Line: 1030
Column: 3
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
int *syscall_err)
{
union {
char buf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
struct cmsghdr align;
} control6;
union {
char buf[CMSG_SPACE(sizeof(struct in_pktinfo))];
struct cmsghdr align;
Reported by FlawFinder.
Line: 1034
Column: 3
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
struct cmsghdr align;
} control6;
union {
char buf[CMSG_SPACE(sizeof(struct in_pktinfo))];
struct cmsghdr align;
} control4;
struct msghdr hdr;
struct iovec iov;
char data = 'a';
Reported by FlawFinder.
Line: 1108
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
struct timeval tv;
struct msghdr hdr;
struct iovec iov;
char data[64];
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(sockfd, &rfds);
Reported by FlawFinder.
drivers/input/joystick/db9.c
4 issues
Line: 95
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
int used;
int parportno;
struct mutex mutex;
char phys[DB9_MAX_DEVICES][32];
};
static struct db9 *db9_base[3];
static const short db9_multi_btn[] = { BTN_TRIGGER, BTN_THUMB };
Reported by FlawFinder.
Line: 259
Column: 57
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
/*
* db9_saturn_report() analyzes packet and reports.
*/
static int db9_saturn_report(unsigned char id, unsigned char data[60], struct input_dev *devs[], int n, int max_pads)
{
struct input_dev *dev;
int tmp, i, j;
tmp = (id == 0x41) ? 60 : 10;
Reported by FlawFinder.
Line: 259
Column: 39
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
/*
* db9_saturn_report() analyzes packet and reports.
*/
static int db9_saturn_report(unsigned char id, unsigned char data[60], struct input_dev *devs[], int n, int max_pads)
{
struct input_dev *dev;
int tmp, i, j;
tmp = (id == 0x41) ? 60 : 10;
Reported by FlawFinder.
Line: 327
Column: 11
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
static int db9_saturn(int mode, struct parport *port, struct input_dev *devs[])
{
unsigned char id, data[60];
int type, n, max_pads;
int tmp, i;
switch (mode) {
case DB9_SATURN_PAD:
Reported by FlawFinder.
drivers/hid/i2c-hid/i2c-hid-core.c
4 issues
Line: 239
CWE codes:
476
cmd->c.reportTypeID = reportID | reportType << 4;
}
memcpy(cmd->data + length, args, args_len);
length += args_len;
i2c_hid_dbg(ihid, "%s: cmd=%*ph\n", __func__, length, cmd->data);
msg[0].addr = client->addr;
Reported by Cppcheck.
Line: 239
Column: 2
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
cmd->c.reportTypeID = reportID | reportType << 4;
}
memcpy(cmd->data + length, args, args_len);
length += args_len;
i2c_hid_dbg(ihid, "%s: cmd=%*ph\n", __func__, length, cmd->data);
msg[0].addr = client->addr;
Reported by FlawFinder.
Line: 386
Column: 2
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (reportID)
args[index++] = reportID;
memcpy(&args[index], buf, data_len);
ret = __i2c_hid_command(client, hidcmd, reportID,
reportType, args, args_len, NULL, 0);
if (ret) {
dev_err(&client->dev, "failed to set a report to device.\n");
Reported by FlawFinder.
Line: 638
Column: 2
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
/* The query buffer contains the size, dropping it in the reply */
count = min(count, ret_count - 2);
memcpy(buf, ihid->rawbuf + 2, count);
return count;
}
static int i2c_hid_output_raw_report(struct hid_device *hid, __u8 *buf,
Reported by FlawFinder.
drivers/i2c/busses/i2c-scmi.c
4 issues
Line: 372
Column: 2
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
return -ENOMEM;
smbus_cmi->handle = device->handle;
strcpy(acpi_device_name(device), ACPI_SMBUS_HC_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_SMBUS_HC_CLASS);
device->driver_data = smbus_cmi;
smbus_cmi->cap_info = 0;
smbus_cmi->cap_read = 0;
smbus_cmi->cap_write = 0;
Reported by FlawFinder.
Line: 373
Column: 2
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
smbus_cmi->handle = device->handle;
strcpy(acpi_device_name(device), ACPI_SMBUS_HC_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_SMBUS_HC_CLASS);
device->driver_data = smbus_cmi;
smbus_cmi->cap_info = 0;
smbus_cmi->cap_read = 0;
smbus_cmi->cap_write = 0;
Reported by FlawFinder.
Line: 259
Column: 3
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
return -EPROTO;
data->block[0] = len;
memcpy(data->block + 1, obj->buffer.pointer, len);
break;
}
out:
kfree(buffer.pointer);
Reported by FlawFinder.
Line: 348
Column: 2
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
static acpi_status acpi_smbus_cmi_query_methods(acpi_handle handle, u32 level,
void *context, void **return_value)
{
char node_name[5];
struct acpi_buffer buffer = { sizeof(node_name), node_name };
struct acpi_smbus_cmi *smbus_cmi = context;
acpi_status status;
status = acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
Reported by FlawFinder.
drivers/i2c/busses/i2c-sh_mobile.c
4 issues
Line: 518
Column: 32
CWE codes:
120
20
static void sh_mobile_i2c_xfer_dma(struct sh_mobile_i2c_data *pd)
{
bool read = pd->msg->flags & I2C_M_RD;
enum dma_data_direction dir = read ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
struct dma_chan *chan = read ? pd->dma_rx : pd->dma_tx;
struct dma_async_tx_descriptor *txdesc;
dma_addr_t dma_addr;
dma_cookie_t cookie;
Reported by FlawFinder.
Line: 519
Column: 26
CWE codes:
120
20
{
bool read = pd->msg->flags & I2C_M_RD;
enum dma_data_direction dir = read ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
struct dma_chan *chan = read ? pd->dma_rx : pd->dma_tx;
struct dma_async_tx_descriptor *txdesc;
dma_addr_t dma_addr;
dma_cookie_t cookie;
if (PTR_ERR(chan) == -EPROBE_DEFER) {
Reported by FlawFinder.
Line: 525
Column: 7
CWE codes:
120
20
dma_cookie_t cookie;
if (PTR_ERR(chan) == -EPROBE_DEFER) {
if (read)
chan = pd->dma_rx = sh_mobile_i2c_request_dma_chan(pd->dev, DMA_DEV_TO_MEM,
pd->res->start + ICDR);
else
chan = pd->dma_tx = sh_mobile_i2c_request_dma_chan(pd->dev, DMA_MEM_TO_DEV,
pd->res->start + ICDR);
Reported by FlawFinder.
Line: 548
Column: 7
CWE codes:
120
20
pd->dma_direction = dir;
txdesc = dmaengine_prep_slave_sg(chan, &pd->sg, 1,
read ? DMA_DEV_TO_MEM : DMA_MEM_TO_DEV,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (!txdesc) {
dev_dbg(pd->dev, "dma prep slave sg failed, using PIO\n");
sh_mobile_i2c_cleanup_dma(pd);
return;
Reported by FlawFinder.
drivers/infiniband/hw/mlx5/cmd.c
4 issues
Line: 131
Column: 2
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
MLX5_SET(attach_to_mcg_in, in, qpn, qpn);
MLX5_SET(attach_to_mcg_in, in, uid, uid);
gid = MLX5_ADDR_OF(attach_to_mcg_in, in, multicast_gid);
memcpy(gid, mgid, sizeof(*mgid));
return mlx5_cmd_exec_in(dev, attach_to_mcg, in);
}
int mlx5_cmd_detach_mcg(struct mlx5_core_dev *dev, union ib_gid *mgid,
u32 qpn, u16 uid)
Reported by FlawFinder.
Line: 145
Column: 2
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
MLX5_SET(detach_from_mcg_in, in, qpn, qpn);
MLX5_SET(detach_from_mcg_in, in, uid, uid);
gid = MLX5_ADDR_OF(detach_from_mcg_in, in, multicast_gid);
memcpy(gid, mgid, sizeof(*mgid));
return mlx5_cmd_exec_in(dev, detach_from_mcg, in);
}
int mlx5_cmd_xrcd_alloc(struct mlx5_core_dev *dev, u32 *xrcdn, u16 uid)
{
Reported by FlawFinder.
Line: 194
Column: 2
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
MLX5_SET(mad_ifc_in, in, port, port);
data = MLX5_ADDR_OF(mad_ifc_in, in, mad);
memcpy(data, inb, MLX5_FLD_SZ_BYTES(mad_ifc_in, mad));
err = mlx5_cmd_exec_inout(dev, mad_ifc, in, out);
if (err)
goto out;
Reported by FlawFinder.
Line: 201
Column: 2
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
goto out;
resp = MLX5_ADDR_OF(mad_ifc_out, out, response_mad_packet);
memcpy(outb, resp,
MLX5_FLD_SZ_BYTES(mad_ifc_out, response_mad_packet));
out:
kfree(out);
kfree(in);
Reported by FlawFinder.
drivers/gpu/drm/i915/intel_uncore.c
4 issues
Line: 1264
Column: 20
CWE codes:
120
20
static void
__unclaimed_reg_debug(struct intel_uncore *uncore,
const i915_reg_t reg,
const bool read,
const bool before)
{
if (drm_WARN(&uncore->i915->drm,
check_for_unclaimed_mmio(uncore) && !before,
"Unclaimed %s register 0x%x\n",
Reported by FlawFinder.
Line: 1270
Column: 8
CWE codes:
120
20
if (drm_WARN(&uncore->i915->drm,
check_for_unclaimed_mmio(uncore) && !before,
"Unclaimed %s register 0x%x\n",
read ? "read from" : "write to",
i915_mmio_reg_offset(reg)))
/* Only report the first N failures */
uncore->i915->params.mmio_debug--;
}
Reported by FlawFinder.
Line: 1279
Column: 18
CWE codes:
120
20
static inline void
unclaimed_reg_debug(struct intel_uncore *uncore,
const i915_reg_t reg,
const bool read,
const bool before)
{
if (likely(!uncore->i915->params.mmio_debug))
return;
Reported by FlawFinder.