Skip to content

Commit

Permalink
Merge tag 'v4.9.38' into linux-4.9.x-unofficial_grsec
Browse files Browse the repository at this point in the history
This is the 4.9.38 stable release
  • Loading branch information
minipli committed Jul 16, 2017
2 parents 0110ef4 + f0cd77d commit 4c6fc46
Show file tree
Hide file tree
Showing 29 changed files with 206 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION = 4
PATCHLEVEL = 9
SUBLEVEL = 37
SUBLEVEL = 38
EXTRAVERSION =
NAME = Roaring Lionus

Expand Down
1 change: 1 addition & 0 deletions arch/x86/include/asm/pat.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
bool pat_enabled(void);
void pat_disable(const char *reason);
extern void pat_init(void);
extern void init_cache_modes(void);

extern int reserve_memtype(u64 start, u64 end,
enum page_cache_mode req_pcm, enum page_cache_mode *ret_pcm);
Expand Down
7 changes: 7 additions & 0 deletions arch/x86/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,13 @@ void __init setup_arch(char **cmdline_p)

max_possible_pfn = max_pfn;

/*
* This call is required when the CPU does not support PAT. If
* mtrr_bp_init() invoked it already via pat_init() the call has no
* effect.
*/
init_cache_modes();

/*
* Define random base addresses for memory sections after max_pfn is
* defined and before each memory section base is used.
Expand Down
28 changes: 12 additions & 16 deletions arch/x86/mm/pat.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,23 @@
#undef pr_fmt
#define pr_fmt(fmt) "" fmt

static bool boot_cpu_done;

static int __read_mostly __pat_enabled = IS_ENABLED(CONFIG_X86_PAT);
static void init_cache_modes(void);
static bool __read_mostly boot_cpu_done;
static bool __read_mostly pat_disabled = !IS_ENABLED(CONFIG_X86_PAT);
static bool __read_mostly pat_initialized;
static bool __read_mostly init_cm_done;

void pat_disable(const char *reason)
{
if (!__pat_enabled)
if (pat_disabled)
return;

if (boot_cpu_done) {
WARN_ONCE(1, "x86/PAT: PAT cannot be disabled after initialization\n");
return;
}

__pat_enabled = 0;
pat_disabled = true;
pr_info("x86/PAT: %s\n", reason);

init_cache_modes();
}

static int __init nopat(char *str)
Expand All @@ -66,7 +64,7 @@ early_param("nopat", nopat);

bool pat_enabled(void)
{
return !!__pat_enabled;
return pat_initialized;
}
EXPORT_SYMBOL_GPL(pat_enabled);

Expand Down Expand Up @@ -204,6 +202,8 @@ static void __init_cache_modes(u64 pat)
update_cache_mode_entry(i, cache);
}
pr_info("x86/PAT: Configuration [0-7]: %s\n", pat_msg);

init_cm_done = true;
}

#define PAT(x, y) ((u64)PAT_ ## y << ((x)*8))
Expand All @@ -224,6 +224,7 @@ static void pat_bsp_init(u64 pat)
}

wrmsrl(MSR_IA32_CR_PAT, pat);
pat_initialized = true;

__init_cache_modes(pat);
}
Expand All @@ -241,10 +242,9 @@ static void pat_ap_init(u64 pat)
wrmsrl(MSR_IA32_CR_PAT, pat);
}

static void init_cache_modes(void)
void init_cache_modes(void)
{
u64 pat = 0;
static int init_cm_done;

if (init_cm_done)
return;
Expand Down Expand Up @@ -286,8 +286,6 @@ static void init_cache_modes(void)
}

__init_cache_modes(pat);

init_cm_done = 1;
}

/**
Expand All @@ -305,10 +303,8 @@ void pat_init(void)
u64 pat;
struct cpuinfo_x86 *c = &boot_cpu_data;

if (!pat_enabled()) {
init_cache_modes();
if (pat_disabled)
return;
}

if ((c->x86_vendor == X86_VENDOR_INTEL) &&
(((c->x86 == 0x6) && (c->x86_model <= 0xd)) ||
Expand Down
2 changes: 1 addition & 1 deletion crypto/rsa-pkcs1pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ static int pkcs1pad_verify_complete(struct akcipher_request *req, int err)
goto done;
pos++;

if (memcmp(out_buf + pos, digest_info->data, digest_info->size))
if (crypto_memneq(out_buf + pos, digest_info->data, digest_info->size))
goto done;

pos += digest_info->size;
Expand Down
6 changes: 5 additions & 1 deletion drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2095,7 +2095,11 @@ void device_shutdown(void)
pm_runtime_get_noresume(dev);
pm_runtime_barrier(dev);

if (dev->bus && dev->bus->shutdown) {
if (dev->class && dev->class->shutdown) {
if (initcall_debug)
dev_info(dev, "shutdown\n");
dev->class->shutdown(dev);
} else if (dev->bus && dev->bus->shutdown) {
if (initcall_debug)
dev_info(dev, "shutdown\n");
dev->bus->shutdown(dev);
Expand Down
36 changes: 36 additions & 0 deletions drivers/char/tpm/tpm-chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,41 @@ static void tpm_dev_release(struct device *dev)
kfree(chip);
}


/**
* tpm_class_shutdown() - prepare the TPM device for loss of power.
* @dev: device to which the chip is associated.
*
* Issues a TPM2_Shutdown command prior to loss of power, as required by the
* TPM 2.0 spec.
* Then, calls bus- and device- specific shutdown code.
*
* XXX: This codepath relies on the fact that sysfs is not enabled for
* TPM2: sysfs uses an implicit lock on chip->ops, so this could race if TPM2
* has sysfs support enabled before TPM sysfs's implicit locking is fixed.
*/
static int tpm_class_shutdown(struct device *dev)
{
struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev);

if (chip->flags & TPM_CHIP_FLAG_TPM2) {
down_write(&chip->ops_sem);
tpm2_shutdown(chip, TPM2_SU_CLEAR);
chip->ops = NULL;
up_write(&chip->ops_sem);
}
/* Allow bus- and device-specific code to run. Note: since chip->ops
* is NULL, more-specific shutdown code will not be able to issue TPM
* commands.
*/
if (dev->bus && dev->bus->shutdown)
dev->bus->shutdown(dev);
else if (dev->driver && dev->driver->shutdown)
dev->driver->shutdown(dev);
return 0;
}


/**
* tpm_chip_alloc() - allocate a new struct tpm_chip instance
* @pdev: device to which the chip is associated
Expand Down Expand Up @@ -168,6 +203,7 @@ struct tpm_chip *tpm_chip_alloc(struct device *pdev,
device_initialize(&chip->dev);

chip->dev.class = tpm_class;
chip->dev.class->shutdown = tpm_class_shutdown;
chip->dev.release = tpm_dev_release;
chip->dev.parent = pdev;
chip->dev.groups = chip->groups;
Expand Down
5 changes: 5 additions & 0 deletions drivers/char/tpm/tpm-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ static const struct attribute_group tpm_dev_group = {

void tpm_sysfs_add_device(struct tpm_chip *chip)
{
/* XXX: If you wish to remove this restriction, you must first update
* tpm_sysfs to explicitly lock chip->ops.
*/
if (chip->flags & TPM_CHIP_FLAG_TPM2)
return;
/* The sysfs routines rely on an implicit tpm_try_get_ops, device_del
* is called before ops is null'd and the sysfs core synchronizes this
* removal so that no callbacks are running or can run again
Expand Down
3 changes: 1 addition & 2 deletions drivers/crypto/caam/caamalg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2601,8 +2601,7 @@ static struct ablkcipher_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request
struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req);
struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher);
struct device *jrdev = ctx->jrdev;
gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
CRYPTO_TFM_REQ_MAY_SLEEP)) ?
gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
GFP_KERNEL : GFP_ATOMIC;
int src_nents, dst_nents = 0, sec4_sg_bytes;
struct ablkcipher_edesc *edesc;
Expand Down
4 changes: 2 additions & 2 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@ super_1_rdev_size_change(struct md_rdev *rdev, sector_t num_sectors)
}
sb = page_address(rdev->sb_page);
sb->data_size = cpu_to_le64(num_sectors);
sb->super_offset = rdev->sb_start;
sb->super_offset = cpu_to_le64(rdev->sb_start);
sb->sb_csum = calc_sb_1_csum(sb);
md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size,
rdev->sb_page);
Expand Down Expand Up @@ -2270,7 +2270,7 @@ static bool does_sb_need_changing(struct mddev *mddev)
/* Check if any mddev parameters have changed */
if ((mddev->dev_sectors != le64_to_cpu(sb->size)) ||
(mddev->reshape_position != le64_to_cpu(sb->reshape_position)) ||
(mddev->layout != le64_to_cpu(sb->layout)) ||
(mddev->layout != le32_to_cpu(sb->layout)) ||
(mddev->raid_disks != le32_to_cpu(sb->raid_disks)) ||
(mddev->chunk_sectors != le32_to_cpu(sb->chunksize)))
return true;
Expand Down
31 changes: 31 additions & 0 deletions drivers/media/pci/saa7134/saa7134-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,43 @@ static struct i2c_client saa7134_client_template = {

/* ----------------------------------------------------------- */

/* On Medion 7134 reading EEPROM needs DVB-T demod i2c gate open */
static void saa7134_i2c_eeprom_md7134_gate(struct saa7134_dev *dev)
{
u8 subaddr = 0x7, dmdregval;
u8 data[2];
int ret;
struct i2c_msg i2cgatemsg_r[] = { {.addr = 0x08, .flags = 0,
.buf = &subaddr, .len = 1},
{.addr = 0x08,
.flags = I2C_M_RD,
.buf = &dmdregval, .len = 1}
};
struct i2c_msg i2cgatemsg_w[] = { {.addr = 0x08, .flags = 0,
.buf = data, .len = 2} };

ret = i2c_transfer(&dev->i2c_adap, i2cgatemsg_r, 2);
if ((ret == 2) && (dmdregval & 0x2)) {
pr_debug("%s: DVB-T demod i2c gate was left closed\n",
dev->name);

data[0] = subaddr;
data[1] = (dmdregval & ~0x2);
if (i2c_transfer(&dev->i2c_adap, i2cgatemsg_w, 1) != 1)
pr_err("%s: EEPROM i2c gate open failure\n",
dev->name);
}
}

static int
saa7134_i2c_eeprom(struct saa7134_dev *dev, unsigned char *eedata, int len)
{
unsigned char buf;
int i,err;

if (dev->board == SAA7134_BOARD_MD7134)
saa7134_i2c_eeprom_md7134_gate(dev);

dev->i2c_client.addr = 0xa0 >> 1;
buf = 0;
if (1 != (err = i2c_master_send(&dev->i2c_client,&buf,1))) {
Expand Down
1 change: 1 addition & 0 deletions drivers/staging/comedi/comedi_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -2908,6 +2908,7 @@ static int __init comedi_init(void)
dev = comedi_alloc_board_minor(NULL);
if (IS_ERR(dev)) {
comedi_cleanup_board_minors();
class_destroy(comedi_class);
cdev_del(&comedi_cdev);
unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
COMEDI_NUM_MINORS);
Expand Down
3 changes: 3 additions & 0 deletions drivers/staging/vt6656/main_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ static int vnt_start(struct ieee80211_hw *hw)
goto free_all;
}

if (vnt_key_init_table(priv))
goto free_all;

priv->int_interval = 1; /* bInterval is set to 1 */

vnt_int_start_interrupt(priv);
Expand Down
2 changes: 1 addition & 1 deletion fs/ext4/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static ssize_t reserved_clusters_store(struct ext4_attr *a,
int ret;

ret = kstrtoull(skip_spaces(buf), 0, &val);
if (!ret || val >= clusters)
if (ret || val >= clusters)
return -EINVAL;

atomic64_set(&sbi->s_resv_clusters, val);
Expand Down
2 changes: 2 additions & 0 deletions include/linux/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ int subsys_virtual_register(struct bus_type *subsys,
* @suspend: Used to put the device to sleep mode, usually to a low power
* state.
* @resume: Used to bring the device from the sleep mode.
* @shutdown: Called at shut-down time to quiesce the device.
* @ns_type: Callbacks so sysfs can detemine namespaces.
* @namespace: Namespace of the device belongs to this class.
* @pm: The default device power management operations of this class.
Expand Down Expand Up @@ -401,6 +402,7 @@ struct class {

int (*suspend)(struct device *dev, pm_message_t state);
int (*resume)(struct device *dev);
int (*shutdown)(struct device *dev);

const struct kobj_ns_type_operations *ns_type;
const void *(*namespace)(struct device *dev);
Expand Down
4 changes: 3 additions & 1 deletion ipc/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1250,8 +1250,10 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,

timeo = MAX_SCHEDULE_TIMEOUT;
ret = netlink_attachskb(sock, nc, &timeo, NULL);
if (ret == 1)
if (ret == 1) {
sock = NULL;
goto retry;
}
if (ret) {
sock = NULL;
nc = NULL;
Expand Down
4 changes: 2 additions & 2 deletions kernel/locking/rwsem-spinlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ int __sched __down_write_common(struct rw_semaphore *sem, int state)

out_nolock:
list_del(&waiter.list);
if (!list_empty(&sem->wait_list))
__rwsem_do_wake(sem, 1);
if (!list_empty(&sem->wait_list) && sem->count >= 0)
__rwsem_do_wake(sem, 0);
raw_spin_unlock_irqrestore(&sem->wait_lock, flags);

return -EINTR;
Expand Down
9 changes: 9 additions & 0 deletions tools/include/linux/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,13 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
#define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; __write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })


#ifndef __fallthrough
# if defined(__GNUC__) && __GNUC__ >= 7
# define __fallthrough __attribute__ ((fallthrough))
# else
# define __fallthrough
# endif
#endif

#endif /* _TOOLS_LINUX_COMPILER_H */
6 changes: 3 additions & 3 deletions tools/perf/bench/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1573,13 +1573,13 @@ static int __bench_numa(const char *name)
"GB/sec,", "total-speed", "GB/sec total speed");

if (g->p.show_details >= 2) {
char tname[32];
char tname[14 + 2 * 10 + 1];
struct thread_data *td;
for (p = 0; p < g->p.nr_proc; p++) {
for (t = 0; t < g->p.nr_threads; t++) {
memset(tname, 0, 32);
memset(tname, 0, sizeof(tname));
td = g->threads + p*g->p.nr_threads + t;
snprintf(tname, 32, "process%d:thread%d", p, t);
snprintf(tname, sizeof(tname), "process%d:thread%d", p, t);
print_res(tname, td->speed_gbs,
"GB/sec", "thread-speed", "GB/sec/thread speed");
print_res(tname, td->system_time_ns / NSEC_PER_SEC,
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ static void *display_thread(void *arg)
case -1:
if (errno == EINTR)
continue;
/* Fall trhu */
__fallthrough;
default:
c = getc(stdin);
tcsetattr(0, TCSAFLUSH, &save);
Expand Down
Loading

0 comments on commit 4c6fc46

Please sign in to comment.